Skip to content
Snippets Groups Projects
Commit a04aa5a6 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

wip

parent 58e98c4c
No related tags found
No related merge requests found
...@@ -20,14 +20,15 @@ ...@@ -20,14 +20,15 @@
#include <DspFilters/Butterworth.h> #include <DspFilters/Butterworth.h>
#include <ITAAudioSample.h>
#include <ITAConstants.h> #include <ITAConstants.h>
#include <ITAFiniteImpulseResponse.h> #include <ITAFiniteImpulseResponse.h>
#include <ITAStopWatch.h>
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
#include <cmath> #include <cmath>
#include <vector> #include <vector>
#include "ITAAudioSample.h"
#include "VistaTools/VistaRandomNumberGenerator.h" #include "VistaTools/VistaRandomNumberGenerator.h"
using namespace std; using namespace std;
...@@ -209,6 +210,7 @@ void live_coeff_change_test() ...@@ -209,6 +210,7 @@ void live_coeff_change_test()
CITAAudioSample sbCoeffChangeTest( 3, int( fSampleRate * 10 ), fSampleRate ); CITAAudioSample sbCoeffChangeTest( 3, int( fSampleRate * 10 ), fSampleRate );
ITAStopWatch sw;
for( int n = 0; n < sbCoeffChangeTest.GetLength(); n++ ) for( int n = 0; n < sbCoeffChangeTest.GetLength(); n++ )
{ {
float fRandomSample = VistaRandomNumberGenerator::GetStandardRNG()->GenerateFloat( -1.0f, 1.0f ); float fRandomSample = VistaRandomNumberGenerator::GetStandardRNG()->GenerateFloat( -1.0f, 1.0f );
...@@ -218,7 +220,9 @@ void live_coeff_change_test() ...@@ -218,7 +220,9 @@ void live_coeff_change_test()
float fModulatedCenterFrequency = fMidCenterFrequency + 600.0f * sin( ITAConstants::TWO_PI_F * n / float( sbCoeffChangeTest.GetLength() ) * 10 ); float fModulatedCenterFrequency = fMidCenterFrequency + 600.0f * sin( ITAConstants::TWO_PI_F * n / float( sbCoeffChangeTest.GetLength() ) * 10 );
sbCoeffChangeTest[ 2 ][ n ] = ( fModulatedCenterFrequency - fMidCenterFrequency ) / 2.0f / fMidCenterFrequency; sbCoeffChangeTest[ 2 ][ n ] = ( fModulatedCenterFrequency - fMidCenterFrequency ) / 2.0f / fMidCenterFrequency;
sw.start();
oBPFDynamic.setup( iOrder, fSampleRate, fModulatedCenterFrequency, fModulatedCenterFrequency / fQ ); oBPFDynamic.setup( iOrder, fSampleRate, fModulatedCenterFrequency, fModulatedCenterFrequency / fQ );
sw.stop(); // takes about 30us on Intel i7 3GHZ from 2015 in debug mode .. not entirely irrelevant :/
float* pfSampleAliasDynamic = &sbCoeffChangeTest[ 0 ][ n ]; float* pfSampleAliasDynamic = &sbCoeffChangeTest[ 0 ][ n ];
oBPFDynamic.process( 1, &pfSampleAliasDynamic ); oBPFDynamic.process( 1, &pfSampleAliasDynamic );
...@@ -227,5 +231,7 @@ void live_coeff_change_test() ...@@ -227,5 +231,7 @@ void live_coeff_change_test()
oBPFStatic.process( 1, &pfSampleAliasStatic ); oBPFStatic.process( 1, &pfSampleAliasStatic );
} }
cout << "SimpleFilter setup routine stats: " << sw << endl;
sbCoeffChangeTest.Store( "NativeDspFiltersTest_LiveCoeffChangeTest.wav" ); sbCoeffChangeTest.Store( "NativeDspFiltersTest_LiveCoeffChangeTest.wav" );
} }
...@@ -55,7 +55,7 @@ namespace ITADSP ...@@ -55,7 +55,7 @@ namespace ITADSP
inline virtual ~CJetEngine() {}; inline virtual ~CJetEngine() {};
virtual void SetRPM( float fInletValue ); virtual void SetRPM( float fNewRPM );
virtual void Process( float* pfOutputBuffer, int iNumSamples ); virtual void Process( float* pfOutputBuffer, int iNumSamples );
protected: protected:
...@@ -79,11 +79,22 @@ int main( int, char** ) ...@@ -79,11 +79,22 @@ int main( int, char** )
{ {
ITASampleBuffer oOutputBuffer( g_iOutputLengthSamples ); ITASampleBuffer oOutputBuffer( g_iOutputLengthSamples );
float fRPM = 1100.f; vector<float > vfRPMs = { 700.f, 800.0f, 600.0f, 1100.0f, 2500.0f, 4000.0f, 4200.0f, 4000.0f, 3000.0f, 2800.0f };
ITADSP::PD::CJetEngine oPatch( fRPM ); ITADSP::PD::CJetEngine oPatch( vfRPMs[ 0 ] );
oPatch.Process( oOutputBuffer.GetData(), g_iOutputLengthSamples );
string sFilePath = "ITADSP_pd_jet_engine_out_rpm1100.wav"; int iTimeSeriesLeg = g_iOutputLengthSamples / (int) vfRPMs.size();
int iTotalSamples = 0;
for( auto m = 0; m < vfRPMs.size(); m++ )
{
oPatch.SetRPM( vfRPMs[ m ] );
int iProcessSamples = std::min( iTimeSeriesLeg, oOutputBuffer.GetLength() - m * iTimeSeriesLeg );
oPatch.Process( oOutputBuffer.GetData() + iTotalSamples, iProcessSamples );
iTotalSamples += iProcessSamples;
}
assert( iTotalSamples == oOutputBuffer.GetLength() );
string sFilePath = "ITADSP_pd_jet_engine_out.wav";
writeAudiofile( sFilePath, &oOutputBuffer, g_dSampleRate, ITAQuantization::ITA_FLOAT ); writeAudiofile( sFilePath, &oOutputBuffer, g_dSampleRate, ITAQuantization::ITA_FLOAT );
cout << "Exported result to " << sFilePath << endl; cout << "Exported result to " << sFilePath << endl;
...@@ -175,7 +186,7 @@ void ITADSP::PD::CJetEngine::Process( float* pfOutputBuffer, int iNumSamples ) ...@@ -175,7 +186,7 @@ void ITADSP::PD::CJetEngine::Process( float* pfOutputBuffer, int iNumSamples )
m_fTempSample *= 0.5f; // *~ 0.5 m_fTempSample *= 0.5f; // *~ 0.5
const float fManualBalance = 0.2 / 0.5; // Manual modifier [NOT INCLUDED IN PD PATCH] const float fManualBalance = 0.2f / 0.5f; // Manual modifier [NOT INCLUDED IN PD PATCH]
fCurrentSample += fManualBalance * m_fTempSample; // combine turbine and flame from jet engine patch (with a manual balance that sound better) fCurrentSample += fManualBalance * m_fTempSample; // combine turbine and flame from jet engine patch (with a manual balance that sound better)
m_oJetEngineLP1.process( 1, &pfTempSampleAlias ); // ~lop 11000 m_oJetEngineLP1.process( 1, &pfTempSampleAlias ); // ~lop 11000
......
jet_engine = ita_read( 'ITADSP_pd_jet_engine_out.wav' ) jet_engine = ita_read( 'ITADSP_pd_jet_engine_out.wav' )
jet_engine.pt jet_engine.plot_spectrogram
jet_engine.play jet_engine.play
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment