mirror of
https://github.com/AndroidAudioMods/ViPERFX_RE.git
synced 2025-01-03 16:13:35 +08:00
Update
This commit is contained in:
parent
59d6c12118
commit
5c4092e8e4
@ -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)
|
||||
|
@ -2,17 +2,17 @@
|
||||
#include <cstring>
|
||||
#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);
|
||||
|
||||
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);
|
||||
|
||||
this->harmonic[0].Reset();
|
||||
this->harmonic[1].Reset();
|
||||
|
||||
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);
|
||||
|
||||
for (auto &peak : this->peak) {
|
||||
peak.RefreshFilter(MultiBiquad::FilterType::PEAK, 0.58f, 633.0f, this->samplingRate, 6.28f, true);
|
||||
this->gain = 1.2;
|
||||
|
||||
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);
|
||||
|
||||
for (auto &harmonic : this->harmonic) {
|
||||
harmonic.Reset();
|
||||
}
|
||||
this->gain = 2.4;
|
||||
|
||||
if (this->processingModel == 0) {
|
||||
for (auto &harmonic : this->harmonic) {
|
||||
harmonic.SetHarmonics(ANALOGX_HARMONICS);
|
||||
}
|
||||
|
||||
this->gain = 0.6f;
|
||||
|
||||
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->gain = 1.2f;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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];
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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];
|
||||
|
@ -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;
|
||||
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
@ -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];
|
||||
|
||||
|
@ -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);
|
||||
|
@ -1,19 +1,18 @@
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#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])))))))))));
|
||||
|
||||
this->prevOut = (this->lastProcessed + this->prevOut * 0.999) - prevLast;
|
||||
|
||||
if (this->sampleCounter < this->biggestCoeff) {
|
||||
this->sampleCounter++;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
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;
|
||||
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];
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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];
|
||||
|
@ -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];
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user