Commits (1)
/*
* ----------------------------------------------------------------
*
* ITA core libs
* ITA acoustic visualization libs
* Licensed under Apache License, Version 2.0
*
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2016
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
......
/*
* ----------------------------------------------------------------
*
* ITA core libs
* ITA acoustic visualization libs
* Licensed under Apache License, Version 2.0
*
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2016
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
......@@ -41,39 +43,18 @@ public:
CITAQtWLevelMeter( QWidget* parent = Q_NULLPTR );
~CITAQtWLevelMeter();
void SetNumChannels( int iNumChannels );
void SetNumChannels( const int iNumChannels );
int GetNumChannels() const;
void SetPeak( int iChannel, float fFactor );
inline void SetPeaks( std::vector< float >& vfFactors )
{
if( int( vfFactors.size() ) != GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Given channel number does not match number of available channels" );
m_vfFactors = vfFactors;
UpdateLevels();
};
void SetRMS( int iChannel, float fRMS );
inline void SetRMSs( std::vector< float >& vfRMSs )
{
if( int( vfRMSs.size() ) != GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Given channel number does not match number of available channels" );
m_vfRMSs = vfRMSs;
UpdateLevels();
};
void SetSensitivity( int iChannel, float fSensitivity );
void SetSensitivities( std::vector< float >& vfSensitivity );
void SetPeak( const int iChannel, const float fFactor );
void SetPeaks( const std::vector< float >& vfFactors );
void SetRMS( const int iChannel, const float fRMS );
void SetRMSs( const std::vector< float >& vfRMSs );
void SetSensitivity( const int iChannel, const float fSensitivity );
void SetSensitivities( const std::vector< float >& vfSensitivity );
private:
std::vector< float > m_vfFactors; //!< Factors with level values (linear)
std::vector< float > m_vfPeaks; //!< Factors with level values (linear)
std::vector< float > m_vfRMSs; //!< Factors with root-mean-square (RMS) values (linear)
std::vector< float > m_vfSensitivities; //!< Sensitivities factor (linear)
std::vector< QGraphicsLineItem > m_voLines; //!< Graphics line items of levels
......
/*
* ----------------------------------------------------------------
*
* ITA acoustic visualization libs
* Licensed under Apache License, Version 2.0
*
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#include <ITAQtWLevelMeter.h>
#include <ITAException.h>
......@@ -20,12 +40,13 @@ CITAQtWLevelMeter::~CITAQtWLevelMeter()
}
void CITAQtWLevelMeter::SetNumChannels( int iNumChannels )
void CITAQtWLevelMeter::SetNumChannels( const int iNumChannels )
{
if( iNumChannels < 0 )
ITA_EXCEPT1( INVALID_PARAMETER, "CITAQtWLevelMeter: Negative channel number given" );
m_vfFactors.resize( iNumChannels );
m_vfPeaks.resize( iNumChannels );
m_vfRMSs.resize( iNumChannels );
m_vfSensitivities.resize( iNumChannels );
for( int i = 0; i < iNumChannels; i++ )
m_vfSensitivities[ i ] = 1.0f;
......@@ -33,52 +54,51 @@ void CITAQtWLevelMeter::SetNumChannels( int iNumChannels )
int CITAQtWLevelMeter::GetNumChannels() const
{
return int( m_vfFactors.size() );
return int( m_vfPeaks.size() );
}
void CITAQtWLevelMeter::SetPeak( int iChannel, float fFactor )
void CITAQtWLevelMeter::SetPeaks( const std::vector< float >& vfFactors )
{
if( iChannel > GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Given channel number exceeds number of available channels" );
if( int( vfFactors.size() ) != GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Given channel number does not match number of available channels" );
m_vfFactors[ iChannel - 1 ] = fFactor;
m_vfPeaks = vfFactors;
UpdateLevels();
}
};
void CITAQtWLevelMeter::SetRMS( int iChannel, float fRMS )
void CITAQtWLevelMeter::SetRMSs( const std::vector< float >& vfRMSs )
{
if( iChannel > GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Given channel number exceeds number of available channels" );
if( int( vfRMSs.size() ) != GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Given channel number does not match number of available channels" );
m_vfRMSs[ iChannel - 1 ] = fRMS;
m_vfRMSs = vfRMSs;
UpdateLevels();
}
};
/*
void CITAQtWLevelMeter::SetPeaks( std::vector< float >& vfFactors )
void CITAQtWLevelMeter::SetPeak( const int iChannel, const float fFactor )
{
if( int( vfFactors.size() ) != GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Given channel number does not match number of available channels" );
if( iChannel > GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Given channel number exceeds number of available channels" );
m_vfFactors = vfFactors;
m_vfPeaks[ iChannel - 1 ] = fFactor;
UpdateLevels();
UpdateLevels();
}
void CITAQtWLevelMeter::SetRMSs( std::vector< float >& vfRMSs )
void CITAQtWLevelMeter::SetRMS( const int iChannel, const float fRMS )
{
if( int( vfRMSs.size() ) != GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Given channel number does not match number of available channels" );
if( iChannel > GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Given channel number exceeds number of available channels" );
m_vfRMSs = vfRMSs;
m_vfRMSs[ iChannel - 1 ] = fRMS;
UpdateLevels();
}
*/
void CITAQtWLevelMeter::SetSensitivity( int iChannel, float fSensitivity )
void CITAQtWLevelMeter::SetSensitivity( const int iChannel, const float fSensitivity )
{
if( iChannel > GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Given channel number exceeds number of available channels" );
......@@ -88,7 +108,7 @@ void CITAQtWLevelMeter::SetSensitivity( int iChannel, float fSensitivity )
UpdateLevels();
}
void CITAQtWLevelMeter::SetSensitivities( std::vector<float>& vfSensitivities )
void CITAQtWLevelMeter::SetSensitivities( const std::vector< float >& vfSensitivities )
{
if( int( vfSensitivities.size() ) != GetNumChannels() )
ITA_EXCEPT1( INVALID_PARAMETER, "Given channel number does not match number of available channels" );
......@@ -103,8 +123,9 @@ void CITAQtWLevelMeter::UpdateLevels()
scene()->clear();
int iHeight = int( height() - 40 );
int iNumElements = int( m_vfFactors.size() );
int iNumElements = int( m_vfPeaks.size() );
assert( iNumElements == m_vfRMSs.size() );
assert( iNumElements == m_vfSensitivities.size() );
for( int i = 0; i < iNumElements; i++ )
{
......
/*
* ----------------------------------------------------------------
*
* ITA acoustic visualization libs
* Licensed under Apache License, Version 2.0
*
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#include "ITAQtWGraphicsViewTest.h"
CITAQtWGraphicsViewTest::CITAQtWGraphicsViewTest( QWidget* parent /* = 0 */ )
......
/*
* ----------------------------------------------------------------
*
* ITAMess measurement application
* Licensed under Apache License, Version 2.0
*
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_QT_WIDGETS_GRAPHICS_VIEW_TEST
#define IW_ITA_QT_WIDGETS_GRAPHICS_VIEW_TEST
......
/*
* ----------------------------------------------------------------
*
* ITA acoustic visualization libs
* Licensed under Apache License, Version 2.0
*
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#include "ITAQtWGraphicsViewTestWindow.h"
#include <ui_ITAQtWGraphicsViewTestWindow.h>
......
/*
* ----------------------------------------------------------------
*
* ITA acoustic visualization libs
* Licensed under Apache License, Version 2.0
*
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_QT_WIDGETS_GRAPHICS_VIEW_TEST_WINDOW
#define IW_ITA_QT_WIDGETS_GRAPHICS_VIEW_TEST_WINDOW
......
/*
* ----------------------------------------------------------------
*
* ITA acoustic visualization libs
* Licensed under Apache License, Version 2.0
*
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#include <QApplication>
#include <QMainWindow>
#include "ITAQtWGraphicsViewTestWindow.h"
......
/*
* ----------------------------------------------------------------
*
* ITA acoustic visualization libs
* Licensed under Apache License, Version 2.0
*
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#include <QApplication>
#include "ITAQtWLevelMeterTestWindow.h"
#include <ITAPortaudioInterface.h>
#include <ITAStreamFunctionGenerator.h>
#include <ITAPeakDetector.h>
#include <ITARMSDetector.h>
#include <ITAStreamDetector.h>
#include <ITAStreamProbe.h>
#include <ITAQtWLevelMeter.h>
......@@ -28,8 +47,7 @@ int main( int argc, char *argv[] )
ITAPA_IN.SetPlaybackEnabled( false );
ITAPA_IN.SetRecordEnabled( true );
ITAStreamProbe oRecordStreamProbe( ITAPA_IN.GetRecordDatasource(), "ITAQtWLevelMeterTest_Record.wav" );
ITAPeakDetector oRecordPeakDetector( &oRecordStreamProbe );
ITARMSDetector oRecordRMSDetector( &oRecordPeakDetector );
ITAStreamDetector oRecordDetector( &oRecordStreamProbe );
ITAPA_IN.Open();
ITAPA_IN.Start();
......@@ -45,13 +63,12 @@ int main( int argc, char *argv[] )
ITAStreamFunctionGenerator oPlayback( iNumOutputChannels, dSampleRate, iBlockLength, ITAStreamFunctionGenerator::SINE, 377.0f, 0.0f, true );
ITAStreamProbe oPlaybackStreamProbe( &oPlayback, "ITAQtWLevelMeterTest_Playback.wav" );
ITAPeakDetector oPlaybackPeakDetector( &oPlaybackStreamProbe );
ITARMSDetector oPlaybackRMSDetector( &oPlaybackPeakDetector );
ITAStreamDetector oPlaybackDetector( &oPlaybackStreamProbe );
// Start streaming
ITAPA_OUT.SetRecordEnabled( false );
ITAPA_OUT.SetPlaybackEnabled( true );
ITAPA_OUT.SetPlaybackDatasource( &oPlaybackRMSDetector );
ITAPA_OUT.SetPlaybackDatasource( &oPlaybackDetector );
ITAPA_OUT.Open();
ITAPA_OUT.Start();
......@@ -64,8 +81,7 @@ int main( int argc, char *argv[] )
a.setApplicationDisplayName( "ITAQtWidgets" );
CITAQtWLevelMeterTestWindow w;
w.SetPeakDetector( &oRecordPeakDetector );
w.SetRMSDetector( &oRecordRMSDetector );
w.SetStreamDetector( &oRecordDetector );
w.show();
int iRet = a.exec();
......
/*
* ----------------------------------------------------------------
*
* ITA acoustic visualization libs
* Licensed under Apache License, Version 2.0
*
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#include "ITAQtWLevelMeterTestWindow.h"
#include <ui_ITAQtWLevelMeterTestWindow.h>
#include <ITAPeakDetector.h>
#include <ITARMSDetector.h>
#include <ITAStreamDetector.h>
#include <ITAAudiofileCommon.h>
#include <ITAAudiofileWriter.h>
CITAQtWLevelMeterTestWindow::CITAQtWLevelMeterTestWindow( QWidget *parent )
: QMainWindow( parent )
, ui( new Ui::ITAQtWLevelMeterTestWindow )
, m_pPeakDetector( NULL )
, m_pRMSDetector( NULL )
, m_pDetector( NULL )
{
ui->setupUi( this );
......@@ -28,15 +46,15 @@ CITAQtWLevelMeterTestWindow::~CITAQtWLevelMeterTestWindow()
}
void CITAQtWLevelMeterTestWindow::SetPeakDetector( ITAPeakDetector* pDetector )
void CITAQtWLevelMeterTestWindow::SetStreamDetector( ITAStreamDetector* pDetector )
{
m_pPeakDetector = pDetector;
m_pDetector = pDetector;
if( !pDetector )
return;
double dBlockTime = double( pDetector->GetBlocklength() ) / pDetector->GetSampleRate(); // Seconds
if( pDetector && !m_pRMSDetector )
if( pDetector )
ui->graphicsView_LevelMeter->SetNumChannels( pDetector->GetNumberOfChannels() );
if( !m_qAudioProcessTimer.isActive() )
......@@ -52,73 +70,32 @@ void CITAQtWLevelMeterTestWindow::SetPeakDetector( ITAPeakDetector* pDetector )
}
}
void CITAQtWLevelMeterTestWindow::SetRMSDetector( ITARMSDetector* pDetector )
{
m_pRMSDetector = pDetector;
if( !pDetector )
return;
if( pDetector && !m_pPeakDetector )
ui->graphicsView_LevelMeter->SetNumChannels( pDetector->GetNumberOfChannels() );
double dBlockTime = double( pDetector->GetBlocklength() ) / pDetector->GetSampleRate(); // Seconds
if( !m_qAudioProcessTimer.isActive() )
{
m_qAudioProcessTimer.setInterval( int( dBlockTime * 1000.0f ) ); // Milliseconds
m_qAudioProcessTimer.start();
}
if( !m_qRenderTimer.isActive() )
{
m_qRenderTimer.setInterval( 1000 / 25 ); // 25 Hz
m_qRenderTimer.start();
}
}
void CITAQtWLevelMeterTestWindow::Render()
{
CITAQtWLevelMeter* pLM = ui->graphicsView_LevelMeter;
if( m_pRMSDetector )
if( m_pDetector )
{
m_pRMSDetector->GetRMSs( m_vfRMSs );
pLM->SetRMSs( m_vfRMSs );
}
if( m_pPeakDetector )
{
m_pPeakDetector->GetPeaks( m_vfPeaks );
m_pDetector->GetPeaks( m_vfPeaks, false );
pLM->SetPeaks( m_vfPeaks );
m_pDetector->GetRMSs( m_vfRMSs, true );
pLM->SetRMSs( m_vfRMSs );
}
}
void CITAQtWLevelMeterTestWindow::ProcessAudioStream()
{
if( !m_pPeakDetector && !m_pRMSDetector )
if( !m_pDetector )
return;
if( m_pPeakDetector )
for( int i = 0; i < int( m_pDetector->GetNumberOfChannels() ); i++ )
{
for( int i = 0; i < int( m_pPeakDetector->GetNumberOfChannels() ); i++ )
{
const float* pfData = m_pPeakDetector->GetBlockPointer( i, &m_siState );
}
m_pPeakDetector->IncrementBlockPointer();
const float* pfData = m_pDetector->GetBlockPointer( i, &m_siState );
}
if( m_pRMSDetector )
{
for( int i = 0; i < int( m_pRMSDetector->GetNumberOfChannels() ); i++ )
{
const float* pfData = m_pRMSDetector->GetBlockPointer( i, &m_siState );
}
m_pRMSDetector->IncrementBlockPointer();
}
m_pDetector->IncrementBlockPointer();
m_siState.nSamples += m_pPeakDetector->GetBlocklength();
m_siState.nSamples += m_pDetector->GetBlocklength();
m_siState.dStreamTimeCode += m_qAudioProcessTimer.interval() / 1000.0f; // Milliseconds
}
......
/*
* ----------------------------------------------------------------
*
* ITA acoustic visualization libs
* Licensed under Apache License, Version 2.0
*
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_QT_WIDGETS_LEVEL_METER_TEST_WINDOW
#define IW_ITA_QT_WIDGETS_LEVEL_METER_TEST_WINDOW
......@@ -8,8 +28,7 @@
#include <ITAStreamInfo.h>
class ITAPeakDetector;
class ITARMSDetector;
class ITAStreamDetector;
namespace Ui
{
......@@ -23,8 +42,7 @@ class CITAQtWLevelMeterTestWindow : public QMainWindow
public:
explicit CITAQtWLevelMeterTestWindow( QWidget *parent = 0 );
~CITAQtWLevelMeterTestWindow();
void SetPeakDetector( ITAPeakDetector* );
void SetRMSDetector( ITARMSDetector* );
void SetStreamDetector( ITAStreamDetector* );
private slots:
void Render();
......@@ -33,8 +51,7 @@ private slots:
private:
Ui::ITAQtWLevelMeterTestWindow* ui;
ITAPeakDetector* m_pPeakDetector;
ITARMSDetector* m_pRMSDetector;
ITAStreamDetector* m_pDetector;
QTimer m_qRenderTimer, m_qAudioProcessTimer;
std::vector< float > m_vfPeaks;
std::vector< float > m_vfRMSs;
......
/*
* ----------------------------------------------------------------
*
* ITA acoustic visualization libs
* Licensed under Apache License, Version 2.0
*
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#include <QApplication>
#include <QMainWindow>
#include "ITAQtWTestWindow.h"
......
/*
* ----------------------------------------------------------------
*
* ITA acoustic visualization libs
* Licensed under Apache License, Version 2.0
*
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_QT_WIDGETS_TEST_WINDOW
#define IW_ITA_QT_WIDGETS_TEST_WINDOW
......