Skip to content

Commit

Permalink
ViPERDDC: Do not spam log when sampling rate is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
iscle committed Apr 9, 2024
1 parent 0c86463 commit 11e5cb6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/viper/effects/ViPERDDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::array<float, 5>> *coeffsArr;

Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
3 changes: 2 additions & 1 deletion src/viper/effects/ViPERDDC.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -31,6 +31,7 @@ class ViPERDDC {
std::vector<float> y2R;

void ReleaseResources();
bool isSamplingRateValid() const;
};


0 comments on commit 11e5cb6

Please sign in to comment.