...
 
Commits (4)
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......@@ -231,9 +231,9 @@ private:
ITASampleFrame m_sfRingBuffer; //!< Ring buffer
int m_iStreamingStatus; //!< Current streaming status
double m_dLastStreamingTimeCode;
ITABufferedDataLoggerImplStream* m_pAudioStreamLogger; //!< Logging for the audio stream
double m_dLastStreamingTimeCode;
ITABufferedDataLoggerImplStream* m_pAudioStreamLogger; //!< Logging for the audio stream
ITABufferedDataLoggerImplNet* m_pNetworkStreamLogger; //!< Logging for the network stream
std::string m_sNetAudioStreamLoggerBaseName;
bool m_bDebuggingEnabled;
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......@@ -23,8 +23,10 @@
#include <ITACriticalSection.h>
#include <ITADataSource.h>
#include <ITAStopWatch.h>
#include <atomic>
#include <string>
#include <vector>
//! Detektor for statistic values in audio stream (i.e. for level metering)
......@@ -162,6 +164,12 @@ public:
virtual const float* GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* pStreamInfo );
virtual void IncrementBlockPointer();
void SetProfilerEnabled( bool bEnabled );
bool GetProfilerEnabled() const;
double GetProfilerMeanCalculationTime( bool bReset = true );
std::string GetProfilerResult( bool bReset = true );
protected:
ITADatasource* m_pDataSource; //!< Angeschlossene Datenquelle
double m_dSamplerate; //!< Abtastrate [Hz]
......@@ -174,6 +182,8 @@ protected:
int m_iOverallPeakChannel; //!< Kanal in dem der Spitzenwert auftrat
std::vector< double > m_vdRMSSquaredSums;
int m_iRMSBlocks;
bool m_bProfilerEnabled;
ITAStopWatch m_sw;
};
#endif // INCLUDE_WATCHER_ITA_PEAK_DETECTOR
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -4,138 +4,122 @@
#include <ITANumericUtils.h>
ITABufferDatasource::ITABufferDatasource()
: m_uiChannels( 0 )
, m_uiBlocklength( 0 )
, m_uiCapacity( 0 )
, m_iCursor( 0 )
, m_uiROIStart( 0 )
, m_uiROIEnd( 0 )
, m_uiNewROIStart( 0 )
, m_uiNewROIEnd( 0 )
, m_bLoopMode( false )
, m_bNewLoopMode( false )
, m_bChangeLoopMode( false )
, m_bRewind( false )
, m_bPaused( false )
, m_bChangeROI( false )
, m_bGetBlockPointerTouched( false )
, m_bInit( false )
: m_uiChannels( 0 )
, m_uiBlocklength( 0 )
, m_uiCapacity( 0 )
, m_iCursor( 0 )
, m_uiROIStart( 0 )
, m_uiROIEnd( 0 )
, m_uiNewROIStart( 0 )
, m_uiNewROIEnd( 0 )
, m_bLoopMode( false )
, m_bNewLoopMode( false )
, m_bChangeLoopMode( false )
, m_bRewind( false )
, m_bPaused( false )
, m_bChangeROI( false )
, m_bGetBlockPointerTouched( false )
, m_bInit( false )
{
}
ITABufferDatasource::ITABufferDatasource(const float** ppfBuffer,
unsigned int uiChannels,
unsigned int uiBuffersize,
double dSamplerate,
unsigned int uiBlocklength,
bool bLoopMode)
: m_uiChannels( uiChannels )
, m_uiBlocklength( uiBlocklength )
, m_uiCapacity( 0 )
, m_iCursor( 0 )
, m_uiROIStart( 0 )
, m_uiROIEnd( 0 )
, m_uiNewROIStart( 0 )
, m_uiNewROIEnd( 0 )
, m_bLoopMode( bLoopMode )
, m_bNewLoopMode( bLoopMode )
, m_bChangeLoopMode( false )
, m_bRewind( false )
, m_bPaused( false )
, m_bChangeROI( false )
, m_bGetBlockPointerTouched( false )
, m_bInit( false )
ITABufferDatasource::ITABufferDatasource( const float** ppfBuffer, unsigned int uiChannels, unsigned int uiBuffersize, double dSamplerate, unsigned int uiBlocklength, bool bLoopMode )
: m_uiChannels( uiChannels )
, m_uiBlocklength( uiBlocklength )
, m_uiCapacity( 0 )
, m_iCursor( 0 )
, m_uiROIStart( 0 )
, m_uiROIEnd( 0 )
, m_uiNewROIStart( 0 )
, m_uiNewROIEnd( 0 )
, m_bLoopMode( bLoopMode )
, m_bNewLoopMode( bLoopMode )
, m_bChangeLoopMode( false )
, m_bRewind( false )
, m_bPaused( false )
, m_bChangeROI( false )
, m_bGetBlockPointerTouched( false )
, m_bInit( false )
{
// Initialisieren
std::vector<float*> vpfBuffer;
for (unsigned int i=0; i<uiChannels; i++)
vpfBuffer.push_back( (float*) ppfBuffer[i] );
for( unsigned int i = 0; i < uiChannels; i++ )
vpfBuffer.push_back( ( float* ) ppfBuffer[ i ] );
Init(vpfBuffer, uiBuffersize, dSamplerate, uiBlocklength, bLoopMode);
Init( vpfBuffer, uiBuffersize, dSamplerate, uiBlocklength, bLoopMode );
}
ITABufferDatasource::ITABufferDatasource(const std::vector<float*>& vpfBuffer,
unsigned int uiBuffersize,
double dSamplerate,
unsigned int uiBlocklength,
bool bLoopMode)
: m_uiBlocklength( uiBlocklength )
, m_uiCapacity( 0 )
, m_iCursor( 0 )
, m_uiROIStart( 0 )
, m_uiROIEnd( 0 )
, m_uiNewROIStart( 0 )
, m_uiNewROIEnd( 0 )
, m_bLoopMode( bLoopMode )
, m_bNewLoopMode( bLoopMode )
, m_bChangeLoopMode( false )
, m_bRewind( false )
, m_bPaused( false )
, m_bChangeROI( false )
, m_bGetBlockPointerTouched( false )
, m_bInit( false )
ITABufferDatasource::ITABufferDatasource( const std::vector< float* >& vpfBuffer, unsigned int uiBuffersize, double dSamplerate, unsigned int uiBlocklength, bool bLoopMode )
: m_uiBlocklength( uiBlocklength )
, m_uiCapacity( 0 )
, m_iCursor( 0 )
, m_uiROIStart( 0 )
, m_uiROIEnd( 0 )
, m_uiNewROIStart( 0 )
, m_uiNewROIEnd( 0 )
, m_bLoopMode( bLoopMode )
, m_bNewLoopMode( bLoopMode )
, m_bChangeLoopMode( false )
, m_bRewind( false )
, m_bPaused( false )
, m_bChangeROI( false )
, m_bGetBlockPointerTouched( false )
, m_bInit( false )
{
m_uiChannels = (int) vpfBuffer.size();
m_uiChannels = ( int ) vpfBuffer.size();
// Initialisieren
Init(vpfBuffer, uiBuffersize, dSamplerate, uiBlocklength, bLoopMode);
Init( vpfBuffer, uiBuffersize, dSamplerate, uiBlocklength, bLoopMode );
}
ITABufferDatasource::ITABufferDatasource(const float* pfBuffer,
unsigned int uiBuffersize,
double dSamplerate,
unsigned int uiBlocklength,
bool bLoopMode)
: m_uiChannels( 1 )
, m_uiBlocklength( uiBlocklength )
, m_uiCapacity( 0 )
, m_iCursor( 0 )
, m_uiROIStart( 0 )
, m_uiROIEnd( 0 )
, m_uiNewROIStart( 0 )
, m_uiNewROIEnd( 0 )
, m_bLoopMode( bLoopMode )
, m_bNewLoopMode( bLoopMode )
, m_bChangeLoopMode( false )
, m_bRewind( false )
, m_bPaused( false )
, m_bChangeROI( false )
, m_bGetBlockPointerTouched( false )
, m_bInit( false )
ITABufferDatasource::ITABufferDatasource( const float* pfBuffer, unsigned int uiBuffersize, double dSamplerate, unsigned int uiBlocklength, bool bLoopMode )
: m_uiChannels( 1 )
, m_uiBlocklength( uiBlocklength )
, m_uiCapacity( 0 )
, m_iCursor( 0 )
, m_uiROIStart( 0 )
, m_uiROIEnd( 0 )
, m_uiNewROIStart( 0 )
, m_uiNewROIEnd( 0 )
, m_bLoopMode( bLoopMode )
, m_bNewLoopMode( bLoopMode )
, m_bChangeLoopMode( false )
, m_bRewind( false )
, m_bPaused( false )
, m_bChangeROI( false )
, m_bGetBlockPointerTouched( false )
, m_bInit( false )
{
// Initialisieren
std::vector<float*> vpfBuffer;
vpfBuffer.push_back( (float*) pfBuffer );
vpfBuffer.push_back( ( float* ) pfBuffer );
Init(vpfBuffer, uiBuffersize, dSamplerate, uiBlocklength, bLoopMode);
Init( vpfBuffer, uiBuffersize, dSamplerate, uiBlocklength, bLoopMode );
}
void ITABufferDatasource::Init(const std::vector<float*>& vpfBuffer,
unsigned int uiBuffersize,
double dSamplerate,
unsigned int uiBlocklength,
bool bLoopMode) {
if ((vpfBuffer.empty()) ||
(uiBuffersize == 0) ||
(dSamplerate <= 0)) ITA_EXCEPT0(INVALID_PARAMETER);
void ITABufferDatasource::Init( const std::vector<float*>& vpfBuffer, unsigned int uiBuffersize, double dSamplerate, unsigned int uiBlocklength, bool bLoopMode )
{
if( ( vpfBuffer.empty() ) || ( uiBuffersize == 0 ) || ( dSamplerate <= 0 ) )
ITA_EXCEPT0( INVALID_PARAMETER );
m_dSamplerate = dSamplerate;
m_uiChannels = (unsigned int) vpfBuffer.size();
m_uiChannels = ( unsigned int ) vpfBuffer.size();
m_uiBlocklength = uiBlocklength;
m_uiBuffersize = uiBuffersize;
m_dSamplerate = dSamplerate;
for (unsigned int i=0; i<m_uiChannels; i++) {
for( unsigned int i = 0; i < m_uiChannels; i++ )
{
// Keine Nullzeiger Kanalpuffer erlaubt
if (vpfBuffer[i] == 0) ITA_EXCEPT0(INVALID_PARAMETER)
m_vpfBuffer.push_back(vpfBuffer[i]);
}
if( vpfBuffer[ i ] == 0 ) ITA_EXCEPT0( INVALID_PARAMETER )
m_vpfBuffer.push_back( vpfBuffer[ i ] );
}
// Initialen Loop-Modus setzen
m_bLoopMode = m_bNewLoopMode = bLoopMode;
// Kapazitt = Nchstes kleineres Vielfaches der Blocklnge
m_uiCapacity = lwrmulu(uiBuffersize, m_uiBlocklength);
m_uiCapacity = lwrmulu( uiBuffersize, m_uiBlocklength );
// Start-/Endcursor auf Gesamtlnge des Puffers einstellen.
m_uiROIStart = m_uiNewROIStart = 0;
......@@ -144,36 +128,40 @@ void ITABufferDatasource::Init(const std::vector<float*>& vpfBuffer,
m_bInit = true;
}
unsigned int ITABufferDatasource::GetCapacity() {
unsigned int ITABufferDatasource::GetCapacity()
{
/* TODO: Diese Implementierung ist NICHT THREAD-SAFE.
m_uiCapacity kann durch IncrementReadPointer modifiziert werden,
m_uiCapacity kann durch IncrementReadPointer modifiziert werden,
whrend der Wert hier ausgelesen wird. */
return m_uiCapacity;
}
unsigned int ITABufferDatasource::GetAbsoluteCursor() {
unsigned int ITABufferDatasource::GetAbsoluteCursor()
{
/* TODO: Diese Implementierung ist NICHT THREAD-SAFE.
m_uiCursor kann durch IncrementReadPointer modifiziert werden,
m_uiCursor kann durch IncrementReadPointer modifiziert werden,
whrend der Wert hier ausgelesen wird. */
return (unsigned int) m_iCursor;
return ( unsigned int ) m_iCursor;
}
unsigned int ITABufferDatasource::GetCursor() {
/* TODO: Diese Implementierung ist NICHT THREAD-SAFE.
m_uiCursor kann durch IncrementReadPointer modifiziert werden,
m_uiCursor kann durch IncrementReadPointer modifiziert werden,
whrend der Wert hier ausgelesen wird. */
/* TODO: Problem, falls nderungen des Arbeitsbereiches, so dass
m_uiCursor pltzlich kleiner als m_uiNewROIStart */
return (unsigned int) m_iCursor - m_uiNewROIStart;
m_uiCursor pltzlich kleiner als m_uiNewROIStart */
return ( unsigned int ) m_iCursor - m_uiNewROIStart;
}
void ITABufferDatasource::SetCursor(unsigned int uiNewCursor) {
if (uiNewCursor > m_uiCapacity) {
void ITABufferDatasource::SetCursor( unsigned int uiNewCursor )
{
if( uiNewCursor > m_uiCapacity )
{
uiNewCursor = m_uiCapacity;
return;
}
m_iCursor = (int) uiNewCursor;
m_iCursor = ( int ) uiNewCursor;
}
void ITABufferDatasource::SetIsLooping( bool bEnabled )
......@@ -186,63 +174,73 @@ bool ITABufferDatasource::GetIsLooping()
return GetLoopMode();
}
bool ITABufferDatasource::GetLoopMode() {
bool ITABufferDatasource::GetLoopMode()
{
/* TODO: Diese Implementierung ist NICHT THREAD-SAFE.
m_bLoopMode kann durch IncrementReadPointer modifiziert werden,
m_bLoopMode kann durch IncrementReadPointer modifiziert werden,
whrend der Wert hier ausgelesen wird. */
return m_bNewLoopMode;
return m_bNewLoopMode;
}
void ITABufferDatasource::SetLoopMode(bool bLoopMode) {
void ITABufferDatasource::SetLoopMode( bool bLoopMode )
{
// Hinweis: Diese Implementierung ist Thread-Safe
if (!m_bInit) return;
if( !m_bInit )
return;
m_bNewLoopMode = bLoopMode;
m_bChangeLoopMode = true;
}
bool ITABufferDatasource::IsPaused() const {
bool ITABufferDatasource::IsPaused() const
{
return m_bPaused;
}
void ITABufferDatasource::SetPaused(bool bPaused) {
void ITABufferDatasource::SetPaused( bool bPaused )
{
m_bPaused = bPaused;
}
void ITABufferDatasource::SetROI(unsigned int uiStartOffset, unsigned int uiEndOffset) {
void ITABufferDatasource::SetROI( unsigned int uiStartOffset, unsigned int uiEndOffset )
{
// Hinweis: Diese Implementierung ist Thread-Safe
if (!m_bInit) return;
if( !m_bInit ) return;
// Parameter berprfen
if ((uiStartOffset >= m_uiCapacity) ||
(uiEndOffset > m_uiCapacity) ||
(uiStartOffset > uiEndOffset)) ITA_EXCEPT0(INVALID_PARAMETER);
if( ( uiStartOffset >= m_uiCapacity ) ||
( uiEndOffset > m_uiCapacity ) ||
( uiStartOffset > uiEndOffset ) ) ITA_EXCEPT0( INVALID_PARAMETER );
// Nchstkleineres Blocklngen-Vielfaches des Endoffset bestimmen
unsigned int l = lwrmulu((uiEndOffset - uiStartOffset), m_uiBlocklength);
unsigned int l = lwrmulu( ( uiEndOffset - uiStartOffset ), m_uiBlocklength );
m_uiNewROIStart = uiStartOffset;
m_uiNewROIEnd = uiStartOffset + l;
m_bChangeROI = true;
}
unsigned int ITABufferDatasource::GetROIStart() {
unsigned int ITABufferDatasource::GetROIStart()
{
/* TODO: Diese Implementierung ist NICHT THREAD-SAFE.
m_uiStartCursor kann durch IncrementReadPointer modifiziert werden,
m_uiStartCursor kann durch IncrementReadPointer modifiziert werden,
whrend der Wert hier ausgelesen wird. */
return m_uiNewROIStart;
}
unsigned int ITABufferDatasource::GetROIEnd() {
unsigned int ITABufferDatasource::GetROIEnd()
{
/* TODO: Diese Implementierung ist NICHT THREAD-SAFE.
m_uiEndCursor kann durch IncrementReadPointer modifiziert werden,
m_uiEndCursor kann durch IncrementReadPointer modifiziert werden,
whrend der Wert hier ausgelesen wird. */
return m_uiNewROIEnd;
}
unsigned int ITABufferDatasource::GetROILength() {
unsigned int ITABufferDatasource::GetROILength()
{
/* TODO: Diese Implementierung ist NICHT THREAD-SAFE.
m_uiEndCursor kann durch IncrementReadPointer modifiziert werden,
m_uiEndCursor kann durch IncrementReadPointer modifiziert werden,
whrend der Wert hier ausgelesen wird. */
return m_uiNewROIEnd - m_uiNewROIStart;
}
......@@ -256,15 +254,18 @@ void ITABufferDatasource::Rewind()
Update();
}
unsigned int ITABufferDatasource::GetBlocklength() const {
unsigned int ITABufferDatasource::GetBlocklength() const
{
return m_uiBlocklength;
}
unsigned int ITABufferDatasource::GetNumberOfChannels() const {
unsigned int ITABufferDatasource::GetNumberOfChannels() const
{
return m_uiChannels;
}
double ITABufferDatasource::GetSampleRate() const {
double ITABufferDatasource::GetSampleRate() const
{
return m_dSamplerate;
}
......@@ -286,34 +287,42 @@ const float* ITABufferDatasource::GetBlockPointer( unsigned int uiChannel, const
// Keine Eingangsdaten in der Datei oder keine Wiederholung und Ende erreicht:
// Dann Nullzeiger zurckgeben (d.h. keine Daten vorhanden)
if ((unsigned int) m_iCursor >= m_uiROIEnd) return 0;
if( ( unsigned int )
m_iCursor >= m_uiROIEnd ) return 0;
// Pausiert? => Dann auch Nullzeiger zurckgeben
if (m_bPausedInternal) return 0;
if( m_bPausedInternal )
return 0;
// Sonst Datenzeiger zurckgeben
return(m_vpfBuffer[uiChannel] + (unsigned int) m_iCursor); // bergebenen Cursor verwenden
return( m_vpfBuffer[ uiChannel ] + ( unsigned int ) m_iCursor ); // bergebenen Cursor verwenden
}
void ITABufferDatasource::IncrementBlockPointer() {
if (!m_bInit) return;
if (!Update()) return;
void ITABufferDatasource::IncrementBlockPointer()
{
if( !m_bInit )
return;
if( !Update() )
return;
if (m_bPausedInternal) {
if( m_bPausedInternal )
{
m_bGetBlockPointerTouched = false;
return;
}
// Ganz normale Verhaltensweise:
if ((unsigned int) m_iCursor < m_uiROIEnd) m_iCursor = m_iCursor + (int) m_uiBlocklength;
if( m_bLoopMode && ( (unsigned int)( m_iCursor ) >= m_uiROIEnd ) )
if( ( unsigned int ) m_iCursor < m_uiROIEnd )
m_iCursor = m_iCursor + ( int ) m_uiBlocklength;
if( m_bLoopMode && ( ( unsigned int ) ( m_iCursor ) >= m_uiROIEnd ) )
m_iCursor = int( m_uiROIStart );
m_bGetBlockPointerTouched = false;
}
bool ITABufferDatasource::Update()
{
{
if( m_bChangeLoopMode )
{
m_bLoopMode = m_bNewLoopMode;
......@@ -326,14 +335,15 @@ bool ITABufferDatasource::Update()
m_uiROIEnd = m_uiNewROIEnd;
m_bChangeROI = false;
if ((m_uiNewROIStart > (unsigned int) m_iCursor) || (m_uiNewROIEnd < (unsigned int) m_iCursor))
if( ( m_uiNewROIStart > ( unsigned int ) m_iCursor ) || ( m_uiNewROIEnd < ( unsigned int ) m_iCursor ) )
// Der aktuelle Cursor liegt auerhalb des Arbeitsbereiches
if ((m_bLoopMode) || ((unsigned int) m_iCursor < m_uiNewROIStart)) {
if( ( m_bLoopMode ) || ( ( unsigned int ) m_iCursor < m_uiNewROIStart ) )
{
// Falls Wiederholung eingeschaltet ist oder der Anfang des
// neuen Arbeitsbereiches vor den aktuellen Cursor verschoben
// wurde, so springt der Cursor nun an den Anfang des neuen
// Arbeitsbereiches
m_iCursor = (int) m_uiROIStart;
m_iCursor = ( int ) m_uiROIStart;
// Ein Rckspulwunsch ist damit erfllt
m_bRewind = false;
......@@ -343,15 +353,16 @@ bool ITABufferDatasource::Update()
if( m_bRewind )
{
m_iCursor = (int) m_uiROIStart;
m_iCursor = ( int ) m_uiROIStart;
m_bRewind = false;
return false;
}
}
// Wiederholungsmodus eingeschaltet und Cursor bereits hinter dem Ende
// des Arbeitsbereiches? Dann wieder zum Beginn des Arbeitsbereiches springen
if (m_bLoopMode && ((unsigned int) m_iCursor >= m_uiROIEnd)) {
m_iCursor = (int) m_uiROIStart;
if( m_bLoopMode && ( ( unsigned int ) m_iCursor >= m_uiROIEnd ) )
{
m_iCursor = ( int ) m_uiROIStart;
return false;
}
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
* RWTH Aachen University, Germany, 2015-2018
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -9,6 +9,7 @@
ITAStreamDetector::ITAStreamDetector( ITADatasource* pDataSource, const int iMode )
: m_pDataSource( pDataSource )
, m_iMode( iMode )
, m_bProfilerEnabled( false )
{
m_dSamplerate = pDataSource->GetSampleRate();
m_iChannels = int( pDataSource->GetNumberOfChannels() );
......@@ -76,23 +77,7 @@ float ITAStreamDetector::GetOverallPeak( int& iChannel, const bool bReset )
double ITAStreamDetector::GetOverallPeakDecibel( int& iChannel, const bool bReset )
{
if( m_iMode != ITAStreamDetector::PEAK && m_iMode != ITAStreamDetector::PEAK_AND_RMS )
ITA_EXCEPT1( MODAL_EXCEPTION, "Can not provide stream detector data because it is not calculated in this mode" );
m_cs.enter();
const double dOverallPeakDB = ratio_to_db20( m_fOverallPeak );
iChannel = m_iOverallPeakChannel;
if( bReset )
{
m_fOverallPeak = 0;
m_iOverallPeakChannel = 0;
}
m_cs.leave();
return dOverallPeakDB;
return ratio_to_db20( GetOverallPeak( iChannel, bReset ) );
}
float ITAStreamDetector::GetPeak( const int iChannel, const bool bReset )
......@@ -163,7 +148,10 @@ float ITAStreamDetector::GetOverallRMS( const bool bReset )
m_cs.enter();
if( m_iRMSBlocks == 0 )
{
m_cs.leave();
return 0.0f;
}
double dOverallRMSSums = 0;
for( size_t i = 0; i < m_vdRMSSquaredSums.size(); i++ )
......@@ -220,7 +208,10 @@ void ITAStreamDetector::GetRMSs( std::vector< float >& vfDest, const bool bReset
vfDest.resize( m_vdRMSSquaredSums.size(), 0.0f );
if( m_iRMSBlocks == 0 )
{
m_cs.leave();
return;
}
for( size_t c = 0; c < m_vdRMSSquaredSums.size(); c++ )
vfDest[ c ] = float( std::sqrt( ( m_vdRMSSquaredSums[ c ] / double( m_iRMSBlocks ) ) ) ); // RMS
......@@ -236,9 +227,14 @@ void ITAStreamDetector::GetRMSsDecibel( std::vector< float >& vdDestDecibel, con
if( m_iMode != ITAStreamDetector::RMS && m_iMode != ITAStreamDetector::PEAK_AND_RMS )
ITA_EXCEPT1( MODAL_EXCEPTION, "Can not provide stream detector data because it is not calculated in this mode" );
m_cs.enter();
vdDestDecibel.resize( m_vdRMSSquaredSums.size(), ITAConstants::MINUS_INFINITY_F );
if( m_iRMSBlocks == 0 )
{
m_cs.leave();
return;
}
for( size_t c = 0; c < m_vdRMSSquaredSums.size(); c++ )
vdDestDecibel[ c ] = float( ratio_to_db20( std::sqrt( m_vdRMSSquaredSums[ c ] / double( m_iRMSBlocks * m_iBlocklength ) ) ) ); // RMS
......@@ -253,6 +249,10 @@ const float* ITAStreamDetector::GetBlockPointer( unsigned int uiChannel, const I
{
const float* pfData = m_pDataSource->GetBlockPointer( uiChannel, pStreamInfo );
const bool bProfilerEnabled = GetProfilerEnabled();
if( bProfilerEnabled )
m_sw.start();
if( pfData && m_iMode != ITAStreamDetector::DEACTIVATED )
{
m_cs.enter();
......@@ -286,6 +286,9 @@ const float* ITAStreamDetector::GetBlockPointer( unsigned int uiChannel, const I
m_cs.leave();
}
if( bProfilerEnabled )
m_sw.stop();
return pfData;
}
......@@ -294,3 +297,41 @@ void ITAStreamDetector::IncrementBlockPointer()
m_iRMSBlocks++;
m_pDataSource->IncrementBlockPointer();
}
void ITAStreamDetector::SetProfilerEnabled( bool bEnabled )
{
m_bProfilerEnabled = bEnabled;
}
bool ITAStreamDetector::GetProfilerEnabled() const
{
return m_bProfilerEnabled;
}
double ITAStreamDetector::GetProfilerMeanCalculationTime( bool bReset )
{
double dResult = 0.0f;
if( GetProfilerEnabled() )
{
dResult = m_sw.mean();
if( bReset )
m_sw.reset();
}
return dResult;
}
std::string ITAStreamDetector::GetProfilerResult( bool bReset )
{
std::string sResult;
if( GetProfilerEnabled() )
{
sResult = m_sw.ToString();
if( bReset )
m_sw.reset();
}
return sResult;
}
......@@ -421,7 +421,8 @@ void ITAStreamPatchbay::HandlePreGetBlockPointer( ITADatasourceRealization*, uns
void ITAStreamPatchbay::HandlePostIncrementBlockPointer( ITADatasourceRealization* )
{
// Ignore, if already called for another output
if( !m_bProcessIncrement ) return;
if( !m_bProcessIncrement )
return;
// Turn data producion on again, when the first output's block pointer is incremented
m_bProcessData = true;
......@@ -432,9 +433,11 @@ void ITAStreamPatchbay::HandlePostIncrementBlockPointer( ITADatasourceRealizatio
// Build a unique list of sources
std::set<ITADatasource*> vSources;
for( int i = 0; i < GetNumInputs(); i++ ) {
for( int i = 0; i < GetNumInputs(); i++ )
{
ITADatasource* pdsInputSource = m_vpInputs[ i ]->pDatasource;
if( pdsInputSource ) vSources.insert( pdsInputSource );
if( pdsInputSource )
vSources.insert( pdsInputSource );
}
// Increment each data source only once
......