diff --git a/src/viper/effects/ViPERDDC.cpp b/src/viper/effects/ViPERDDC.cpp index d59354c..f3d0362 100644 --- a/src/viper/effects/ViPERDDC.cpp +++ b/src/viper/effects/ViPERDDC.cpp @@ -12,6 +12,7 @@ ViPERDDC::ViPERDDC() : void ViPERDDC::Process(float *samples, uint32_t size) { if (!this->setCoeffsOk || this->arrSize == 0) return; if (!this->enable) return; + if (!isSamplingRateValid()) return; std::vector> *coeffsArr; @@ -24,10 +25,6 @@ void ViPERDDC::Process(float *samples, uint32_t size) { coeffsArr = &this->coeffsArr48000; break; } - default: { - VIPER_LOGD("ViPERDDC::Process() -> Invalid sampling rate: %d", this->samplingRate); - return; - } } for (uint32_t i = 0; i < size * 2; i += 2) { @@ -101,7 +98,7 @@ void ViPERDDC::Reset() { memset(this->x1R.data(), 0, this->arrSize * sizeof(float)); } -void ViPERDDC::SetCoeffs(uint32_t newCoeffsSize, float *newCoeffs44100, float *newCoeffs48000) { +void ViPERDDC::SetCoeffs(uint32_t newCoeffsSize, const float *newCoeffs44100, const float *newCoeffs48000) { ReleaseResources(); if (newCoeffsSize == 0) return; @@ -148,6 +145,13 @@ void ViPERDDC::SetEnable(bool enable) { void ViPERDDC::SetSamplingRate(uint32_t samplingRate) { if (this->samplingRate != samplingRate) { this->samplingRate = samplingRate; + if (!isSamplingRateValid()) { + VIPER_LOGE("ViPERDDC::SetSamplingRate() -> Invalid sampling rate: %d", this->samplingRate); + } Reset(); } } + +bool ViPERDDC::isSamplingRateValid() const { + return this->samplingRate == 44100 || this->samplingRate == 48000; +} diff --git a/src/viper/effects/ViPERDDC.h b/src/viper/effects/ViPERDDC.h index 65b9c54..c8d2de0 100644 --- a/src/viper/effects/ViPERDDC.h +++ b/src/viper/effects/ViPERDDC.h @@ -10,7 +10,7 @@ class ViPERDDC { void Process(float *samples, uint32_t size); void Reset(); - void SetCoeffs(uint32_t newCoeffsSize, float *newCoeffs44100, float *newCoeffs48000); + void SetCoeffs(uint32_t newCoeffsSize, const float *newCoeffs44100, const float *newCoeffs48000); void SetEnable(bool enable); void SetSamplingRate(uint32_t samplingRate); @@ -31,6 +31,7 @@ class ViPERDDC { std::vector y2R; void ReleaseResources(); + bool isSamplingRateValid() const; };