diff --git a/CMakeLists.txt b/CMakeLists.txt index aae2c55..4ba3985 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,3 +91,4 @@ add_library( ${FILES}) target_link_libraries(v4afx_r log) # kissfft) +target_compile_options(v4afx_r PRIVATE -Wall -Wextra -Wno-unused-parameter) diff --git a/src/cpp/viper/effects/AnalogX.cpp b/src/cpp/viper/effects/AnalogX.cpp index 05081b0..c8fabc9 100644 --- a/src/cpp/viper/effects/AnalogX.cpp +++ b/src/cpp/viper/effects/AnalogX.cpp @@ -2,17 +2,17 @@ #include #include "../constants.h" -static float ANALOGX_HARMONICS[10] = { - 0.01f, - 0.02f, - 0.0001f, - 0.001f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f +static float ANALOGX_HARMONICS[] = { + 0.01, + 0.02, + 0.0001, + 0.001, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 }; AnalogX::AnalogX() { @@ -24,17 +24,20 @@ AnalogX::AnalogX() { void AnalogX::Process(float *samples, uint32_t size) { if (this->enable) { - for (int i = 0; i < size * 2; i++) { - float sample = samples[i]; - int channel = i % 2; + for (uint32_t i = 0; i < size * 2; i += 2) { + double inL = samples[i]; + double outL = this->highPass[0].ProcessSample(inL); + outL = this->harmonic[0].Process(outL); + outL = this->lowPass[0].ProcessSample(inL + outL * this->gain); + outL = this->peak[0].ProcessSample(outL * 0.8); + samples[i] = (float) outL; - double tmp = this->highpass[channel].ProcessSample(sample); - tmp = this->harmonic[channel].Process(tmp); - - tmp = this->lowpass[channel].ProcessSample(sample + tmp * this->gain); - tmp = this->peak->ProcessSample(tmp * 0.8f); - - samples[i] = tmp; + double inR = samples[i + 1]; + double outR = this->highPass[1].ProcessSample(inR); + outR = this->harmonic[1].Process(outR); + outR = this->lowPass[1].ProcessSample(inR + outR * this->gain); + outR = this->peak[1].ProcessSample(outR * 0.8); + samples[i + 1] = (float) outR; } if (this->freqRange < this->samplingRate / 4) { @@ -45,47 +48,45 @@ void AnalogX::Process(float *samples, uint32_t size) { } void AnalogX::Reset() { - for (auto &highpass : this->highpass) { - highpass.RefreshFilter(MultiBiquad::FilterType::HIGH_PASS, 0.0f, 240.0f, this->samplingRate, 0.717f, false); - } + this->highPass[0].RefreshFilter(MultiBiquad::FilterType::HIGH_PASS, 0.0, 240.0, this->samplingRate, 0.717, false); + this->highPass[1].RefreshFilter(MultiBiquad::FilterType::HIGH_PASS, 0.0, 240.0, this->samplingRate, 0.717, false); - for (auto &peak : this->peak) { - peak.RefreshFilter(MultiBiquad::FilterType::PEAK, 0.58f, 633.0f, this->samplingRate, 6.28f, true); - } + this->peak[0].RefreshFilter(MultiBiquad::FilterType::PEAK, 0.58, 633.0, this->samplingRate, 6.28, true); + this->peak[1].RefreshFilter(MultiBiquad::FilterType::PEAK, 0.58, 633.0, this->samplingRate, 6.28, true); - for (auto &harmonic : this->harmonic) { - harmonic.Reset(); - } + this->harmonic[0].Reset(); + this->harmonic[1].Reset(); - if (this->processingModel == 0) { - for (auto &harmonic : this->harmonic) { - harmonic.SetHarmonics(ANALOGX_HARMONICS); + switch (this->processingModel) { + case 0: { + this->harmonic[0].SetHarmonics(ANALOGX_HARMONICS); + this->harmonic[1].SetHarmonics(ANALOGX_HARMONICS); + + this->gain = 0.6; + + this->lowPass[0].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, 19650.0, this->samplingRate, 0.717, false); + this->lowPass[1].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, 19650.0, this->samplingRate, 0.717, false); + break; } + case 1: { + this->harmonic[0].SetHarmonics(ANALOGX_HARMONICS); + this->harmonic[1].SetHarmonics(ANALOGX_HARMONICS); - this->gain = 0.6f; + this->gain = 1.2; - for (auto &lowpass : this->lowpass) { - lowpass.RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0f, 19650.0f, this->samplingRate, 0.717f, false); - } - } else if (this->processingModel == 1) { - for (auto &harmonic : this->harmonic) { - harmonic.SetHarmonics(ANALOGX_HARMONICS); + this->lowPass[0].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, 18233.0, this->samplingRate, 0.717, false); + this->lowPass[1].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, 18233.0, this->samplingRate, 0.717, false); + break; } + case 2: { + this->harmonic[0].SetHarmonics(ANALOGX_HARMONICS); + this->harmonic[1].SetHarmonics(ANALOGX_HARMONICS); - this->gain = 1.2f; + this->gain = 2.4; - for (auto &lowpass : this->lowpass) { - lowpass.RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0f, 18233.0f, this->samplingRate, 0.717f, false); - } - } else if (this->processingModel == 2) { - for (auto &harmonic : this->harmonic) { - harmonic.SetHarmonics(ANALOGX_HARMONICS); - } - - this->gain = 2.4f; - - for (auto &lowpass : this->lowpass) { - lowpass.RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0f, 16307.0f, this->samplingRate, 0.717f, false); + this->lowPass[0].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, 16307.0, this->samplingRate, 0.717, false); + this->lowPass[1].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, 16307.0, this->samplingRate, 0.717, false); + break; } } diff --git a/src/cpp/viper/effects/AnalogX.h b/src/cpp/viper/effects/AnalogX.h index 5afe2cd..98e5ea2 100644 --- a/src/cpp/viper/effects/AnalogX.h +++ b/src/cpp/viper/effects/AnalogX.h @@ -15,9 +15,9 @@ public: void SetSamplingRate(uint32_t samplingRate); private: - MultiBiquad highpass[2]; + MultiBiquad highPass[2]; Harmonic harmonic[2]; - MultiBiquad lowpass[2]; + MultiBiquad lowPass[2]; MultiBiquad peak[2]; float gain; diff --git a/src/cpp/viper/effects/DiffSurround.cpp b/src/cpp/viper/effects/DiffSurround.cpp index 8f471b8..94c3816 100644 --- a/src/cpp/viper/effects/DiffSurround.cpp +++ b/src/cpp/viper/effects/DiffSurround.cpp @@ -25,14 +25,14 @@ void DiffSurround::Process(float *samples, uint32_t size) { bufs[0] = this->buffers[0]->PushZerosGetBuffer(size); bufs[1] = this->buffers[1]->PushZerosGetBuffer(size); - for (int i = 0; i < size * 2; i++) { + for (uint32_t i = 0; i < size * 2; i++) { bufs[i % 2][i / 2] = samples[i]; } outbufs[0] = this->buffers[0]->GetBuffer(); outbufs[1] = this->buffers[1]->GetBuffer(); - for (int i = 0; i < size * 2; i++) { + for (uint32_t i = 0; i < size * 2; i++) { samples[i] = outbufs[i % 2][i / 2]; } diff --git a/src/cpp/viper/effects/SpeakerCorrection.cpp b/src/cpp/viper/effects/SpeakerCorrection.cpp index 7737a59..90d39ab 100644 --- a/src/cpp/viper/effects/SpeakerCorrection.cpp +++ b/src/cpp/viper/effects/SpeakerCorrection.cpp @@ -10,7 +10,7 @@ SpeakerCorrection::SpeakerCorrection() { void SpeakerCorrection::Process(float *samples, uint32_t size) { if (!this->enable) return; - for (int i = 0; i < size * 2; i += 2) { + for (uint32_t i = 0; i < size * 2; i += 2) { double outL = samples[i]; outL = this->lowPass[0].ProcessSample(outL); outL = this->highPass[0].ProcessSample(outL); diff --git a/src/cpp/viper/effects/SpectrumExtend.cpp b/src/cpp/viper/effects/SpectrumExtend.cpp index fef6a61..35d3569 100644 --- a/src/cpp/viper/effects/SpectrumExtend.cpp +++ b/src/cpp/viper/effects/SpectrumExtend.cpp @@ -28,7 +28,7 @@ SpectrumExtend::~SpectrumExtend() { void SpectrumExtend::Process(float *samples, uint32_t size) { if (this->enabled) { - for (int i = 0; i < size * 2; i++) { + for (uint32_t i = 0; i < size * 2; i++) { float sample = samples[i]; int index = i % 2; float tmp = this->highpass[index].ProcessSample(sample); diff --git a/src/cpp/viper/effects/TubeSimulator.cpp b/src/cpp/viper/effects/TubeSimulator.cpp index 7d46e80..421e073 100644 --- a/src/cpp/viper/effects/TubeSimulator.cpp +++ b/src/cpp/viper/effects/TubeSimulator.cpp @@ -23,7 +23,7 @@ void TubeSimulator::SetEnable(bool enable) { void TubeSimulator::TubeProcess(float *buffer, uint32_t size) { if (this->enable) { - for (int x = 0; x < size; x++) { + for (uint32_t x = 0; x < size; x++) { this->acc[0] = (this->acc[0] + buffer[2 * x]) / 2.f; this->acc[1] = (this->acc[1] + buffer[2 * x + 1]) / 2.f; buffer[2 * x] = this->acc[0]; diff --git a/src/cpp/viper/effects/ViPERClarity.cpp b/src/cpp/viper/effects/ViPERClarity.cpp index 8f22c85..bd08f64 100644 --- a/src/cpp/viper/effects/ViPERClarity.cpp +++ b/src/cpp/viper/effects/ViPERClarity.cpp @@ -26,7 +26,7 @@ void ViPERClarity::Process(float *samples, uint32_t size) { break; } case ClarityMode::OZONE: { - for (int i = 0; i < size * 2; i++) { + for (uint32_t i = 0; i < size * 2; i++) { samples[i] = (float) this->highShelf[i % 2].Process(samples[i]); } break; diff --git a/src/cpp/viper/utils/Crossfeed.cpp b/src/cpp/viper/utils/Crossfeed.cpp index d32422a..30d9db7 100644 --- a/src/cpp/viper/utils/Crossfeed.cpp +++ b/src/cpp/viper/utils/Crossfeed.cpp @@ -45,7 +45,7 @@ void Crossfeed::Reset() { } void Crossfeed::ProcessFrames(float *buffer, uint32_t size) { - for (int x = 0; x < size; x += 2) { + for (uint32_t x = 0; x < size; x += 2) { FilterSample(&buffer[x]); } } diff --git a/src/cpp/viper/utils/DepthSurround.cpp b/src/cpp/viper/utils/DepthSurround.cpp index bb913da..108b1d9 100644 --- a/src/cpp/viper/utils/DepthSurround.cpp +++ b/src/cpp/viper/utils/DepthSurround.cpp @@ -17,7 +17,7 @@ DepthSurround::DepthSurround() { void DepthSurround::Process(float *samples, uint32_t size) { if (this->enabled) { if (!this->strengthAtLeast500) { - for (int i = 0; i < size; i++) { + for (uint32_t i = 0; i < size; i++) { float sampleLeft = samples[2 * i]; float sampleRight = samples[2 * i + 1]; @@ -34,7 +34,7 @@ void DepthSurround::Process(float *samples, uint32_t size) { samples[2 * i + 1] = avg - (diff - avgOut); } } else { - for (int i = 0; i < size; i++) { + for (uint32_t i = 0; i < size; i++) { float sampleLeft = samples[2 * i]; float sampleRight = samples[2 * i + 1]; diff --git a/src/cpp/viper/utils/DynamicBass.cpp b/src/cpp/viper/utils/DynamicBass.cpp index fcab0e2..c185a49 100644 --- a/src/cpp/viper/utils/DynamicBass.cpp +++ b/src/cpp/viper/utils/DynamicBass.cpp @@ -19,7 +19,7 @@ DynamicBass::DynamicBass() { void DynamicBass::FilterSamples(float *samples, uint32_t size) { if (this->lowFreqX <= 120) { - for (int i = 0; i < size; i++) { + for (uint32_t i = 0; i < size; i++) { float left = samples[2 * i]; float right = samples[2 * i + 1]; float avg = (float) this->lowPass.ProcessSample(left + right); @@ -27,7 +27,7 @@ void DynamicBass::FilterSamples(float *samples, uint32_t size) { samples[2 * i + 1] = right + avg; } } else { - for (int i = 0; i < size; i++) { + for (uint32_t i = 0; i < size; i++) { float x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6; this->filterX.DoFilterLeft(samples[2 * i], &x1, &x2, &x3); diff --git a/src/cpp/viper/utils/Harmonic.cpp b/src/cpp/viper/utils/Harmonic.cpp index 0094386..1081c74 100644 --- a/src/cpp/viper/utils/Harmonic.cpp +++ b/src/cpp/viper/utils/Harmonic.cpp @@ -1,19 +1,18 @@ #include -#include #include #include "Harmonic.h" -static float HARMONIC_DEFAULT[10] = { - 1.f, - 0.f, - 0.f, - 0.f, - 0.f, - 0.f, - 0.f, - 0.f, - 0.f, - 0.f, +static float HARMONIC_DEFAULT[] = { + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, }; Harmonic::Harmonic() { @@ -21,38 +20,36 @@ Harmonic::Harmonic() { Reset(); } -Harmonic::~Harmonic() { +double Harmonic::Process(double sample) { + double prevLast = this->lastProcessed; -} + this->lastProcessed = + (this->coeffs[0] + sample * + (this->coeffs[1] + sample * + (this->coeffs[2] + sample * + (this->coeffs[3] + sample * + (this->coeffs[4] + sample * + (this->coeffs[5] + sample * + (this->coeffs[6] + sample * + (this->coeffs[7] + sample * + (this->coeffs[8] + sample * + (this->coeffs[9] + sample * + (this->coeffs[10]))))))))))); -float Harmonic::Process(float sample) { -// float prevLast = this->lastProcessed; -// this->lastProcessed = ( -// sample * this->coeffs[0] + -// sample * this->coeffs[1] + -// sample * this->coeffs[2] + -// sample * this->coeffs[3] + -// sample * this->coeffs[4] + -// sample * this->coeffs[5] + -// sample * this->coeffs[6] + -// sample * this->coeffs[7] + -// sample * this->coeffs[8] + -// sample * this->coeffs[9] + -// sample * this->coeffs[10] -// ); -// this->prevOut = (this->lastProcessed + this->prevOut * 0.999f) - prevLast; -// if (this->sampleCounter < this->buildup) { -// this->sampleCounter++; -// return 0.0; -// } -// return this->prevOut; - return sample; + this->prevOut = (this->lastProcessed + this->prevOut * 0.999) - prevLast; + + if (this->sampleCounter < this->biggestCoeff) { + this->sampleCounter++; + return 0.0; + } + + return this->prevOut; } void Harmonic::Reset() { this->lastProcessed = 0.0; - this->prevOut = 0.0; this->sampleCounter = 0; + this->prevOut = 0.0; } void Harmonic::SetHarmonics(float *coefficients) { @@ -61,58 +58,51 @@ void Harmonic::SetHarmonics(float *coefficients) { } void Harmonic::UpdateCoeffs(float *coefficients) { -// float fVar5; -// float fVar6; -// float _coeffs[20]; -// float afStack76[14]; -// -// memset(_coeffs, 0, 11 * sizeof(float)); -// this->buildup = (int) fabsf(coefficients[10]); -// memcpy(&_coeffs[1], coefficients, 10 * sizeof(float)); -// -// fVar6 = 1.f / ( -// fabsf(_coeffs[1]) + -// fabsf(_coeffs[2]) + -// fabsf(_coeffs[3]) + -// fabsf(_coeffs[4]) + -// fabsf(_coeffs[5]) + -// fabsf(_coeffs[6]) + -// fabsf(_coeffs[7]) + -// fabsf(_coeffs[8]) + -// fabsf(_coeffs[9]) + -// fabsf(_coeffs[10]) -// ); -// -// for (int i = 0; i < 11; i++) { -// _coeffs[i] *= fVar6; -// } -// -// for (int i = 0; i < 11; i++) { -// afStack76[2 + i] = 0; -// _coeffs[10 + i] = 0; -// } -// -// _coeffs[11] = _coeffs[10]; -// fVar6 = _coeffs[11]; -// for (int i = 2; i < 11; i++) { -// for (int idx = 0; idx < i; idx++) { -// _coeffs[11] = fVar6; -// fVar5 = _coeffs[10 - idx + i]; -// fVar6 = afStack76[2 - idx + i]; -// afStack76[2 - idx + i] = _coeffs[11 - idx + i]; -// _coeffs[11 - idx + i] = 2 * fVar5 - fVar6; -// fVar6 = _coeffs[11]; -// } -// fVar6 = _coeffs[11 - i] - afStack76[2]; -// afStack76[2] = _coeffs[11]; -// } -// -// for (int i = 1; i < 11; i++) { -// afStack76[2 + i] = afStack76[i - 1] - afStack76[13 - i]; -// } -// -// _coeffs[11] = _coeffs[0] * 0.5f - _coeffs[11]; -// for (int i = 0; i < 11; i++) { -// this->coeffs[i] = _coeffs[11 + i]; -// } + float unkarr1[11]; + float unkarr2[11]; + + memset(unkarr1, 0, 11 * sizeof(float)); + + float biggestCoeffVal = 0.0; + float absCoeffSum = 0.0; + for (uint32_t i = 0; i < 10; i++) { + float absCoeffVal = abs(coefficients[i]); + absCoeffSum += absCoeffVal; + if (absCoeffVal > biggestCoeffVal) { + biggestCoeffVal = absCoeffVal; + } + } + this->biggestCoeff = (uint32_t) (biggestCoeffVal * 10000.0); + + memcpy(unkarr1 + 1, coefficients, 10 * sizeof(float)); + + float unk1 = 1.0; + if (absCoeffSum > 1.0) { + unk1 = 1.0f / absCoeffSum; + } + for (uint32_t i = 1; i < 11; i++) { + unkarr1[i] *= unk1; + } + + memset(this->coeffs, 0, 11 * sizeof(float)); + memset(unkarr2, 0, 11 * sizeof(float)); + + this->coeffs[10] = unkarr1[10]; + + for (uint32_t i = 2; i < 11; i++) { + for (uint32_t j = 0; j < i; j++) { + float tmp = unkarr2[i - j]; + unkarr2[i - j] = this->coeffs[i - j]; + this->coeffs[i - j] = this->coeffs[i - j - 1] * 2.0f - tmp; + } + float tmp = unkarr1[10 - i + 1] - unkarr2[0]; + unkarr2[0] = this->coeffs[0]; + this->coeffs[0] = tmp; + } + + for (uint32_t i = 1; i < 11; i++) { + this->coeffs[10 - i + 1] = this->coeffs[10 - i] - unkarr2[10 - i + 1]; + } + + this->coeffs[0] = unkarr1[0] / 2.0f - unkarr2[0]; } diff --git a/src/cpp/viper/utils/Harmonic.h b/src/cpp/viper/utils/Harmonic.h index bf10a33..362c039 100644 --- a/src/cpp/viper/utils/Harmonic.h +++ b/src/cpp/viper/utils/Harmonic.h @@ -5,18 +5,17 @@ class Harmonic { public: Harmonic(); - ~Harmonic(); - float Process(float sample); + double Process(double sample); void Reset(); void SetHarmonics(float *coeffs); void UpdateCoeffs(float *coeffs); private: float coeffs[11]; - float lastProcessed; - float prevOut; - uint32_t buildup; + double lastProcessed; + double prevOut; + uint32_t biggestCoeff; uint32_t sampleCounter; }; diff --git a/src/cpp/viper/utils/HiFi.cpp b/src/cpp/viper/utils/HiFi.cpp index 8ecbb96..0935cd4 100644 --- a/src/cpp/viper/utils/HiFi.cpp +++ b/src/cpp/viper/utils/HiFi.cpp @@ -31,7 +31,7 @@ void HiFi::Process(float *samples, uint32_t size) { return; } - for (int i = 0; i < size * 2; i++) { + for (uint32_t i = 0; i < size * 2; i++) { int index = i % 2; float out1 = do_filter_lh(this->filters[index].lowpass, samples[i]); float out2 = do_filter_lh(this->filters[index].highpass, samples[i]); @@ -42,7 +42,7 @@ void HiFi::Process(float *samples, uint32_t size) { } float *bpOut = this->buffers[0]->GetBuffer(); float *lpOut = this->buffers[1]->GetBuffer(); - for (int i = 0; i < size * 2; i++) { + for (uint32_t i = 0; i < size * 2; i++) { float hp = samples[i] * this->gain * 1.2f; float bp = bpOut[i] * this->gain; samples[i] = hp + bp + lpOut[i]; @@ -53,7 +53,7 @@ void HiFi::Process(float *samples, uint32_t size) { } void HiFi::Reset() { - for (int i = 0; i < 2; i++) { + for (uint32_t i = 0; i < 2; i++) { this->filters[i].lowpass->setLPF(120.0, this->samplingRate); this->filters[i].lowpass->Mute(); this->filters[i].highpass->setHPF(1200.0, this->samplingRate); diff --git a/src/cpp/viper/utils/IIR_NOrder_BW_BP.cpp b/src/cpp/viper/utils/IIR_NOrder_BW_BP.cpp index 6c9546f..e1769ed 100644 --- a/src/cpp/viper/utils/IIR_NOrder_BW_BP.cpp +++ b/src/cpp/viper/utils/IIR_NOrder_BW_BP.cpp @@ -5,7 +5,7 @@ IIR_NOrder_BW_BP::IIR_NOrder_BW_BP(uint32_t order) { this->highpass = new IIR_1st[order]; this->order = order; - for (int x = 0; x < order; x++) { + for (uint32_t x = 0; x < order; x++) { this->lowpass[x].Mute(); this->highpass[x].Mute(); } @@ -17,14 +17,14 @@ IIR_NOrder_BW_BP::~IIR_NOrder_BW_BP() { } void IIR_NOrder_BW_BP::Mute() { - for (int x = 0; x < this->order; x++) { + for (uint32_t x = 0; x < this->order; x++) { this->lowpass[x].Mute(); this->highpass[x].Mute(); } } void IIR_NOrder_BW_BP::setBPF(float highCut, float lowCut, uint32_t samplingRate) { - for (int x = 0; x < this->order; x++) { + for (uint32_t x = 0; x < this->order; x++) { this->lowpass[x].setLPF_BW(lowCut, samplingRate); this->highpass[x].setHPF_BW(highCut, samplingRate); } diff --git a/src/cpp/viper/utils/IIR_NOrder_BW_BP.h b/src/cpp/viper/utils/IIR_NOrder_BW_BP.h index dd0ab0b..51cd266 100644 --- a/src/cpp/viper/utils/IIR_NOrder_BW_BP.h +++ b/src/cpp/viper/utils/IIR_NOrder_BW_BP.h @@ -18,14 +18,14 @@ public: }; inline float do_filter_bplp(IIR_NOrder_BW_BP *filt, float sample) { - for (int idx = 0; idx < filt->order; idx++) { + for (uint32_t idx = 0; idx < filt->order; idx++) { sample = do_filter(&filt->lowpass[idx], sample); } return sample; } inline float do_filter_bphp(IIR_NOrder_BW_BP *filt, float sample) { - for (int idx = 0; idx < filt->order; idx++) { + for (uint32_t idx = 0; idx < filt->order; idx++) { sample = do_filter(&filt->highpass[idx], sample); } return sample; diff --git a/src/cpp/viper/utils/IIR_NOrder_BW_LH.cpp b/src/cpp/viper/utils/IIR_NOrder_BW_LH.cpp index 171c80d..a342d9a 100644 --- a/src/cpp/viper/utils/IIR_NOrder_BW_LH.cpp +++ b/src/cpp/viper/utils/IIR_NOrder_BW_LH.cpp @@ -4,7 +4,7 @@ IIR_NOrder_BW_LH::IIR_NOrder_BW_LH(uint32_t order) { this->filters = new IIR_1st[order]; this->order = order; - for (int x = 0; x < order; x++) { + for (uint32_t x = 0; x < order; x++) { this->filters[x].Mute(); } } @@ -14,19 +14,19 @@ IIR_NOrder_BW_LH::~IIR_NOrder_BW_LH() { } void IIR_NOrder_BW_LH::Mute() { - for (int x = 0; x < this->order; x++) { + for (uint32_t x = 0; x < this->order; x++) { this->filters[x].Mute(); } } void IIR_NOrder_BW_LH::setLPF(float frequency, uint32_t samplingRate) { - for (int x = 0; x < this->order; x++) { + for (uint32_t x = 0; x < this->order; x++) { this->filters[x].setLPF_BW(frequency, samplingRate); } } void IIR_NOrder_BW_LH::setHPF(float frequency, uint32_t samplingRate) { - for (int x = 0; x < this->order; x++) { + for (uint32_t x = 0; x < this->order; x++) { this->filters[x].setHPF_BW(frequency, samplingRate); } } diff --git a/src/cpp/viper/utils/IIR_NOrder_BW_LH.h b/src/cpp/viper/utils/IIR_NOrder_BW_LH.h index 6f4889b..904d20b 100644 --- a/src/cpp/viper/utils/IIR_NOrder_BW_LH.h +++ b/src/cpp/viper/utils/IIR_NOrder_BW_LH.h @@ -19,7 +19,7 @@ public: }; inline float do_filter_lh(IIR_NOrder_BW_LH *filt, float sample) { - for (int idx = 0; idx < filt->order; idx++) { + for (uint32_t idx = 0; idx < filt->order; idx++) { sample = do_filter(&filt->filters[idx], sample); } return sample; diff --git a/src/cpp/viper/utils/MultiBiquad.cpp b/src/cpp/viper/utils/MultiBiquad.cpp index 335205f..769d074 100644 --- a/src/cpp/viper/utils/MultiBiquad.cpp +++ b/src/cpp/viper/utils/MultiBiquad.cpp @@ -65,7 +65,7 @@ MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float frequency, uint double b2; switch (type) { - case LOW_PASS: { // OK + case LOW_PASS: { a0 = 1.0 + y; a1 = -2.0 * cosOmega; a2 = 1.0 - y; diff --git a/src/cpp/viper/utils/NoiseSharpening.cpp b/src/cpp/viper/utils/NoiseSharpening.cpp index 0feefa5..b8ccd7e 100644 --- a/src/cpp/viper/utils/NoiseSharpening.cpp +++ b/src/cpp/viper/utils/NoiseSharpening.cpp @@ -8,7 +8,7 @@ NoiseSharpening::NoiseSharpening() { } void NoiseSharpening::Process(float *buffer, uint32_t size) { - for (int i = 0; i < size; i++) { + for (uint32_t i = 0; i < size; i++) { float sampleLeft = buffer[i * 2]; float sampleRight = buffer[i * 2 + 1]; float prevLeft = this->in[0]; diff --git a/src/cpp/viper/utils/PassFilter.cpp b/src/cpp/viper/utils/PassFilter.cpp index a2aa0a8..13b6e65 100644 --- a/src/cpp/viper/utils/PassFilter.cpp +++ b/src/cpp/viper/utils/PassFilter.cpp @@ -37,7 +37,7 @@ void PassFilter::Reset() { } void PassFilter::ProcessFrames(float *buffer, uint32_t size) { - for (int x = 0; x < size; x++) { + for (uint32_t x = 0; x < size; x++) { float left = buffer[2 * x]; float right = buffer[2 * x + 1]; diff --git a/src/cpp/viper/utils/Subwoofer.cpp b/src/cpp/viper/utils/Subwoofer.cpp index 8ce9793..fbeb2cc 100644 --- a/src/cpp/viper/utils/Subwoofer.cpp +++ b/src/cpp/viper/utils/Subwoofer.cpp @@ -13,7 +13,7 @@ Subwoofer::Subwoofer() { } void Subwoofer::Process(float *samples, uint32_t size) { - for (int i = 0; i < size * 2; i++) { + for (uint32_t i = 0; i < size * 2; i++) { auto sample = (double) samples[i]; int index = i % 2; double tmp = this->peak[index].ProcessSample(sample);