Commit 58e98c4c authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Adding DspFilsters test that modifies coefficients in real-time / live. works, baby!

parent aea30067
......@@ -27,6 +27,8 @@
#include <iostream>
#include <cmath>
#include <vector>
#include "ITAAudioSample.h"
#include "VistaTools/VistaRandomNumberGenerator.h"
using namespace std;
using namespace Dsp;
......@@ -44,6 +46,7 @@ void manual_band_pass_1kHz();
void tri_band();
void downcast_test();
void octave_bands();
void live_coeff_change_test();
int main( int, char** )
{
......@@ -57,6 +60,8 @@ int main( int, char** )
octave_bands();
live_coeff_change_test();
return 255;
}
......@@ -191,3 +196,36 @@ void octave_bands()
oHPF.process( iFilterLength, &pf );
oIR.Store( "NativeDspFiltersTest_IR_OctaveBands_HP.wav" );
}
void live_coeff_change_test()
{
float fMidCenterFrequency = 1200.0f;
float fQ = 2;
SimpleFilter< Butterworth::BandPass< iOrder >, iChannels > oBPFDynamic, oBPFStatic;
assert( fMidCenterFrequency > 0 );
oBPFDynamic.setup( iOrder, fSampleRate, fMidCenterFrequency, fMidCenterFrequency / fQ );
oBPFStatic.setup( iOrder, fSampleRate, fMidCenterFrequency, fMidCenterFrequency / fQ );
CITAAudioSample sbCoeffChangeTest( 3, int( fSampleRate * 10 ), fSampleRate );
for( int n = 0; n < sbCoeffChangeTest.GetLength(); n++ )
{
float fRandomSample = VistaRandomNumberGenerator::GetStandardRNG()->GenerateFloat( -1.0f, 1.0f );
sbCoeffChangeTest[ 0 ][ n ] = fRandomSample;
sbCoeffChangeTest[ 1 ][ n ] = fRandomSample;
float fModulatedCenterFrequency = fMidCenterFrequency + 600.0f * sin( ITAConstants::TWO_PI_F * n / float( sbCoeffChangeTest.GetLength() ) * 10 );
sbCoeffChangeTest[ 2 ][ n ] = ( fModulatedCenterFrequency - fMidCenterFrequency ) / 2.0f / fMidCenterFrequency;
oBPFDynamic.setup( iOrder, fSampleRate, fModulatedCenterFrequency, fModulatedCenterFrequency / fQ );
float* pfSampleAliasDynamic = &sbCoeffChangeTest[ 0 ][ n ];
oBPFDynamic.process( 1, &pfSampleAliasDynamic );
float* pfSampleAliasStatic = &sbCoeffChangeTest[ 1 ][ n ];
oBPFStatic.process( 1, &pfSampleAliasStatic );
}
sbCoeffChangeTest.Store( "NativeDspFiltersTest_LiveCoeffChangeTest.wav" );
}
......@@ -42,3 +42,10 @@ IR_Octaves_HP = ita_read( 'NativeDspFiltersTest_IR_OctaveBands_HP.wav' );
IR_Octaves = ita_merge( IR_Octaves_LP, IR_Octaves_BP1, IR_Octaves_BP2,IR_Octaves_BP3, IR_Octaves_BP4, IR_Octaves_BP5, IR_Octaves_BP6, IR_Octaves_BP7, IR_Octaves_BP8, IR_Octaves_HP );
IR_Octaves = ita_merge( IR_Octaves, IR_Octaves.sum );
IR_Octaves.pf
%% Time-variant filtering
LiveCoeffChangeTest = ita_read( 'NativeDspFiltersTest_LiveCoeffChangeTest.wav' );
LiveCoeffChangeTest.pt
LiveCoeffChangeTest.ch(1).play
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