Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple audio assert fix (add sampleRate to DSPs which does not need them) #400

Merged
merged 1 commit into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Audio/include/Audio/DSP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"; }
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Audio/src/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 6 additions & 1 deletion Audio/src/DSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -696,8 +700,9 @@ class PitchShiftDSP_Impl
}
};

PitchShiftDSP::PitchShiftDSP()
PitchShiftDSP::PitchShiftDSP(uint32 sampleRate) : DSP()
{
SetSampleRate(sampleRate);
m_impl = new PitchShiftDSP_Impl();
}
PitchShiftDSP::~PitchShiftDSP()
Expand Down
2 changes: 1 addition & 1 deletion Main/src/Audio/GameAudioEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down