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

Moved code from inline header to src file

parent 2e236b0d
......@@ -36,9 +36,6 @@
class CITAIIRFilterEngine;
class CITAThirdOctaveFIRFilterGenerator;
const int g_iIIRFilterOrder = 1;
const int g_iChannels = 1;
namespace ITADSP
{
namespace PD
......@@ -51,50 +48,8 @@ namespace ITADSP
class ITA_DSP_API CJetEngine
{
public:
inline CJetEngine( double dSampleRate = 44100.0f, float fRPMInit = 1000.0f, bool bColdStart = true )
: m_dSampleRate( dSampleRate )
{
m_vfTurbineBaseModeFrequencies = { 3097.0f, 4495.0f, 5588.0f, 7414.0f, 11000.0f };
m_vfTurbineBaseModeAmplitudes = { 0.25f, 0.25f, 1.0f, 0.4f, 0.4f };
m_vfRPMRange = { 1000.0f, 5000.0f };
const float fCenterFrequency1 = 8000.0f;
const float fQ1 = 0.5f;
m_oForcedFlameBP1.setup( g_iIIRFilterOrder, float( dSampleRate ), fCenterFrequency1, fCenterFrequency1 / fQ1 );
const float fCutoffFrequency1 = 120.0f;
m_oForcedFlameHP1.setup( g_iIIRFilterOrder, float( dSampleRate ), fCutoffFrequency1 );
const float fLPCutoffFrequency1 = 11000.0f;
m_oJetEngineLP1.setup( g_iIIRFilterOrder, float( dSampleRate ), fLPCutoffFrequency1 );
const float fLPCutoffFrequency2 = 0.1f;
m_oJetEngineLP2.setup( 1, float( dSampleRate ), fLPCutoffFrequency2 );
oCtxAudio.vfTurbineModePhaseShift = { 0, 0, 0, 0, 0 };
oCtxAudio.vfTurbineModeFrequencies = { 0, 0, 0, 0, 0 };
SetRPM( fRPMInit );
if( !bColdStart )
{
// Run input low-pass for 3 secs (until 0.2 Hz LP died away on unit step function) to akkumulate
// of the default input, otherwise there is a run-up from zero to target RPM value
const float fNormalizedRPMInit = GetRPMNormalized( oCtxAudio.vfRPM );
float fNormalizedRPMUpsample;
float* pfNormalizedRPMUpsampleAlias = &fNormalizedRPMUpsample;
for( int n = 0; n < ( int ) dSampleRate * 3; n++ )
{
fNormalizedRPMUpsample = fNormalizedRPMInit;
m_oJetEngineLP2.process( 1, &pfNormalizedRPMUpsampleAlias );
}
}
};
inline virtual ~CJetEngine()
{
};
CJetEngine( double dSampleRate = 44100.0f, float fRPMInit = 1000.0f, bool bColdStart = true );
virtual ~CJetEngine();
virtual void SetRPM( float fNewRPM );
virtual void Process( float* pfOutputBuffer, int iNumSamples );
......@@ -114,9 +69,9 @@ namespace ITADSP
private:
VistaRandomNumberGenerator oRNG;
Dsp::SimpleFilter< Dsp::Butterworth::BandPass< g_iIIRFilterOrder >, g_iChannels > m_oForcedFlameBP1, m_oForcedFlameBP2, m_oForcedFlameBP3;
Dsp::SimpleFilter< Dsp::Butterworth::HighPass< g_iIIRFilterOrder >, g_iChannels > m_oForcedFlameHP1;
Dsp::SimpleFilter< Dsp::Butterworth::LowPass< 1 >, g_iChannels > m_oJetEngineLP1, m_oJetEngineLP2;
Dsp::SimpleFilter< Dsp::Butterworth::BandPass< 1 >, 1 > m_oForcedFlameBP1, m_oForcedFlameBP2, m_oForcedFlameBP3;
Dsp::SimpleFilter< Dsp::Butterworth::HighPass< 1 >, 1 > m_oForcedFlameHP1;
Dsp::SimpleFilter< Dsp::Butterworth::LowPass< 1 >, 1 > m_oJetEngineLP1, m_oJetEngineLP2;
std::vector< float > m_vfTurbineBaseModeFrequencies, m_vfTurbineBaseModeAmplitudes, m_vfRPMRange;
......
#include <ITADSP/PD/JetEngine.h>
ITADSP::PD::CJetEngine::CJetEngine( double dSampleRate, float fRPMInit, bool bColdStart )
: m_dSampleRate( dSampleRate )
{
m_vfTurbineBaseModeFrequencies = { 3097.0f, 4495.0f, 5588.0f, 7414.0f, 11000.0f };
m_vfTurbineBaseModeAmplitudes = { 0.25f, 0.25f, 1.0f, 0.4f, 0.4f };
m_vfRPMRange = { 1000.0f, 5000.0f };
const float fCenterFrequency1 = 8000.0f;
const float fQ1 = 0.5f;
m_oForcedFlameBP1.setup( 1, float( dSampleRate ), fCenterFrequency1, fCenterFrequency1 / fQ1 );
const float fCutoffFrequency1 = 120.0f;
m_oForcedFlameHP1.setup( 1, float( dSampleRate ), fCutoffFrequency1 );
const float fLPCutoffFrequency1 = 11000.0f;
m_oJetEngineLP1.setup( 1, float( dSampleRate ), fLPCutoffFrequency1 );
const float fLPCutoffFrequency2 = 1.0f;
m_oJetEngineLP2.setup( 1, float( dSampleRate ), fLPCutoffFrequency2 );
oCtxAudio.vfTurbineModePhaseShift = { 0, 0, 0, 0, 0 };
oCtxAudio.vfTurbineModeFrequencies = { 0, 0, 0, 0, 0 };
SetRPM( fRPMInit );
if( !bColdStart )
{
// Run input low-pass for 3 secs (until 0.2 Hz LP died away on unit step function) to akkumulate
// of the default input, otherwise there is a run-up from zero to target RPM value
const float fNormalizedRPMInit = GetRPMNormalized( oCtxAudio.vfRPM );
float fNormalizedRPMUpsample;
float* pfNormalizedRPMUpsampleAlias = &fNormalizedRPMUpsample;
for( int n = 0; n < ( int ) dSampleRate * 3; n++ )
{
fNormalizedRPMUpsample = fNormalizedRPMInit;
m_oJetEngineLP2.process( 1, &pfNormalizedRPMUpsampleAlias );
}
}
};
ITADSP::PD::CJetEngine::~CJetEngine()
{
}
void ITADSP::PD::CJetEngine::SetRPM( float fRPM )
{
oCtxAudio.vfRPM = fRPM; // Direct write-through, no lock & swap implemented here
......@@ -44,11 +89,11 @@ void ITADSP::PD::CJetEngine::Process( float* pfOutputBuffer, int iNumSamples )
// Update forced flame filters
const float fCenterFrequency2 = fNormalizedRPMControlUpscaled * fNormalizedRPMControlUpscaled * 150.0f;
m_oForcedFlameBP2.setup( g_iIIRFilterOrder, float( m_dSampleRate ), fCenterFrequency2, fCenterFrequency2 / 1.0f );
m_oForcedFlameBP2.setup( 1, float( m_dSampleRate ), fCenterFrequency2, fCenterFrequency2 / 1.0f );
const float fCenterFrequency3 = fNormalizedRPMControlUpscaled * 12000.0f;
const float fQ3 = 0.6f;
m_oForcedFlameBP3.setup( g_iIIRFilterOrder, float( m_dSampleRate ), fCenterFrequency3, fCenterFrequency3 / fQ3 );
m_oForcedFlameBP3.setup( 1, float( m_dSampleRate ), fCenterFrequency3, fCenterFrequency3 / fQ3 );
/* Process DSP */
......
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