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

wip

parent 58e98c4c
......@@ -20,14 +20,15 @@
#include <DspFilters/Butterworth.h>
#include <ITAAudioSample.h>
#include <ITAConstants.h>
#include <ITAFiniteImpulseResponse.h>
#include <ITAStopWatch.h>
#include <cassert>
#include <iostream>
#include <cmath>
#include <vector>
#include "ITAAudioSample.h"
#include "VistaTools/VistaRandomNumberGenerator.h"
using namespace std;
......@@ -208,7 +209,8 @@ void live_coeff_change_test()
oBPFStatic.setup( iOrder, fSampleRate, fMidCenterFrequency, fMidCenterFrequency / fQ );
CITAAudioSample sbCoeffChangeTest( 3, int( fSampleRate * 10 ), fSampleRate );
ITAStopWatch sw;
for( int n = 0; n < sbCoeffChangeTest.GetLength(); n++ )
{
float fRandomSample = VistaRandomNumberGenerator::GetStandardRNG()->GenerateFloat( -1.0f, 1.0f );
......@@ -218,7 +220,9 @@ void live_coeff_change_test()
float fModulatedCenterFrequency = fMidCenterFrequency + 600.0f * sin( ITAConstants::TWO_PI_F * n / float( sbCoeffChangeTest.GetLength() ) * 10 );
sbCoeffChangeTest[ 2 ][ n ] = ( fModulatedCenterFrequency - fMidCenterFrequency ) / 2.0f / fMidCenterFrequency;
sw.start();
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 ];
oBPFDynamic.process( 1, &pfSampleAliasDynamic );
......@@ -227,5 +231,7 @@ void live_coeff_change_test()
oBPFStatic.process( 1, &pfSampleAliasStatic );
}
cout << "SimpleFilter setup routine stats: " << sw << endl;
sbCoeffChangeTest.Store( "NativeDspFiltersTest_LiveCoeffChangeTest.wav" );
}
......@@ -31,7 +31,7 @@ namespace ITADSP
class CJetEngine
{
public:
inline CJetEngine( float RPMInit = 500.0f)
inline CJetEngine( float RPMInit = 500.0f )
{
m_vfTurbineModeFrequencies = { 3097.0f, 4495.0f, 5588.0f, 7414.0f, 11000.0f };
m_vfTurbineModeAmplitudes = { 0.25f, 0.25f, 1.0f, 0.4f, 0.4f };
......@@ -55,7 +55,7 @@ namespace ITADSP
inline virtual ~CJetEngine() {};
virtual void SetRPM( float fInletValue );
virtual void SetRPM( float fNewRPM );
virtual void Process( float* pfOutputBuffer, int iNumSamples );
protected:
......@@ -79,11 +79,22 @@ int main( int, char** )
{
ITASampleBuffer oOutputBuffer( g_iOutputLengthSamples );
float fRPM = 1100.f;
ITADSP::PD::CJetEngine oPatch( fRPM );
oPatch.Process( oOutputBuffer.GetData(), g_iOutputLengthSamples );
string sFilePath = "ITADSP_pd_jet_engine_out_rpm1100.wav";
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( vfRPMs[ 0 ] );
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 );
cout << "Exported result to " << sFilePath << endl;
......@@ -119,7 +130,7 @@ void ITADSP::PD::CJetEngine::UpdateTurbine( float fRPM )
// Normalize input
const float fNormalizedTurbineControl = std::max( 0.1f, fValidRPM / m_vfRPMRange[ 1 ] );
for( auto& v : m_vfTurbineModeFrequencies )
v *= fNormalizedTurbineControl;
}
......@@ -150,7 +161,7 @@ void ITADSP::PD::CJetEngine::Process( float* pfOutputBuffer, int iNumSamples )
fCurrentSample = m_fTempSample; // override buffer
// Turbine (adds to output buffer)
m_fTempSample = 0.0f;
......@@ -164,7 +175,7 @@ void ITADSP::PD::CJetEngine::Process( float* pfOutputBuffer, int iNumSamples )
const int iPeriodLengthSamples = ( int ) round( g_dSampleRate / fFrequency );
const float t = fmodf( ITAConstants::TWO_PI_F_L / float( iPeriodLengthSamples ) * float( n ), ITAConstants::TWO_PI_F );
m_fTempSample += fAmplitude * sin( t + fPhaseShift ); // all osc~ and *~
}
......@@ -175,7 +186,7 @@ void ITADSP::PD::CJetEngine::Process( float* pfOutputBuffer, int iNumSamples )
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)
m_oJetEngineLP1.process( 1, &pfTempSampleAlias ); // ~lop 11000
......
jet_engine = ita_read( 'ITADSP_pd_jet_engine_out.wav' )
jet_engine.pt
jet_engine.plot_spectrogram
jet_engine.play
\ No newline at end of file
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