Aufgrund einer Störung des s3 Storage, könnten in nächster Zeit folgende GitLab Funktionen nicht zur Verfügung stehen: LFS, Container Registry, Job Artifacs, Uploads (Wiki, Bilder, Projekt-Exporte). Wir bitten um Verständnis. Es wird mit Hochdruck an der Behebung des Problems gearbeitet. Weitere Informationen zur Störung des Object Storage finden Sie hier: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/59-object-storage-pilot

Commit 73086c76 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Progress

parent 6ac2284e
......@@ -20,6 +20,7 @@
#define IW_ITA_BIQUAD
#include <ITADSPDefinitions.h>
#include <vector>
//! Implements digital biquad component for IIR filtering
/**
......@@ -33,28 +34,20 @@
class ITA_DSP_API CITABiquad
{
public:
// [stienen] Atomic? Lock? ... cpp Datei?
//! Parameter class for biquads / second-order sections
class ITA_DSP_API CParams
{
public:
float g; //!< Verstärkungsfaktor (Gain)
float a1; //!< Nenner-Koeffizient 1
float a2; //!< Nenner-Koeffizient 2
float b0; //!< Zähler-Koeffizient 0
float b1; //!< Zähler-Koeffizient 1
float b2; //!< Zähler-Koeffizient 2
float g; //!< Gain (ScaleVector)
float b0; //!< Denominator 1
float b1; //!< Denominator 2
float b2; //!< Denominator 3
float a0; //!< Numerator 1
float a1; //!< Numerator 2
float a2; //!< Numerator 3
CParams();
//! Parameter setzen
/**
* \param params Filterparameter/Koeffizienten, Reihenfolge: g, b0, b1, b2, a1, a2
*
* \note Reihenfolge der Parameter beachten
*/
void SetParameters( const float params[] );
} oParams;
//! Output write modes
......@@ -69,7 +62,7 @@ public:
virtual inline ~CITABiquad() {};
//! Clears all accumulators
void Clear();
void ClearAccumulators();
//! Filter samples, simple variant without any gain (factor)
/**
......@@ -114,7 +107,7 @@ public:
void Process( const float* pfInputData, float* pfOutputData, const int iNumSamples, const float fOutputGain1, const float fOutputGain2, const int iOutputMode );
private:
float vfAccumulators[ 2 ]; //!< Accumulators
std::vector< float > m_vfAccumulators; //!< Accumulators
};
#endif // IW_ITA_BIQUAD
function Hd = ita_dsp_third_octave_filterbank_iir_band_coefficients( Fs, Fc1, Fc2 )
%ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS Returns a discrete-time filter object.
% Fs Sampling Frequency
% Fc1 First Cutoff Frequency
% Fc2 Second Cutoff Frequency
N = 10; % Order
h = fdesign.bandpass('N,F3dB1,F3dB2', N, Fc1, Fc2, Fs);
Hd = design(h, 'butter');
function Hd = ita_dsp_third_octave_filterbank_iir_highpass_coefficients( Fs, Fc )
%ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS Returns a discrete-time filter object.
% Fs Sampling Frequency
% Fc Cutoff Frequency
N = 10; % Order
h = fdesign.highpass( 'N,F3dB', N, Fc, Fs );
Hd = design( h, 'butter' );
function Hd = ita_dsp_third_octave_filterbank_iir_lowpass_coefficients( Fs, Fc )
%ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS Returns a discrete-time filter object.
% Fs Sampling Frequency
% Fc Cutoff Frequency
N = 10; % Order
h = fdesign.lowpass( 'N,F3dB', N, Fc, Fs );
Hd = design( h, 'butter' );
......@@ -3,12 +3,13 @@
CITABiquad::CITABiquad()
{
Clear();
ClearAccumulators();
}
void CITABiquad::Clear()
void CITABiquad::ClearAccumulators()
{
vfAccumulators[ 0 ] = vfAccumulators[ 1 ] = 0;
m_vfAccumulators.push_back( 0.0f );
m_vfAccumulators.push_back( 0.0f );
}
void CITABiquad::Process( const float* pfInputData, float* pfOutputData, const int iNumSamples )
......@@ -16,8 +17,9 @@ void CITABiquad::Process( const float* pfInputData, float* pfOutputData, const i
// Local accumulators
float z0, z1, z2;
z1 = vfAccumulators[ 0 ];
z2 = vfAccumulators[ 1 ];
// Restore accumulators from last process call
z1 = m_vfAccumulators[ 0 ];
z2 = m_vfAccumulators[ 1 ];
for( int i = 0; i < iNumSamples; i++ )
{
......@@ -32,9 +34,9 @@ void CITABiquad::Process( const float* pfInputData, float* pfOutputData, const i
z1 = z0;
}
// Store accumulators
vfAccumulators[ 0 ] = z1;
vfAccumulators[ 1 ] = z2;
// Store accumulators for next process call
m_vfAccumulators[ 0 ] = z1;
m_vfAccumulators[ 1 ] = z2;
return;
}
......@@ -44,8 +46,8 @@ void CITABiquad::Process( const float* pfInputData, float* pfOutputData, const i
// Local accumulators
float z0, z1, z2;
z1 = vfAccumulators[ 0 ];
z2 = vfAccumulators[ 1 ];
z1 = m_vfAccumulators[ 0 ];
z2 = m_vfAccumulators[ 1 ];
if( iOutputMode == CITABiquad::OUTPUT_ADD )
{
......@@ -77,8 +79,8 @@ void CITABiquad::Process( const float* pfInputData, float* pfOutputData, const i
}
// Store accumulators
vfAccumulators[ 0 ] = z1;
vfAccumulators[ 1 ] = z2;
m_vfAccumulators[ 0 ] = z1;
m_vfAccumulators[ 1 ] = z2;
return;
}
......@@ -90,8 +92,8 @@ void CITABiquad::Process( const float* pfInputData, float* out, const int iNumSa
// Local accumulators
float z0, z1, z2;
z1 = vfAccumulators[ 0 ];
z2 = vfAccumulators[ 1 ];
z1 = m_vfAccumulators[ 0 ];
z2 = m_vfAccumulators[ 1 ];
// Factor for linear gain
const float fLinearGainFactor = ( fOutputGain2 - fOutputGain1 ) / float( iNumSamples );
......@@ -131,8 +133,8 @@ void CITABiquad::Process( const float* pfInputData, float* out, const int iNumSa
}
// Store accumulators
vfAccumulators[ 0 ] = z1;
vfAccumulators[ 1 ] = z2;
m_vfAccumulators[ 0 ] = z1;
m_vfAccumulators[ 1 ] = z2;
}
CITABiquad::CParams::CParams()
......@@ -144,13 +146,3 @@ CITABiquad::CParams::CParams()
, b2( 0 )
{
}
void CITABiquad::CParams::SetParameters( const float params[] )
{
g = params[ 0 ];
b0 = params[ 1 ];
b1 = params[ 2 ];
b2 = params[ 3 ];
a1 = params[ 4 ];
a2 = params[ 5 ];
}
......@@ -26,6 +26,9 @@
namespace ITADSPThirdOctaveFilterbankIIR
{
const int ITA_BIQUAD_FILTER_NUM_BANDS = 30;
const int ITA_BIQUAD_FILTER_NUM_BIQUADS_PER_BAND = 5; // num sections
const double dSamplingFrequency = 44100.00; // Hz
const int iOrdner = 10;
const int iNumFrequencies = 31;
......
#include <ITAThirdOctaveFilterbankIIR.h>
#include "ITAThirdOctaveFilterbankCoefficients.h"
//#include "ITAThirdOctaveFilterbankCoefficients.h"
#include "ITADSPThirdOctaveFilterbankIIRCoefficients.h"
#include <ITAFastMath.h>
#include <ITAStopWatch.h>
......@@ -10,20 +11,36 @@
#include <cassert>
CITAThirdOctaveFilterbankIIR::CITAThirdOctaveFilterbankIIR( const double dSampleRate, const int iBlockLength )
: m_dSampleRate( dSampleRate ),
m_iBlockLength( iBlockLength ),
m_nBandsInternal( ITA_BIQUAD_FILTER_NUM_BANDS ),
m_nBiquadsPerBand( ITA_BIQUAD_FILTER_NUM_BIQUADS_PER_BAND )
: m_dSampleRate( dSampleRate )
, m_iBlockLength( iBlockLength )
, m_nBandsInternal( int( ITADSPThirdOctaveFilterbankIIR::vfFrequencies.size() ) )
, m_nBiquadsPerBand( ITADSPThirdOctaveFilterbankIIR::ITA_BIQUAD_FILTER_NUM_BIQUADS_PER_BAND )
{
if( dSampleRate != ITA_BIQUAD_FILTER_SAMPLINGRATE )
if( dSampleRate != ITADSPThirdOctaveFilterbankIIR::dSamplingFrequency )
ITA_EXCEPT1( INVALID_PARAMETER, "Filterbank does not support this samplingrate" );
if( m_nBandsInternal != CITAThirdOctaveGainMagnitudeSpectrum::GetNumBands() )
ITA_EXCEPT1( INVALID_PARAMETER, "Filterbank does not match third octave band number" );
// Initialize biquads
int nBiquads = m_nBandsInternal * m_nBiquadsPerBand;
m_vBiquads.resize( nBiquads );
for( int i = 0; i < m_nBandsInternal; i++ )
for( int j = 0; j < m_nBiquadsPerBand; j++ )
m_vBiquads[ i * m_nBiquadsPerBand + j ].oParams.SetParameters( ITA_BIQUAD_FILTER_PARAMS[ i ][ j ] );
{
const std::vector< std::vector< float > >& vvfBandBiquads( ITADSPThirdOctaveFilterbankIIR::vvvfSOSMatrixCoefficients[ i ] );
for( int j = 0; j < vvfBandBiquads.size(); j++ )
{
const std::vector< float >& vfBiquad( vvfBandBiquads[ j ] );
CITABiquad& oBiquad( m_vBiquads[ i * m_nBiquadsPerBand + j ] );
oBiquad.oParams.g = vfBiquad[ 0 ];
oBiquad.oParams.a0 = vfBiquad[ 1 ];
oBiquad.oParams.a1 = vfBiquad[ 2 ];
oBiquad.oParams.a2 = vfBiquad[ 3 ];
oBiquad.oParams.b0 = vfBiquad[ 4 ];
oBiquad.oParams.b1 = vfBiquad[ 5 ];
oBiquad.oParams.b2 = vfBiquad[ 6 ];
}
}
m_sfTempFilterBuf.Init( m_iBlockLength, true );
m_pfTempOutputBuf.Init( m_iBlockLength, true );
......@@ -31,7 +48,7 @@ CITAThirdOctaveFilterbankIIR::CITAThirdOctaveFilterbankIIR( const double dSample
int CITAThirdOctaveFilterbankIIR::GetLatency() const
{
return 0; // @todo jst: really?
return 0;
}
void CITAThirdOctaveFilterbankIIR::SetMagnitudes( const CITAThirdOctaveGainMagnitudeSpectrum& oMagnitudes, const bool bSmoothChangeover )
......@@ -45,7 +62,7 @@ void CITAThirdOctaveFilterbankIIR::SetMagnitudes( const CITAThirdOctaveGainMagni
void CITAThirdOctaveFilterbankIIR::Clear()
{
for( size_t i = 0; i < m_vBiquads.size(); i++ )
m_vBiquads[ i ].Clear();
m_vBiquads[ i ].ClearAccumulators();
}
void CITAThirdOctaveFilterbankIIR::Process( const float* pfInputSamples, float* pfOutputSamples )
......@@ -58,7 +75,7 @@ void CITAThirdOctaveFilterbankIIR::Process( const float* pfInputSamples, float*
const int iMaxBand = m_nBandsInternal - 1;
const int iLastBandIndex = m_nBiquadsPerBand - 1;
// Empty queue and use latest magnitude update
CITAThirdOctaveFilterbankIIR::MagnitudeUpdate oLatestMagnitudeUpdate;
bool bUpdateGains = false;
......
......@@ -19,6 +19,16 @@ if( ITA_VISTA_BUILD_STATIC )
endif( )
add_executable( ITADSPBiquadTest ITADSPBiquadTest.cpp )
target_link_libraries( ITADSPBiquadTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( ITADSPBiquadTest )
vista_install( ITADSPBiquadTest )
vista_create_default_info_file( ITADSPBiquadTest )
set_property( TARGET ITADSPBiquadTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADSP" )
add_executable( ITADSPVariableDelayLineTest ITADSPVariableDelayLineTest.cpp )
target_link_libraries( ITADSPVariableDelayLineTest ${VISTA_USE_PACKAGE_LIBRARIES} )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment