Commits (8)
......@@ -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
......@@ -62,7 +62,7 @@ public:
void SetDumpFilename( const std::string& sFilename );
// Filter erzeugen
void GenerateFilter( const CITAThirdOctaveMagnitudeSpectrum& oTOMagnitudes, float* pfFilterCoeffs );
void GenerateFilter( const CITAThirdOctaveGainMagnitudeSpectrum& oTOMagnitudes, float* pfFilterCoeffs );
private:
double m_dSamplerate; // Abtastrate der Ausgabefilter [Hz]
......
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
### stub code ###
%% Settings
Fs = 44100;
N = 10;
freqs = ita_ANSI_center_frequencies;
%% Export to C/C++ header using std::vector
target_file = 'ITADSPThirdOctaveFilterbankIIRCoefficients.h';
proto_file = 'ITADSPThirdOctaveFilterbankCoefficients.proto.h';
copyfile( proto_file, target_file );
fd = fopen( target_file, 'r' );
stub_cpp_file_body = textscan( fd, '%s', 'delimiter', '\n' );
fclose( fd );
fd = fopen( target_file, 'wt' );
for i=1:size( stub_cpp_file_body{ 1 } , 1 )
if strcmp( '### stub code ###', stub_cpp_file_body{ 1 }{ i } )
break;
end
fprintf( fd, '%s\n', stub_cpp_file_body{ 1 }{ i } );
end
fprintf( fd, '/* This file has been generated by the ita_dsp_design_filsters.m Matlab script */\n\n' );
fprintf( fd, '#ifndef IW_ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS\n' );
fprintf( fd, '#define IW_ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS\n\n' );
fprintf( fd, '#include <vector>\n\n' );
fprintf( fd, 'namespace ITADSPThirdOctaveFilterbankIIR\n{\n\n' );
fprintf( fd, 'const double dSamplingFrequency = %0.2f; // Hz\n', Fs );
fprintf( fd, 'const int iOrdner = %d;\n', N );
fprintf( fd, 'const int iNumFrequencies = %d;\n', numel( freqs ) );
fprintf( fd, 'const std::vector< float > vfFrequencies =\n{\n' );
for l=1:numel( freqs )
fprintf( fd, '%.1ff, // Hz\n', freqs( l ) );
end
fprintf( fd, '};\n' );
fprintf( fd, '\n' );
%% Filter design
fprintf( fd, '// 3-dim vector access: FrequencyBand ; Biquad ; Param = { ScaleValue [1], sosMatrix [2-6] }\n' );
fprintf( fd, 'const std::vector< std::vector< std::vector< float > > > vvvfSOSMatrixCoefficients = \n{\n\n' );
% Lowpass
h = fdesign.lowpass( 'N,F3dB', N, freqs( 1 ), Fs );
Hd = design( h, 'butter' );
fprintf( fd, '{\n' );
fprintf( fd, '// Band %.1f Hz sos matrix\n', freqs( 1 ) );
for k=1:size( Hd.sosMatrix, 1 )
fprintf( fd, '{ %.6ff, ', Hd.ScaleValues( k ) );
for l=1:size( Hd.sosMatrix, 2 )
fprintf( fd, '%.6ff, ', Hd.sosMatrix( k, l ) );
end
fprintf( fd, '},\n' );
end
fprintf( fd, '},\n\n' );
% Bandpasses
for n = 2:( numel( freqs ) - 1 )
h = fdesign.bandpass( 'N,F3dB1,F3dB2', N, freqs( n - 1 ), freqs( n + 1 ), Fs );
Hd = design( h, 'butter' );
fprintf( fd, '{\n' );
fprintf( fd, '// Band %.1f Hz sos matrix\n', freqs( n ) );
for k=1:size( Hd.sosMatrix, 1 )
fprintf( fd, '{ %.6ff, ', Hd.ScaleValues( k ) );
for l=1:size( Hd.sosMatrix, 2 )
fprintf( fd, '%.6ff, ', Hd.sosMatrix( k, l ) );
end
fprintf( fd, '},\n' );
end
fprintf( fd, '},\n\n' );
end
% Highpass
h = fdesign.highpass( 'N,F3dB', N, freqs( end ), Fs );
Hd = design( h, 'butter' );
fprintf( fd, '{\n' );
fprintf( fd, '// Band %.1f Hz sos matrix\n', freqs( end ) );
for k=1:size( Hd.sosMatrix, 1 )
fprintf( fd, '{ %.6ff, ', Hd.ScaleValues( k ) );
for l=1:size( Hd.sosMatrix, 2 )
fprintf( fd, '%.6ff, ', Hd.sosMatrix( k, l ) );
end
fprintf( fd, '},\n' );
end
fprintf( fd, '},\n\n' );
fprintf( fd, '};\n\n' );
fprintf( fd, '} // namespace\n\n' );
fprintf( fd, '#endif // IW_ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS\n' );
%% Finish
for ii=(i+1):size( stub_cpp_file_body{ 1 } , 1 )
fprintf( fd, '%s\n', stub_cpp_file_body{ 1 }{ ii } );
end
fclose( fd );
function Hd = ita_dsp_third_octave_filterbank_fir_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
d = fdesign.bandpass( 'Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2', 1/4, 3/8, 5/8, 6/8, 60, 1, 60, Fs );
Hd = design(d,'equiripple');
......@@ -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 ];
}
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
/* This file has been generated by the ita_dsp_design_filsters.m Matlab script */
#ifndef IW_ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS
#define IW_ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS
#include <vector>
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;
const std::vector< float > vfFrequencies =
{
20.0f, // Hz
25.0f, // Hz
31.5f, // Hz
40.0f, // Hz
50.0f, // Hz
62.5f, // Hz
80.0f, // Hz
100.0f, // Hz
125.0f, // Hz
155.0f, // Hz
200.0f, // Hz
250.0f, // Hz
315.0f, // Hz
400.0f, // Hz
500.0f, // Hz
630.0f, // Hz
800.0f, // Hz
1000.0f, // Hz
1250.0f, // Hz
1600.0f, // Hz
2000.0f, // Hz
2500.0f, // Hz
3150.0f, // Hz
4000.0f, // Hz
5000.0f, // Hz
6350.0f, // Hz
8000.0f, // Hz
10000.0f, // Hz
12500.0f, // Hz
16000.0f, // Hz
20000.0f, // Hz
};
// 3-dim vector access: FrequencyBand ; Biquad ; Param = { ScaleValue [1], sosMatrix [2-6] }
const std::vector< std::vector< std::vector< float > > > vvvfSOSMatrixCoefficients =
{
{
// Band 20.0 Hz sos matrix
{ 0.000002f, 1.000000f, 2.000000f, 1.000000f, 1.000000f, -1.999101f, 0.999109f, },
{ 0.000002f, 1.000000f, 2.000000f, 1.000000f, 1.000000f, -1.997408f, 0.997416f, },
{ 0.000002f, 1.000000f, 2.000000f, 1.000000f, 1.000000f, -1.995970f, 0.995978f, },
{ 0.000002f, 1.000000f, 2.000000f, 1.000000f, 1.000000f, -1.994927f, 0.994935f, },
{ 0.000002f, 1.000000f, 2.000000f, 1.000000f, 1.000000f, -1.994379f, 0.994387f, },
},
{
// Band 25.0 Hz sos matrix
{ 0.000819f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.999366f, 0.999386f, },
{ 0.000819f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.999594f, 0.999602f, },
{ 0.000819f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.998479f, 0.998496f, },
{ 0.000819f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.998845f, 0.998855f, },
{ 0.000819f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.998350f, 0.998363f, },
},
{
// Band 31.5 Hz sos matrix
{ 0.001068f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.999162f, 0.999194f, },
{ 0.001068f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.999472f, 0.999485f, },
{ 0.001068f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.998003f, 0.998030f, },
{ 0.001068f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.998500f, 0.998515f, },
{ 0.001067f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.997845f, 0.997865f, },
},
{
// Band 40.0 Hz sos matrix
{ 0.001317f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.998960f, 0.999009f, },
{ 0.001317f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.999342f, 0.999362f, },
{ 0.001316f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.997534f, 0.997576f, },
{ 0.001316f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.998140f, 0.998164f, },
{ 0.001316f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.997336f, 0.997368f, },
},
{
// Band 50.0 Hz sos matrix
{ 0.001602f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.998725f, 0.998802f, },
{ 0.001602f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.999184f, 0.999217f, },
{ 0.001601f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.996999f, 0.997065f, },
{ 0.001601f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.997716f, 0.997755f, },
{ 0.001600f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.996749f, 0.996799f, },
},
{
// Band 62.5 Hz sos matrix
{ 0.002136f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.998262f, 0.998389f, },
{ 0.002136f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.998919f, 0.998971f, },
{ 0.002133f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.995956f, 0.996064f, },
{ 0.002133f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.996971f, 0.997033f, },
{ 0.002133f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.995654f, 0.995735f, },
},
{
// Band 80.0 Hz sos matrix
{ 0.002669f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.997788f, 0.997987f, },
{ 0.002669f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.998633f, 0.998714f, },
{ 0.002666f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.994914f, 0.995082f, },
{ 0.002666f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.996197f, 0.996292f, },
{ 0.002664f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.994545f, 0.994671f, },
},
{
// Band 100.0 Hz sos matrix
{ 0.003203f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.997296f, 0.997606f, },
{ 0.003203f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.998303f, 0.998435f, },
{ 0.003197f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.993874f, 0.994139f, },
{ 0.003197f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.995359f, 0.995514f, },
{ 0.003195f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.993407f, 0.993609f, },
},
{
// Band 125.0 Hz sos matrix
{ 0.003913f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.996607f, 0.997084f, },
{ 0.003913f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.997872f, 0.998079f, },
{ 0.003906f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.992449f, 0.992857f, },
{ 0.003906f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.994263f, 0.994505f, },
{ 0.003903f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.991881f, 0.992194f, },
},
{
// Band 155.0 Hz sos matrix
{ 0.005334f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.995185f, 0.995978f, },
{ 0.005334f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.997106f, 0.997430f, },
{ 0.005320f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.989518f, 0.990188f, },
{ 0.005320f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.992217f, 0.992598f, },
{ 0.005315f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.988866f, 0.989371f, },
},
{
// Band 200.0 Hz sos matrix
{ 0.006753f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.993655f, 0.994893f, },
{ 0.006753f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.996263f, 0.996760f, },
{ 0.006731f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.986519f, 0.987561f, },
{ 0.006731f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.990073f, 0.990660f, },
{ 0.006722f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.985774f, 0.986556f, },
},
{
// Band 250.0 Hz sos matrix
{ 0.008172f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.991910f, 0.993876f, },
{ 0.008172f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.995197f, 0.996025f, },
{ 0.008139f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.983391f, 0.985059f, },
{ 0.008139f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.987640f, 0.988608f, },
{ 0.008126f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.982480f, 0.983748f, },
},
{
// Band 315.0 Hz sos matrix
{ 0.010650f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.988808f, 0.991973f, },
{ 0.010650f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.993572f, 0.994865f, },
{ 0.010594f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.977807f, 0.980474f, },
{ 0.010594f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.983731f, 0.985249f, },
{ 0.010573f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.976846f, 0.978854f, },
},
{
// Band 400.0 Hz sos matrix
{ 0.013125f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.985198f, 0.990140f, },
{ 0.013125f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.991590f, 0.993641f, },
{ 0.013040f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.971855f, 0.976025f, },
{ 0.013040f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.979387f, 0.981786f, },
{ 0.013008f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.970828f, 0.973983f, },
},
{
// Band 500.0 Hz sos matrix
{ 0.016302f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.979956f, 0.987794f, },
{ 0.016302f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.988761f, 0.992063f, },
{ 0.016171f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.963724f, 0.970344f, },
{ 0.016171f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.973493f, 0.977341f, },
{ 0.016122f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.962725f, 0.967756f, },
},
{
// Band 630.0 Hz sos matrix
{ 0.021230f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.971419f, 0.984019f, },
{ 0.021230f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.984596f, 0.989753f, },
{ 0.021010f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.950775f, 0.961335f, },
{ 0.021010f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.964679f, 0.970705f, },
{ 0.020927f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.950200f, 0.958145f, },
},
{
// Band 800.0 Hz sos matrix
{ 0.026143f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.960746f, 0.980393f, },
{ 0.026143f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.979143f, 0.987315f, },
{ 0.025811f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.936168f, 0.952635f, },
{ 0.025811f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.954380f, 0.963883f, },
{ 0.025687f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.936176f, 0.948626f, },
},
{
// Band 1000.0 Hz sos matrix
{ 0.031739f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.945730f, 0.976358f, },
{ 0.031739f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.971302f, 0.984446f, },
{ 0.031252f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.917207f, 0.942941f, },
{ 0.031252f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.940822f, 0.955989f, },
{ 0.031072f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.918215f, 0.937857f, },
},
{
// Band 1250.0 Hz sos matrix
{ 0.042177f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.918513f, 0.968362f, },
{ 0.042177f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.959086f, 0.979580f, },
{ 0.041326f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.882866f, 0.924209f, },
{ 0.041326f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.918462f, 0.942185f, },
{ 0.041015f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.886889f, 0.917971f, },
},
{
// Band 1600.0 Hz sos matrix
{ 0.052544f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.883270f, 0.960674f, },
{ 0.052544f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.942602f, 0.974511f, },
{ 0.051238f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.842334f, 0.906218f, },
{ 0.051238f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.891421f, 0.928185f, },
{ 0.050764f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.850457f, 0.898471f, },
},
{
// Band 2000.0 Hz sos matrix
{ 0.062841f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.833339f, 0.953510f, },
{ 0.062841f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.917025f, 0.969022f, },
{ 0.060993f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.789784f, 0.889300f, },
{ 0.060993f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.854477f, 0.913628f, },
{ 0.060329f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.803454f, 0.879342f, },
},
{
// Band 2500.0 Hz sos matrix
{ 0.079844f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.752679f, 0.941055f, },
{ 0.079844f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.879925f, 0.960653f, },
{ 0.076914f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.706218f, 0.860665f, },
{ 0.076914f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.799621f, 0.890988f, },
{ 0.075877f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.731055f, 0.848245f, },
},
{
// Band 3150.0 Hz sos matrix
{ 0.103322f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.626000f, 0.923923f, },
{ 0.103322f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.824196f, 0.949195f, },
{ 0.098535f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.581184f, 0.821887f, },
{ 0.098535f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.719613f, 0.860324f, },
{ 0.096874f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.625316f, 0.806252f, },
},
{
// Band 4000.0 Hz sos matrix
{ 0.126418f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.453124f, 0.908199f, },
{ 0.126418f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.741078f, 0.936993f, },
{ 0.119424f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.420470f, 0.786153f, },
{ 0.119424f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.611560f, 0.829135f, },
{ 0.117043f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.489466f, 0.765913f, },
},
{
// Band 5000.0 Hz sos matrix
{ 0.158763f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.179163f, 0.886868f, },
{ 0.158763f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.609822f, 0.919682f, },
{ 0.148101f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.447005f, 0.785879f, },
{ 0.148101f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.174879f, 0.737998f, },
{ 0.144561f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.284482f, 0.710877f, },
},
{
// Band 6350.0 Hz sos matrix
{ 0.199686f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -0.796288f, 0.861586f, },
{ 0.199686f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.425777f, 0.897063f, },
{ 0.183536f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.224617f, 0.731209f, },
{ 0.183536f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -0.843451f, 0.680681f, },
{ 0.178326f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.010579f, 0.643348f, },
},
{
// Band 8000.0 Hz sos matrix
{ 0.239376f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -0.290944f, 0.842143f, },
{ 0.239376f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -1.141474f, 0.871316f, },
{ 0.217132f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -0.909951f, 0.673736f, },
{ 0.217132f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -0.413487f, 0.633071f, },
{ 0.210136f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -0.645680f, 0.579727f, },
},
{
// Band 10000.0 Hz sos matrix
{ 0.289489f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, 0.355865f, 0.823971f, },
{ 0.289489f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -0.745157f, 0.834995f, },
{ 0.258678f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -0.492985f, 0.597368f, },
{ 0.258678f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, 0.135349f, 0.582248f, },
{ 0.249262f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -0.174336f, 0.501476f, },
},
{
// Band 12500.0 Hz sos matrix
{ 0.373293f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, 1.161744f, 0.813023f, },
{ 0.373293f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, -0.226640f, 0.764884f, },
{ 0.326657f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, 0.834287f, 0.526520f, },
{ 0.326657f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, 0.024728f, 0.459508f, },
{ 0.312956f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, 0.419294f, 0.374088f, },
},
{
// Band 16000.0 Hz sos matrix
{ 0.451712f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, 0.372812f, 0.651489f, },
{ 0.451712f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, 1.798158f, 0.880660f, },
{ 0.389515f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, 1.547760f, 0.646690f, },
{ 0.389515f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, 0.470276f, 0.263182f, },
{ 0.371736f, 1.000000f, 0.000000f, -1.000000f, 1.000000f, 0.989237f, 0.256529f, },
},
{
// Band 20000.0 Hz sos matrix
{ 0.020263f, 1.000000f, -2.000000f, 1.000000f, 1.000000f, 1.832743f, 0.913795f, },
{ 0.018728f, 1.000000f, -2.000000f, 1.000000f, 1.000000f, 1.693870f, 0.768781f, },
{ 0.017594f, 1.000000f, -2.000000f, 1.000000f, 1.000000f, 1.591300f, 0.661675f, },
{ 0.016852f, 1.000000f, -2.000000f, 1.000000f, 1.000000f, 1.524242f, 0.591651f, },
{ 0.016487f, 1.000000f, -2.000000f, 1.000000f, 1.000000f, 1.491205f, 0.557153f, },
},
};
} // namespace
#endif // IW_ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_COEFFICIENTS
......@@ -78,18 +78,18 @@ void CITAThirdOctaveFIRFilterGenerator::SetDumpFilename( const std::string& sFil
m_sDumpFilename = sFilename;
}
void CITAThirdOctaveFIRFilterGenerator::GenerateFilter( const CITAThirdOctaveMagnitudeSpectrum& oTOMagnitudes, float* pfFilterCoeffs )
void CITAThirdOctaveFIRFilterGenerator::GenerateFilter( const CITAThirdOctaveGainMagnitudeSpectrum& oTOGainMagnitudes, float* pfFilterCoeffs )
{
m_sw.start();
if( oTOMagnitudes.IsZero() )
if( oTOGainMagnitudes.IsZero() )
{
for( int i = 0; i < m_iFilterLength; i++ )
pfFilterCoeffs[ i ] = 0.0f;
return;
}
if( oTOMagnitudes.IsIdentity() )
if( oTOGainMagnitudes.IsIdentity() )
{
for( int i = 0; i < m_iFilterLength; i++ )
pfFilterCoeffs[ i ] = 0.0f;
......@@ -101,7 +101,7 @@ void CITAThirdOctaveFIRFilterGenerator::GenerateFilter( const CITAThirdOctaveMag
m_pfInputData[ 0 ] = 1.0f;
for( int i = 0; i < CITAThirdOctaveMagnitudeSpectrum::GetNumBands(); i++ )
m_pfInputData[ 1 + i ] = float( db10_to_ratio( oTOMagnitudes[ i ] ) );
m_pfInputData[ 1 + i ] = float( oTOGainMagnitudes[ i ] );
m_pfInputData[ m_iInputFreqs - 1 ] = 0.0f; // @todo jst: check if this is good
// Initialize cubic spline interpolation
......
#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} )
......
#include <ITAThirdOctaveFIRFilterGenerator.h>
#include <ITAThirdOctaveFilterbank.h>
#include <ITAAudiofileWriter.h>
#include <ITAStringUtils.h>
#include <ITAStopWatch.h>
#include <ITASampleBuffer.h>
#include <ITASampleFrame.h>
#include <iostream>
using namespace std;
const double g_dSampleRate = 44100;
//const int g_iFilterLength = int( ceil( g_dSampleRate / CITAThirdOctaveMagnitudeSpectrum::GetCenterFrequencies()[ 0 ] ) );
const int g_iFilterLength = int( 10 * ceil( g_dSampleRate / CITAThirdOctaveMagnitudeSpectrum::GetCenterFrequencies()[ 0 ] ) );
void TestThirdOctaveFilterGeneratorFIRIdentity();
void TestThirdOctaveFilterGeneratorFIRZero();
void TestThirdOctaveFilterGeneratorFIRSingleBands();
int main( int, char** )
{
TestThirdOctaveFilterGeneratorFIRIdentity();
TestThirdOctaveFilterGeneratorFIRZero();
TestThirdOctaveFilterGeneratorFIRSingleBands();
return 255;
}
void TestThirdOctaveFilterGeneratorFIRIdentity()
{
CITAThirdOctaveGainMagnitudeSpectrum oMags;
oMags.SetIdentity();
ITASampleBuffer oFilter( g_iFilterLength );
CITAThirdOctaveFIRFilterGenerator oFilterGenerator( g_dSampleRate, g_iFilterLength );
oFilterGenerator.GenerateFilter( oMags, oFilter.GetData() );
string sFilePath = "ITADSPThirdOctaveFilterGeneratorTest_Identity_FIR.wav";
writeAudiofile( sFilePath, &oFilter, g_dSampleRate );
cout << "Exported result to " << sFilePath << endl;
}
void TestThirdOctaveFilterGeneratorFIRZero()
{
CITAThirdOctaveGainMagnitudeSpectrum oMags;
oMags.SetZero();
ITASampleBuffer oFilter( g_iFilterLength );
CITAThirdOctaveFIRFilterGenerator oFilterGenerator( g_dSampleRate, g_iFilterLength );
oFilterGenerator.GenerateFilter( oMags, oFilter.GetData() );
string sFilePath = "ITADSPThirdOctaveFilterGeneratorTest_Zero_FIR.wav";
writeAudiofile( sFilePath, &oFilter, g_dSampleRate );
cout << "Exported result to " << sFilePath << endl;
}
void TestThirdOctaveFilterGeneratorFIRSingleBands()
{
ITASampleFrame oFilter( CITAThirdOctaveMagnitudeSpectrum::GetNumBands(), g_iFilterLength, true );
CITAThirdOctaveFIRFilterGenerator oFilterGenerator( g_dSampleRate, g_iFilterLength );
CITAThirdOctaveGainMagnitudeSpectrum oMags;
for( int i = 0; i < CITAThirdOctaveMagnitudeSpectrum::GetNumBands(); i++ )
{
oMags.SetZero();
oMags[ i ] = 1.0f;
oFilterGenerator.GenerateFilter( oMags, oFilter[ i ].GetData() );
}
string sFilePath = "ITADSPThirdOctaveFilterGeneratorTest_SingleBands_FIR.wav";
writeAudiofile( sFilePath, &oFilter, g_dSampleRate );
cout << "Exported result to " << sFilePath << endl;
}
......@@ -67,7 +67,7 @@ void TestThirdOctaveFilterGeneratorFIRSingleBands()
for( int i = 0; i < CITAThirdOctaveMagnitudeSpectrum::GetNumBands(); i++ )
{
oMags.SetZero();
oMags[ i ] = 0.0f; // dB
oMags[ i ] = 1.0f;
oFilterGenerator.GenerateFilter( oMags, oFilter[ i ].GetData() );
}
......
......@@ -14,3 +14,4 @@ ITADSPThirdOctaveFilterGeneratorTest_Identity_FIR.channelNames = { 'Identity' };
ITADSPThirdOctaveFilterGeneratorTest_Identity_FIR.pf
ITADSPThirdOctaveFilterGeneratorTest_SingleBands_FIR.pf
......@@ -12,7 +12,7 @@ const double g_dSampleRate = 44100;
const int g_iFilterLength = 512;
void TestThirdOctaveFilterbankIIR();
void TestThirdOctaveFilterbankFIR() {};
void TestThirdOctaveFilterbankFIR();
int main( int, char** )
{
......@@ -47,10 +47,10 @@ void TestThirdOctaveFilterbankIIR()
y.Zero();
pIIRFilterbank->Clear();
oMags.SetZero();
pIIRFilterbank->SetMagnitudes( oMags, false );
sw.start();
pIIRFilterbank->Process( x.GetData(), y.GetData() );
sw.stop();
......@@ -81,3 +81,64 @@ void TestThirdOctaveFilterbankIIR()
delete pIIRFilterbank;
}
void TestThirdOctaveFilterbankFIR()
{
const int iSampleLength = ( 1 << 17 );
CITAThirdOctaveFilterbank* pIIRFilterbank = CITAThirdOctaveFilterbank::Create( g_dSampleRate, iSampleLength, CITAThirdOctaveFilterbank::FIR_SPLINE_LINEAR_PHASE );
ITASampleBuffer x( iSampleLength );
x[ 0 ] = 1.0f;
CITAThirdOctaveGainMagnitudeSpectrum oMags;
oMags.SetIdentity();
pIIRFilterbank->SetMagnitudes( oMags, false );
ITASampleBuffer y( iSampleLength );
ITAStopWatch sw;
sw.start();
pIIRFilterbank->Process( x.GetData(), y.GetData() );
sw.stop();
cout << "Runtime identity magnitudes:" << sw.ToString() << endl;
y.Normalize();
writeAudiofile( "ITADSPThirdOctaveFilterbankTest_FIR_Identity.wav", &y, g_dSampleRate );
y.Zero();
pIIRFilterbank->Clear();
oMags.SetZero();
pIIRFilterbank->SetMagnitudes( oMags, false );
sw.start();
pIIRFilterbank->Process( x.GetData(), y.GetData() );
sw.stop();
cout << "Runtime zero magnitude:" << sw.ToString() << endl;
y.Normalize();
writeAudiofile( "ITADSPThirdOctaveFilterbankTest_FIR_Zeros.wav", &y, g_dSampleRate );
pIIRFilterbank->Clear();
// dB values
oMags[ 3 ] = 3.0f;
oMags[ 10 ] = -3.0f;
oMags[ 11 ] = -6.0f;
oMags[ 12 ] = -9.0f;
oMags[ 13 ] = -9.0f;
oMags[ 14 ] = -7.0f;
pIIRFilterbank->SetMagnitudes( oMags );
sw.start();
pIIRFilterbank->Process( x.GetData(), y.GetData() );
sw.stop();
cout << "Runtime real magnitudes:" << sw.ToString() << endl;
y.Normalize();
writeAudiofile( "ITADSPThirdOctaveFilterbankTest_FIR_SomeBands.wav", &y, g_dSampleRate );
delete pIIRFilterbank;
}
......@@ -16,28 +16,28 @@ test_iir_ident2.play
iir_zeros = ita_read( 'ITADSPThirdOctaveFilterbankTest_IIR_Zeros.wav' );
iir_zeros.channelNames = { 'Zeros' };
iir_zeros.pf
fdatool
SOS =
1.0000 0 -1.0000 1.0000 0.2606 0.8247
1.0000 0 -1.0000 1.0000 -0.8148 0.8398
1.0000 0 -1.0000 1.0000 -0.5621 0.6067
1.0000 0 -1.0000 1.0000 0.0527 0.5859
1.0000 0 -1.0000 1.0000 -0.2483 0.5095
G
G =
0.2843
0.2843
0.2544
0.2544
0.2452
1.0000
%
% fdatool
%
% SOS =
%
% 1.0000 0 -1.0000 1.0000 0.2606 0.8247
% 1.0000 0 -1.0000 1.0000 -0.8148 0.8398
% 1.0000 0 -1.0000 1.0000 -0.5621 0.6067
% 1.0000 0 -1.0000 1.0000 0.0527 0.5859
% 1.0000 0 -1.0000 1.0000 -0.2483 0.5095
%
% G
%
% G =
%
% 0.2843
% 0.2843
% 0.2544
% 0.2544
% 0.2452
% 1.0000
%
ITADSPThirdOctaveFilterbankTest_IIR_Zeros = ita_read( 'ITADSPThirdOctaveFilterbankTest_IIR_Zeros.wav' );
......@@ -48,3 +48,21 @@ ITADSPThirdOctaveFilterbankTest_IIR_Zeros.channelNames = { 'Zero' };
ITADSPThirdOctaveFilterbankTest_IIR_Zeros.pf
ITADSPThirdOctaveFilterbankTest_IIR_SomeBands.pf
%% FIR
fir_zeros = ita_read( 'ITADSPThirdOctaveFilterbankTest_FIR_Zeros.wav' );
fir_zeros.signalType = 'power';
fir_unity = ita_read( 'ITADSPThirdOctaveFilterbankTest_FIR_Identity.wav' );
fir_unity.signalType = 'power';
fir_sb = ita_read( 'ITADSPThirdOctaveFilterbankTest_FIR_SomeBands.wav' );
fir_sb.signalType = 'power';
fir_sb_unity = fir_sb.ch( 1 );
for n = 2:fir_sb.nChannels
fir_sb_unity = fir_sb_unity + fir_sb.ch( n );
end
fir_all = ita_merge( fir_zeros, fir_unity, fir_sb );
fir_all.pf