mirror of
https://github.com/AndroidAudioMods/ViPERFX_RE.git
synced 2025-06-08 02:29:40 +08:00
Update
This commit is contained in:
parent
d5a7ba77be
commit
59d6c12118
@ -46,7 +46,7 @@ void AnalogX::Process(float *samples, uint32_t size) {
|
||||
|
||||
void AnalogX::Reset() {
|
||||
for (auto &highpass : this->highpass) {
|
||||
highpass.RefreshFilter(MultiBiquad::FilterType::HIGHPASS, 0.0f, 240.0f, this->samplingRate, 0.717f, false);
|
||||
highpass.RefreshFilter(MultiBiquad::FilterType::HIGH_PASS, 0.0f, 240.0f, this->samplingRate, 0.717f, false);
|
||||
}
|
||||
|
||||
for (auto &peak : this->peak) {
|
||||
@ -65,7 +65,7 @@ void AnalogX::Reset() {
|
||||
this->gain = 0.6f;
|
||||
|
||||
for (auto &lowpass : this->lowpass) {
|
||||
lowpass.RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0f, 19650.0f, this->samplingRate, 0.717f, false);
|
||||
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) {
|
||||
@ -75,7 +75,7 @@ void AnalogX::Reset() {
|
||||
this->gain = 1.2f;
|
||||
|
||||
for (auto &lowpass : this->lowpass) {
|
||||
lowpass.RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0f, 18233.0f, this->samplingRate, 0.717f, false);
|
||||
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) {
|
||||
@ -85,7 +85,7 @@ void AnalogX::Reset() {
|
||||
this->gain = 2.4f;
|
||||
|
||||
for (auto &lowpass : this->lowpass) {
|
||||
lowpass.RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0f, 16307.0f, this->samplingRate, 0.717f, false);
|
||||
lowpass.RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0f, 16307.0f, this->samplingRate, 0.717f, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,8 @@ void SpeakerCorrection::Reset() {
|
||||
this->bandPass[0].Reset();
|
||||
this->bandPass[1].Reset();
|
||||
|
||||
this->highPass[0].RefreshFilter(MultiBiquad::FilterType::HIGHPASS, 0.0, 80.0, this->samplingRate, 1.0, false);
|
||||
this->highPass[1].RefreshFilter(MultiBiquad::FilterType::HIGHPASS, 0.0, 80.0, this->samplingRate, 1.0, false);
|
||||
this->highPass[0].RefreshFilter(MultiBiquad::FilterType::HIGH_PASS, 0.0, 80.0, this->samplingRate, 1.0, false);
|
||||
this->highPass[1].RefreshFilter(MultiBiquad::FilterType::HIGH_PASS, 0.0, 80.0, this->samplingRate, 1.0, false);
|
||||
this->lowPass[0].SetLowPassParameter(13500.0, this->samplingRate, 1.0);
|
||||
this->lowPass[1].SetLowPassParameter(13500.0, this->samplingRate, 1.0);
|
||||
this->bandPass[0].SetBandPassParameter(420.0, this->samplingRate, 3.88);
|
||||
|
@ -40,14 +40,14 @@ void SpectrumExtend::Process(float *samples, uint32_t size) {
|
||||
}
|
||||
|
||||
void SpectrumExtend::Reset() {
|
||||
this->highpass[0].RefreshFilter(MultiBiquad::FilterType::HIGHPASS, 0.0, (float) this->referenceFreq, (float) this->samplingRate,
|
||||
this->highpass[0].RefreshFilter(MultiBiquad::FilterType::HIGH_PASS, 0.0, (float) this->referenceFreq, (float) this->samplingRate,
|
||||
0.717, false);
|
||||
this->highpass[1].RefreshFilter(MultiBiquad::FilterType::HIGHPASS, 0.0, (float) this->referenceFreq, (float) this->samplingRate,
|
||||
this->highpass[1].RefreshFilter(MultiBiquad::FilterType::HIGH_PASS, 0.0, (float) this->referenceFreq, (float) this->samplingRate,
|
||||
0.717, false);
|
||||
|
||||
this->lowpass[0].RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0, (float) this->referenceFreq / 2.f - 2000.f,
|
||||
this->lowpass[0].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, (float) this->referenceFreq / 2.f - 2000.f,
|
||||
(float) this->referenceFreq, 0.717, false);
|
||||
this->lowpass[1].RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0, (float) this->referenceFreq / 2.f - 2000.f,
|
||||
this->lowpass[1].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, (float) this->referenceFreq / 2.f - 2000.f,
|
||||
(float) this->referenceFreq, 0.717, false);
|
||||
|
||||
this->harmonics[0].Reset();
|
||||
|
@ -31,12 +31,12 @@ double MultiBiquad::ProcessSample(double sample) {
|
||||
|
||||
void
|
||||
MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float frequency, uint32_t samplingRate, float qFactor, bool param_7) {
|
||||
float gain;
|
||||
double gain;
|
||||
|
||||
if (type - 5 < 3) { // type - 5 < 3 is always true... right?
|
||||
gain = pow(10.0f, gainAmp / 40.0f);
|
||||
if (type == FilterType::PEAK || type == FilterType::LOW_SHELF || type == HIGH_SHELF) {
|
||||
gain = pow(10.0, (double) gainAmp / 40.0);
|
||||
} else {
|
||||
gain = pow(10.0f, gainAmp / 20.0f);
|
||||
gain = pow(10.0, (double) gainAmp / 20.0);
|
||||
}
|
||||
|
||||
double omega = (2.0 * M_PI * (double) frequency) / (double) samplingRate;
|
||||
@ -46,15 +46,15 @@ MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float frequency, uint
|
||||
double y;
|
||||
double z;
|
||||
|
||||
if (type - 6 < 2) {
|
||||
y = sinOmega / 2.0 * sqrt((1.0 / ((double) gain * 2.0)) * (1.0 / (double) qFactor - 1.0) + 2.0);
|
||||
z = sqrt((double) gain) * y;
|
||||
if (type == FilterType::LOW_SHELF || type == FilterType::HIGH_SHELF) {
|
||||
y = sinOmega / 2.0 * sqrt((1.0 / gain + gain) * (1.0 / (double) qFactor - 1.0) + 2.0);
|
||||
z = sqrt(gain) * 2.0 * y;
|
||||
} else if (!param_7) {
|
||||
y = sinOmega / ((double) qFactor / 2.0);
|
||||
z = -1.0;
|
||||
y = sinOmega / ((double) qFactor * 2.0);
|
||||
z = -1.0; // Unused in this case
|
||||
} else {
|
||||
y = sinh(((double) qFactor * (log(2.0) / 2.0) * omega) / sinOmega);
|
||||
z = -1.0;
|
||||
y = sinh(((double) qFactor * log(2.0) * omega / 2.0) / sinOmega) * sinOmega;
|
||||
z = -1.0; // Unused in this case
|
||||
}
|
||||
|
||||
double a0;
|
||||
@ -65,7 +65,7 @@ MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float frequency, uint
|
||||
double b2;
|
||||
|
||||
switch (type) {
|
||||
case LOWPASS: {
|
||||
case LOW_PASS: { // OK
|
||||
a0 = 1.0 + y;
|
||||
a1 = -2.0 * cosOmega;
|
||||
a2 = 1.0 - y;
|
||||
@ -74,16 +74,16 @@ MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float frequency, uint
|
||||
b2 = (1.0 - cosOmega) / 2.0;
|
||||
break;
|
||||
}
|
||||
case HIGHPASS: {
|
||||
case HIGH_PASS: {
|
||||
a0 = 1.0 + y;
|
||||
a1 = -2.0 * cosOmega;
|
||||
a2 = 1.0 - y;
|
||||
b0 = (1.0 + cosOmega) / 2.0;
|
||||
b1 = -1.0 - cosOmega;
|
||||
b1 = -(1.0 + cosOmega);
|
||||
b2 = (1.0 + cosOmega) / 2.0;
|
||||
break;
|
||||
}
|
||||
case BANDPASS: {
|
||||
case BAND_PASS: {
|
||||
a0 = 1.0 + y;
|
||||
a1 = -2.0 * cosOmega;
|
||||
a2 = 1.0 - y;
|
||||
@ -92,7 +92,7 @@ MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float frequency, uint
|
||||
b2 = -y;
|
||||
break;
|
||||
}
|
||||
case BANDSTOP: {
|
||||
case BAND_STOP: {
|
||||
a0 = 1.0 + y;
|
||||
a1 = -2.0 * cosOmega;
|
||||
a2 = 1.0 - y;
|
||||
@ -101,7 +101,7 @@ MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float frequency, uint
|
||||
b2 = 1.0;
|
||||
break;
|
||||
}
|
||||
case ALLPASS: {
|
||||
case ALL_PASS: {
|
||||
a0 = 1.0 + y;
|
||||
a1 = -2.0 * cosOmega;
|
||||
a2 = 1.0 - y;
|
||||
@ -111,15 +111,15 @@ MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float frequency, uint
|
||||
break;
|
||||
}
|
||||
case PEAK: {
|
||||
a0 = 1.0 + y / (double) gain;
|
||||
a0 = 1.0 + y / gain;
|
||||
a1 = -2.0 * cosOmega;
|
||||
a2 = 1.0 - y / (double) gain;
|
||||
b0 = 1.0 + y * (double) gain;
|
||||
a2 = 1.0 - y / gain;
|
||||
b0 = 1.0 + y * gain;
|
||||
b1 = -2.0 * cosOmega;
|
||||
b2 = 1.0 - y * (double) gain;
|
||||
b2 = 1.0 - y * gain;
|
||||
break;
|
||||
}
|
||||
case LOWSHELF: {
|
||||
case LOW_SHELF: { // TODO: Check me!
|
||||
double tmp1 = (gain + 1.0) - (gain - 1.0) * cosOmega;
|
||||
double tmp2 = (gain + 1.0) + (gain - 1.0) * cosOmega;
|
||||
a1 = ((gain - 1.0) + (gain + 1.0) * cosOmega) * -2.0;
|
||||
@ -130,7 +130,7 @@ MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float frequency, uint
|
||||
b2 = (tmp1 - z) * gain;
|
||||
break;
|
||||
}
|
||||
case HIGHSHELF: {
|
||||
case HIGH_SHELF: { // TODO: Check me!
|
||||
double tmp1 = (gain + 1.0) + (gain - 1.0) * cosOmega;
|
||||
double tmp2 = (gain + 1.0) - (gain - 1.0) * cosOmega;
|
||||
a2 = tmp2 - z;
|
||||
|
@ -5,14 +5,14 @@
|
||||
class MultiBiquad {
|
||||
public:
|
||||
enum FilterType {
|
||||
LOWPASS = 0,
|
||||
HIGHPASS = 1,
|
||||
BANDPASS = 2,
|
||||
BANDSTOP = 3,
|
||||
ALLPASS = 4,
|
||||
PEAK = 5,
|
||||
LOWSHELF = 6,
|
||||
HIGHSHELF = 7
|
||||
LOW_PASS,
|
||||
HIGH_PASS,
|
||||
BAND_PASS,
|
||||
BAND_STOP,
|
||||
ALL_PASS,
|
||||
PEAK,
|
||||
LOW_SHELF,
|
||||
HIGH_SHELF
|
||||
};
|
||||
|
||||
MultiBiquad();
|
||||
|
@ -8,8 +8,8 @@ Subwoofer::Subwoofer() {
|
||||
this->peak[1].RefreshFilter(MultiBiquad::FilterType::PEAK, 0.0, 37.0, samplingRate, 1.0, false);
|
||||
this->peakLow[0].RefreshFilter(MultiBiquad::FilterType::PEAK, 0.0, 75.0, samplingRate, 1.0, false);
|
||||
this->peakLow[1].RefreshFilter(MultiBiquad::FilterType::PEAK, 0.0, 75.0, samplingRate, 1.0, false);
|
||||
this->lowpass[0].RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0, 200.0, samplingRate, 1.0, false);
|
||||
this->lowpass[1].RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0, 200.0, samplingRate, 1.0, false);
|
||||
this->lowpass[0].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, 200.0, samplingRate, 1.0, false);
|
||||
this->lowpass[1].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, 200.0, samplingRate, 1.0, false);
|
||||
}
|
||||
|
||||
void Subwoofer::Process(float *samples, uint32_t size) {
|
||||
@ -31,6 +31,6 @@ void Subwoofer::SetBassGain(uint32_t samplingRate, float gainDb) {
|
||||
this->peak[1].RefreshFilter(MultiBiquad::FilterType::PEAK, gain, 44.0, samplingRate, 0.75, true);
|
||||
this->peakLow[0].RefreshFilter(MultiBiquad::FilterType::PEAK, gainLower, 80.0, samplingRate, 0.2, true);
|
||||
this->peakLow[1].RefreshFilter(MultiBiquad::FilterType::PEAK, gainLower, 80.0, samplingRate, 0.2, true);
|
||||
this->lowpass[0].RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0, 380.0, samplingRate, 0.6, false);
|
||||
this->lowpass[1].RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0, 380.0, samplingRate, 0.6, false);
|
||||
this->lowpass[0].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, 380.0, samplingRate, 0.6, false);
|
||||
this->lowpass[1].RefreshFilter(MultiBiquad::FilterType::LOW_PASS, 0.0, 380.0, samplingRate, 0.6, false);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user