mirror of
https://github.com/AndroidAudioMods/ViPERFX_RE.git
synced 2025-06-24 00:52:31 +08:00
Update
This commit is contained in:
@ -91,3 +91,4 @@ add_library(
|
|||||||
${FILES})
|
${FILES})
|
||||||
|
|
||||||
target_link_libraries(v4afx_r log) # kissfft)
|
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 <cstring>
|
||||||
#include "../constants.h"
|
#include "../constants.h"
|
||||||
|
|
||||||
static float ANALOGX_HARMONICS[10] = {
|
static float ANALOGX_HARMONICS[] = {
|
||||||
0.01f,
|
0.01,
|
||||||
0.02f,
|
0.02,
|
||||||
0.0001f,
|
0.0001,
|
||||||
0.001f,
|
0.001,
|
||||||
0.0f,
|
0.0,
|
||||||
0.0f,
|
0.0,
|
||||||
0.0f,
|
0.0,
|
||||||
0.0f,
|
0.0,
|
||||||
0.0f,
|
0.0,
|
||||||
0.0f
|
0.0
|
||||||
};
|
};
|
||||||
|
|
||||||
AnalogX::AnalogX() {
|
AnalogX::AnalogX() {
|
||||||
@ -24,17 +24,20 @@ AnalogX::AnalogX() {
|
|||||||
|
|
||||||
void AnalogX::Process(float *samples, uint32_t size) {
|
void AnalogX::Process(float *samples, uint32_t size) {
|
||||||
if (this->enable) {
|
if (this->enable) {
|
||||||
for (int i = 0; i < size * 2; i++) {
|
for (uint32_t i = 0; i < size * 2; i += 2) {
|
||||||
float sample = samples[i];
|
double inL = samples[i];
|
||||||
int channel = i % 2;
|
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);
|
double inR = samples[i + 1];
|
||||||
tmp = this->harmonic[channel].Process(tmp);
|
double outR = this->highPass[1].ProcessSample(inR);
|
||||||
|
outR = this->harmonic[1].Process(outR);
|
||||||
tmp = this->lowpass[channel].ProcessSample(sample + tmp * this->gain);
|
outR = this->lowPass[1].ProcessSample(inR + outR * this->gain);
|
||||||
tmp = this->peak->ProcessSample(tmp * 0.8f);
|
outR = this->peak[1].ProcessSample(outR * 0.8);
|
||||||
|
samples[i + 1] = (float) outR;
|
||||||
samples[i] = tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->freqRange < this->samplingRate / 4) {
|
if (this->freqRange < this->samplingRate / 4) {
|
||||||
@ -45,47 +48,45 @@ void AnalogX::Process(float *samples, uint32_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AnalogX::Reset() {
|
void AnalogX::Reset() {
|
||||||
for (auto &highpass : this->highpass) {
|
this->highPass[0].RefreshFilter(MultiBiquad::FilterType::HIGH_PASS, 0.0, 240.0, this->samplingRate, 0.717, false);
|
||||||
highpass.RefreshFilter(MultiBiquad::FilterType::HIGH_PASS, 0.0f, 240.0f, this->samplingRate, 0.717f, 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) {
|
this->gain = 1.2;
|
||||||
peak.RefreshFilter(MultiBiquad::FilterType::PEAK, 0.58f, 633.0f, this->samplingRate, 6.28f, true);
|
|
||||||
|
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) {
|
this->gain = 2.4;
|
||||||
harmonic.Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->processingModel == 0) {
|
this->lowPass[0].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, 16307.0, this->samplingRate, 0.717, false);
|
||||||
for (auto &harmonic : this->harmonic) {
|
this->lowPass[1].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, 16307.0, this->samplingRate, 0.717, false);
|
||||||
harmonic.SetHarmonics(ANALOGX_HARMONICS);
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ public:
|
|||||||
void SetSamplingRate(uint32_t samplingRate);
|
void SetSamplingRate(uint32_t samplingRate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MultiBiquad highpass[2];
|
MultiBiquad highPass[2];
|
||||||
Harmonic harmonic[2];
|
Harmonic harmonic[2];
|
||||||
MultiBiquad lowpass[2];
|
MultiBiquad lowPass[2];
|
||||||
MultiBiquad peak[2];
|
MultiBiquad peak[2];
|
||||||
|
|
||||||
float gain;
|
float gain;
|
||||||
|
@ -25,14 +25,14 @@ void DiffSurround::Process(float *samples, uint32_t size) {
|
|||||||
bufs[0] = this->buffers[0]->PushZerosGetBuffer(size);
|
bufs[0] = this->buffers[0]->PushZerosGetBuffer(size);
|
||||||
bufs[1] = this->buffers[1]->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];
|
bufs[i % 2][i / 2] = samples[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
outbufs[0] = this->buffers[0]->GetBuffer();
|
outbufs[0] = this->buffers[0]->GetBuffer();
|
||||||
outbufs[1] = this->buffers[1]->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];
|
samples[i] = outbufs[i % 2][i / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ SpeakerCorrection::SpeakerCorrection() {
|
|||||||
void SpeakerCorrection::Process(float *samples, uint32_t size) {
|
void SpeakerCorrection::Process(float *samples, uint32_t size) {
|
||||||
if (!this->enable) return;
|
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];
|
double outL = samples[i];
|
||||||
outL = this->lowPass[0].ProcessSample(outL);
|
outL = this->lowPass[0].ProcessSample(outL);
|
||||||
outL = this->highPass[0].ProcessSample(outL);
|
outL = this->highPass[0].ProcessSample(outL);
|
||||||
|
@ -28,7 +28,7 @@ SpectrumExtend::~SpectrumExtend() {
|
|||||||
|
|
||||||
void SpectrumExtend::Process(float *samples, uint32_t size) {
|
void SpectrumExtend::Process(float *samples, uint32_t size) {
|
||||||
if (this->enabled) {
|
if (this->enabled) {
|
||||||
for (int i = 0; i < size * 2; i++) {
|
for (uint32_t i = 0; i < size * 2; i++) {
|
||||||
float sample = samples[i];
|
float sample = samples[i];
|
||||||
int index = i % 2;
|
int index = i % 2;
|
||||||
float tmp = this->highpass[index].ProcessSample(sample);
|
float tmp = this->highpass[index].ProcessSample(sample);
|
||||||
|
@ -23,7 +23,7 @@ void TubeSimulator::SetEnable(bool enable) {
|
|||||||
|
|
||||||
void TubeSimulator::TubeProcess(float *buffer, uint32_t size) {
|
void TubeSimulator::TubeProcess(float *buffer, uint32_t size) {
|
||||||
if (this->enable) {
|
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[0] = (this->acc[0] + buffer[2 * x]) / 2.f;
|
||||||
this->acc[1] = (this->acc[1] + buffer[2 * x + 1]) / 2.f;
|
this->acc[1] = (this->acc[1] + buffer[2 * x + 1]) / 2.f;
|
||||||
buffer[2 * x] = this->acc[0];
|
buffer[2 * x] = this->acc[0];
|
||||||
|
@ -26,7 +26,7 @@ void ViPERClarity::Process(float *samples, uint32_t size) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ClarityMode::OZONE: {
|
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]);
|
samples[i] = (float) this->highShelf[i % 2].Process(samples[i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -45,7 +45,7 @@ void Crossfeed::Reset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Crossfeed::ProcessFrames(float *buffer, uint32_t size) {
|
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]);
|
FilterSample(&buffer[x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ DepthSurround::DepthSurround() {
|
|||||||
void DepthSurround::Process(float *samples, uint32_t size) {
|
void DepthSurround::Process(float *samples, uint32_t size) {
|
||||||
if (this->enabled) {
|
if (this->enabled) {
|
||||||
if (!this->strengthAtLeast500) {
|
if (!this->strengthAtLeast500) {
|
||||||
for (int i = 0; i < size; i++) {
|
for (uint32_t i = 0; i < size; i++) {
|
||||||
float sampleLeft = samples[2 * i];
|
float sampleLeft = samples[2 * i];
|
||||||
float sampleRight = samples[2 * i + 1];
|
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);
|
samples[2 * i + 1] = avg - (diff - avgOut);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < size; i++) {
|
for (uint32_t i = 0; i < size; i++) {
|
||||||
float sampleLeft = samples[2 * i];
|
float sampleLeft = samples[2 * i];
|
||||||
float sampleRight = samples[2 * i + 1];
|
float sampleRight = samples[2 * i + 1];
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ DynamicBass::DynamicBass() {
|
|||||||
|
|
||||||
void DynamicBass::FilterSamples(float *samples, uint32_t size) {
|
void DynamicBass::FilterSamples(float *samples, uint32_t size) {
|
||||||
if (this->lowFreqX <= 120) {
|
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 left = samples[2 * i];
|
||||||
float right = samples[2 * i + 1];
|
float right = samples[2 * i + 1];
|
||||||
float avg = (float) this->lowPass.ProcessSample(left + right);
|
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;
|
samples[2 * i + 1] = right + avg;
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
float x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6;
|
||||||
|
|
||||||
this->filterX.DoFilterLeft(samples[2 * i], &x1, &x2, &x3);
|
this->filterX.DoFilterLeft(samples[2 * i], &x1, &x2, &x3);
|
||||||
|
@ -1,19 +1,18 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdlib>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "Harmonic.h"
|
#include "Harmonic.h"
|
||||||
|
|
||||||
static float HARMONIC_DEFAULT[10] = {
|
static float HARMONIC_DEFAULT[] = {
|
||||||
1.f,
|
1.0,
|
||||||
0.f,
|
0.0,
|
||||||
0.f,
|
0.0,
|
||||||
0.f,
|
0.0,
|
||||||
0.f,
|
0.0,
|
||||||
0.f,
|
0.0,
|
||||||
0.f,
|
0.0,
|
||||||
0.f,
|
0.0,
|
||||||
0.f,
|
0.0,
|
||||||
0.f,
|
0.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
Harmonic::Harmonic() {
|
Harmonic::Harmonic() {
|
||||||
@ -21,38 +20,36 @@ Harmonic::Harmonic() {
|
|||||||
Reset();
|
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) {
|
return this->prevOut;
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Harmonic::Reset() {
|
void Harmonic::Reset() {
|
||||||
this->lastProcessed = 0.0;
|
this->lastProcessed = 0.0;
|
||||||
this->prevOut = 0.0;
|
|
||||||
this->sampleCounter = 0;
|
this->sampleCounter = 0;
|
||||||
|
this->prevOut = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Harmonic::SetHarmonics(float *coefficients) {
|
void Harmonic::SetHarmonics(float *coefficients) {
|
||||||
@ -61,58 +58,51 @@ void Harmonic::SetHarmonics(float *coefficients) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Harmonic::UpdateCoeffs(float *coefficients) {
|
void Harmonic::UpdateCoeffs(float *coefficients) {
|
||||||
// float fVar5;
|
float unkarr1[11];
|
||||||
// float fVar6;
|
float unkarr2[11];
|
||||||
// float _coeffs[20];
|
|
||||||
// float afStack76[14];
|
memset(unkarr1, 0, 11 * sizeof(float));
|
||||||
//
|
|
||||||
// memset(_coeffs, 0, 11 * sizeof(float));
|
float biggestCoeffVal = 0.0;
|
||||||
// this->buildup = (int) fabsf(coefficients[10]);
|
float absCoeffSum = 0.0;
|
||||||
// memcpy(&_coeffs[1], coefficients, 10 * sizeof(float));
|
for (uint32_t i = 0; i < 10; i++) {
|
||||||
//
|
float absCoeffVal = abs(coefficients[i]);
|
||||||
// fVar6 = 1.f / (
|
absCoeffSum += absCoeffVal;
|
||||||
// fabsf(_coeffs[1]) +
|
if (absCoeffVal > biggestCoeffVal) {
|
||||||
// fabsf(_coeffs[2]) +
|
biggestCoeffVal = absCoeffVal;
|
||||||
// fabsf(_coeffs[3]) +
|
}
|
||||||
// fabsf(_coeffs[4]) +
|
}
|
||||||
// fabsf(_coeffs[5]) +
|
this->biggestCoeff = (uint32_t) (biggestCoeffVal * 10000.0);
|
||||||
// fabsf(_coeffs[6]) +
|
|
||||||
// fabsf(_coeffs[7]) +
|
memcpy(unkarr1 + 1, coefficients, 10 * sizeof(float));
|
||||||
// fabsf(_coeffs[8]) +
|
|
||||||
// fabsf(_coeffs[9]) +
|
float unk1 = 1.0;
|
||||||
// fabsf(_coeffs[10])
|
if (absCoeffSum > 1.0) {
|
||||||
// );
|
unk1 = 1.0f / absCoeffSum;
|
||||||
//
|
}
|
||||||
// for (int i = 0; i < 11; i++) {
|
for (uint32_t i = 1; i < 11; i++) {
|
||||||
// _coeffs[i] *= fVar6;
|
unkarr1[i] *= unk1;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// for (int i = 0; i < 11; i++) {
|
memset(this->coeffs, 0, 11 * sizeof(float));
|
||||||
// afStack76[2 + i] = 0;
|
memset(unkarr2, 0, 11 * sizeof(float));
|
||||||
// _coeffs[10 + i] = 0;
|
|
||||||
// }
|
this->coeffs[10] = unkarr1[10];
|
||||||
//
|
|
||||||
// _coeffs[11] = _coeffs[10];
|
for (uint32_t i = 2; i < 11; i++) {
|
||||||
// fVar6 = _coeffs[11];
|
for (uint32_t j = 0; j < i; j++) {
|
||||||
// for (int i = 2; i < 11; i++) {
|
float tmp = unkarr2[i - j];
|
||||||
// for (int idx = 0; idx < i; idx++) {
|
unkarr2[i - j] = this->coeffs[i - j];
|
||||||
// _coeffs[11] = fVar6;
|
this->coeffs[i - j] = this->coeffs[i - j - 1] * 2.0f - tmp;
|
||||||
// fVar5 = _coeffs[10 - idx + i];
|
}
|
||||||
// fVar6 = afStack76[2 - idx + i];
|
float tmp = unkarr1[10 - i + 1] - unkarr2[0];
|
||||||
// afStack76[2 - idx + i] = _coeffs[11 - idx + i];
|
unkarr2[0] = this->coeffs[0];
|
||||||
// _coeffs[11 - idx + i] = 2 * fVar5 - fVar6;
|
this->coeffs[0] = tmp;
|
||||||
// fVar6 = _coeffs[11];
|
}
|
||||||
// }
|
|
||||||
// fVar6 = _coeffs[11 - i] - afStack76[2];
|
for (uint32_t i = 1; i < 11; i++) {
|
||||||
// afStack76[2] = _coeffs[11];
|
this->coeffs[10 - i + 1] = this->coeffs[10 - i] - unkarr2[10 - i + 1];
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// for (int i = 1; i < 11; i++) {
|
this->coeffs[0] = unkarr1[0] / 2.0f - unkarr2[0];
|
||||||
// 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];
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -5,18 +5,17 @@
|
|||||||
class Harmonic {
|
class Harmonic {
|
||||||
public:
|
public:
|
||||||
Harmonic();
|
Harmonic();
|
||||||
~Harmonic();
|
|
||||||
|
|
||||||
float Process(float sample);
|
double Process(double sample);
|
||||||
void Reset();
|
void Reset();
|
||||||
void SetHarmonics(float *coeffs);
|
void SetHarmonics(float *coeffs);
|
||||||
void UpdateCoeffs(float *coeffs);
|
void UpdateCoeffs(float *coeffs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float coeffs[11];
|
float coeffs[11];
|
||||||
float lastProcessed;
|
double lastProcessed;
|
||||||
float prevOut;
|
double prevOut;
|
||||||
uint32_t buildup;
|
uint32_t biggestCoeff;
|
||||||
uint32_t sampleCounter;
|
uint32_t sampleCounter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ void HiFi::Process(float *samples, uint32_t size) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < size * 2; i++) {
|
for (uint32_t i = 0; i < size * 2; i++) {
|
||||||
int index = i % 2;
|
int index = i % 2;
|
||||||
float out1 = do_filter_lh(this->filters[index].lowpass, samples[i]);
|
float out1 = do_filter_lh(this->filters[index].lowpass, samples[i]);
|
||||||
float out2 = do_filter_lh(this->filters[index].highpass, 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 *bpOut = this->buffers[0]->GetBuffer();
|
||||||
float *lpOut = this->buffers[1]->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 hp = samples[i] * this->gain * 1.2f;
|
||||||
float bp = bpOut[i] * this->gain;
|
float bp = bpOut[i] * this->gain;
|
||||||
samples[i] = hp + bp + lpOut[i];
|
samples[i] = hp + bp + lpOut[i];
|
||||||
@ -53,7 +53,7 @@ void HiFi::Process(float *samples, uint32_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HiFi::Reset() {
|
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->setLPF(120.0, this->samplingRate);
|
||||||
this->filters[i].lowpass->Mute();
|
this->filters[i].lowpass->Mute();
|
||||||
this->filters[i].highpass->setHPF(1200.0, this->samplingRate);
|
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->highpass = new IIR_1st[order];
|
||||||
this->order = order;
|
this->order = order;
|
||||||
|
|
||||||
for (int x = 0; x < order; x++) {
|
for (uint32_t x = 0; x < order; x++) {
|
||||||
this->lowpass[x].Mute();
|
this->lowpass[x].Mute();
|
||||||
this->highpass[x].Mute();
|
this->highpass[x].Mute();
|
||||||
}
|
}
|
||||||
@ -17,14 +17,14 @@ IIR_NOrder_BW_BP::~IIR_NOrder_BW_BP() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IIR_NOrder_BW_BP::Mute() {
|
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->lowpass[x].Mute();
|
||||||
this->highpass[x].Mute();
|
this->highpass[x].Mute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIR_NOrder_BW_BP::setBPF(float highCut, float lowCut, uint32_t samplingRate) {
|
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->lowpass[x].setLPF_BW(lowCut, samplingRate);
|
||||||
this->highpass[x].setHPF_BW(highCut, 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) {
|
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);
|
sample = do_filter(&filt->lowpass[idx], sample);
|
||||||
}
|
}
|
||||||
return sample;
|
return sample;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float do_filter_bphp(IIR_NOrder_BW_BP *filt, float 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);
|
sample = do_filter(&filt->highpass[idx], sample);
|
||||||
}
|
}
|
||||||
return 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->filters = new IIR_1st[order];
|
||||||
this->order = order;
|
this->order = order;
|
||||||
|
|
||||||
for (int x = 0; x < order; x++) {
|
for (uint32_t x = 0; x < order; x++) {
|
||||||
this->filters[x].Mute();
|
this->filters[x].Mute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14,19 +14,19 @@ IIR_NOrder_BW_LH::~IIR_NOrder_BW_LH() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IIR_NOrder_BW_LH::Mute() {
|
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();
|
this->filters[x].Mute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIR_NOrder_BW_LH::setLPF(float frequency, uint32_t samplingRate) {
|
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);
|
this->filters[x].setLPF_BW(frequency, samplingRate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIR_NOrder_BW_LH::setHPF(float frequency, uint32_t 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);
|
this->filters[x].setHPF_BW(frequency, samplingRate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline float do_filter_lh(IIR_NOrder_BW_LH *filt, float sample) {
|
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);
|
sample = do_filter(&filt->filters[idx], sample);
|
||||||
}
|
}
|
||||||
return sample;
|
return sample;
|
||||||
|
@ -65,7 +65,7 @@ MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float frequency, uint
|
|||||||
double b2;
|
double b2;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case LOW_PASS: { // OK
|
case LOW_PASS: {
|
||||||
a0 = 1.0 + y;
|
a0 = 1.0 + y;
|
||||||
a1 = -2.0 * cosOmega;
|
a1 = -2.0 * cosOmega;
|
||||||
a2 = 1.0 - y;
|
a2 = 1.0 - y;
|
||||||
|
@ -8,7 +8,7 @@ NoiseSharpening::NoiseSharpening() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NoiseSharpening::Process(float *buffer, uint32_t size) {
|
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 sampleLeft = buffer[i * 2];
|
||||||
float sampleRight = buffer[i * 2 + 1];
|
float sampleRight = buffer[i * 2 + 1];
|
||||||
float prevLeft = this->in[0];
|
float prevLeft = this->in[0];
|
||||||
|
@ -37,7 +37,7 @@ void PassFilter::Reset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PassFilter::ProcessFrames(float *buffer, uint32_t size) {
|
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 left = buffer[2 * x];
|
||||||
float right = buffer[2 * x + 1];
|
float right = buffer[2 * x + 1];
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ Subwoofer::Subwoofer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Subwoofer::Process(float *samples, uint32_t size) {
|
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];
|
auto sample = (double) samples[i];
|
||||||
int index = i % 2;
|
int index = i % 2;
|
||||||
double tmp = this->peak[index].ProcessSample(sample);
|
double tmp = this->peak[index].ProcessSample(sample);
|
||||||
|
Reference in New Issue
Block a user