diff --git a/Audio/include/Audio/DSP.hpp b/Audio/include/Audio/DSP.hpp index 4e2ae8df6..3b5792f34 100644 --- a/Audio/include/Audio/DSP.hpp +++ b/Audio/include/Audio/DSP.hpp @@ -67,6 +67,8 @@ class CombinedFilterDSP : public DSP class LimiterDSP : public DSP { public: + LimiterDSP(uint32 sampleRate); + float releaseTime = 0.1f; virtual void Process(float* out, uint32 numSamples); virtual const char* GetName() const { return "LimiterDSP"; } @@ -270,10 +272,11 @@ class SidechainDSP : public DSP class PitchShiftDSP : public DSP { public: + PitchShiftDSP(uint32 sampleRate); + // Pitch change amount float amount = 0.0f; - PitchShiftDSP(); ~PitchShiftDSP(); virtual void Process(float* out, uint32 numSamples); diff --git a/Audio/src/Audio.cpp b/Audio/src/Audio.cpp index a68db4571..5bb084963 100644 --- a/Audio/src/Audio.cpp +++ b/Audio/src/Audio.cpp @@ -110,7 +110,7 @@ void Audio_Impl::Mix(void* data, uint32& numSamples) } void Audio_Impl::Start() { - limiter = new LimiterDSP(); + limiter = new LimiterDSP(GetSampleRate()); limiter->SetAudio(this); limiter->releaseTime = 0.2f; diff --git a/Audio/src/DSP.cpp b/Audio/src/DSP.cpp index 86711740a..908590eeb 100644 --- a/Audio/src/DSP.cpp +++ b/Audio/src/DSP.cpp @@ -144,6 +144,10 @@ void CombinedFilterDSP::Process(float* out, uint32 numSamples) peak.Process(out, numSamples); } +LimiterDSP::LimiterDSP(uint32 sampleRate) : DSP() +{ + SetSampleRate(sampleRate); +} void LimiterDSP::Process(float* out, uint32 numSamples) { const float secondsPerSample = (float) m_audio->GetSecondsPerSample(); @@ -696,8 +700,9 @@ class PitchShiftDSP_Impl } }; -PitchShiftDSP::PitchShiftDSP() +PitchShiftDSP::PitchShiftDSP(uint32 sampleRate) : DSP() { + SetSampleRate(sampleRate); m_impl = new PitchShiftDSP_Impl(); } PitchShiftDSP::~PitchShiftDSP() diff --git a/Main/src/Audio/GameAudioEffects.cpp b/Main/src/Audio/GameAudioEffects.cpp index 8428085b3..949b8103b 100644 --- a/Main/src/Audio/GameAudioEffects.cpp +++ b/Main/src/Audio/GameAudioEffects.cpp @@ -106,7 +106,7 @@ DSP* GameAudioEffect::CreateDSP(AudioPlayback& playback, uint32 sampleRate) } case EffectType::PitchShift: { - PitchShiftDSP* ps = new PitchShiftDSP(); + PitchShiftDSP* ps = new PitchShiftDSP(sampleRate); ps->amount = pitchshift.amount.Sample(filterInput); ret = ps; break;