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
55722aa955
commit
e84cd53d79
@ -22,19 +22,15 @@ AnalogX::AnalogX() {
|
||||
Reset();
|
||||
}
|
||||
|
||||
AnalogX::~AnalogX() {
|
||||
|
||||
}
|
||||
|
||||
void AnalogX::Process(float *samples, uint32_t size) {
|
||||
for (int i = 0; i < 2 * size; i++) {
|
||||
for (int i = 0; i < size * 2; i++) {
|
||||
float sample = samples[i];
|
||||
int index = i % 2;
|
||||
int channel = i % 2;
|
||||
|
||||
float tmp = this->highpass[index].ProcessSample(sample);
|
||||
tmp = this->harmonic[index].Process(tmp);
|
||||
float tmp = this->highpass[channel].ProcessSample(sample);
|
||||
tmp = this->harmonic[channel].Process(tmp);
|
||||
|
||||
tmp = this->lowpass[index].ProcessSample(sample + tmp * this->gain);
|
||||
tmp = this->lowpass[channel].ProcessSample(sample + tmp * this->gain);
|
||||
tmp = this->peak->ProcessSample(tmp * 0.8f);
|
||||
|
||||
samples[i] = tmp;
|
||||
@ -42,17 +38,17 @@ void AnalogX::Process(float *samples, uint32_t size) {
|
||||
|
||||
if (this->freqRange < this->samplingRate / 4) {
|
||||
this->freqRange += size;
|
||||
memset(samples, 0, 2 * size * sizeof(float));
|
||||
memset(samples, 0, size * 2 * sizeof(float));
|
||||
}
|
||||
}
|
||||
|
||||
void AnalogX::Reset() {
|
||||
for (auto &highpass : this->highpass) {
|
||||
highpass.RefreshFilter(MultiBiquad::FilterType::HIGHPASS, 0.0f, 240.0f, (float) this->samplingRate, 0.717f, false);
|
||||
highpass.RefreshFilter(MultiBiquad::FilterType::HIGHPASS, 0.0f, 240.0f, this->samplingRate, 0.717f, false);
|
||||
}
|
||||
|
||||
for (auto &peak : this->peak) {
|
||||
peak.RefreshFilter(MultiBiquad::FilterType::PEAK, 0.58f, 633.0f, (float) this->samplingRate, 6.28f, true);
|
||||
peak.RefreshFilter(MultiBiquad::FilterType::PEAK, 0.58f, 633.0f, this->samplingRate, 6.28f, true);
|
||||
}
|
||||
|
||||
for (auto &harmonic : this->harmonic) {
|
||||
@ -67,7 +63,7 @@ void AnalogX::Reset() {
|
||||
this->gain = 0.6f;
|
||||
|
||||
for (auto &lowpass : this->lowpass) {
|
||||
lowpass.RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0f, 19650.0f, (float) this->samplingRate, 0.717f, false);
|
||||
lowpass.RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0f, 19650.0f, this->samplingRate, 0.717f, false);
|
||||
}
|
||||
} else if (this->processingModel == 1) {
|
||||
for (auto &harmonic : this->harmonic) {
|
||||
@ -77,7 +73,7 @@ void AnalogX::Reset() {
|
||||
this->gain = 1.2f;
|
||||
|
||||
for (auto &lowpass : this->lowpass) {
|
||||
lowpass.RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0f, 18233.0f, (float) this->samplingRate, 0.717f, false);
|
||||
lowpass.RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0f, 18233.0f, this->samplingRate, 0.717f, false);
|
||||
}
|
||||
} else if (this->processingModel == 2) {
|
||||
for (auto &harmonic : this->harmonic) {
|
||||
@ -87,7 +83,7 @@ void AnalogX::Reset() {
|
||||
this->gain = 2.4f;
|
||||
|
||||
for (auto &lowpass : this->lowpass) {
|
||||
lowpass.RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0f, 16307.0f, (float) this->samplingRate, 0.717f, false);
|
||||
lowpass.RefreshFilter(MultiBiquad::FilterType::LOWPASS, 0.0f, 16307.0f, this->samplingRate, 0.717f, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
class AnalogX {
|
||||
public:
|
||||
AnalogX();
|
||||
~AnalogX();
|
||||
|
||||
void Process(float *samples, uint32_t size);
|
||||
void Reset();
|
||||
|
@ -20,10 +20,6 @@ IIRFilter::IIRFilter(uint32_t bands) {
|
||||
this->Reset();
|
||||
}
|
||||
|
||||
IIRFilter::~IIRFilter() {
|
||||
|
||||
}
|
||||
|
||||
void IIRFilter::Process(float *samples, uint32_t size) {
|
||||
if (!this->enable) return;
|
||||
|
||||
@ -32,9 +28,20 @@ void IIRFilter::Process(float *samples, uint32_t size) {
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
for (uint32_t j = 0; j < 2; j++) {
|
||||
float sample = samples[i * 2 + j];
|
||||
float tmp = 0.0;
|
||||
for (uint32_t k = 0; k < this->bands * 16; k++) {
|
||||
samples[2 * i + j];
|
||||
for (uint32_t k = 0; k < this->bands; k++) {
|
||||
uint32_t bufIdx = this->unknown2 + j * 8 + k * 16;
|
||||
this->buf[bufIdx] = sample;
|
||||
|
||||
float coeff1 = coeffs[k * 4];
|
||||
float coeff2 = coeffs[k * 4 + 1];
|
||||
float coeff3 = coeffs[k * 4 + 2];
|
||||
|
||||
float tmp2 = ((coeff3 * this->buf[bufIdx + ((this->unknown3 + 3) - this->unknown2)] + (sample - this->buf[bufIdx + (unknown4 - unknown2)]) * coeff2) - coeff1 * this->buf[bufIdx + ((unknown4 - unknown2) + 3)]);
|
||||
|
||||
this->buf[bufIdx + 3] = tmp2;
|
||||
tmp += tmp2 * this->bandLevelsWithQ[k];
|
||||
}
|
||||
|
||||
samples[2 * i + j] = tmp;
|
||||
@ -58,16 +65,20 @@ void IIRFilter::SetBandLevel(uint32_t band, float level) {
|
||||
}
|
||||
|
||||
void IIRFilter::SetEnable(bool enable) {
|
||||
this->enable = enable;
|
||||
if (enable) {
|
||||
Reset();
|
||||
if (this->enable != enable) {
|
||||
this->enable = enable;
|
||||
if (enable) {
|
||||
this->Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IIRFilter::SetSamplingRate(uint32_t samplingRate) {
|
||||
this->samplingRate = samplingRate;
|
||||
if (this->bands != 0) {
|
||||
this->minPhaseIirCoeffs.UpdateCoeffs(bands, samplingRate);
|
||||
if (this->samplingRate != samplingRate) {
|
||||
this->samplingRate = samplingRate;
|
||||
if (this->bands != 0) {
|
||||
this->minPhaseIirCoeffs.UpdateCoeffs(this->bands, this->samplingRate);
|
||||
}
|
||||
this->Reset();
|
||||
}
|
||||
this->Reset();
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
class IIRFilter {
|
||||
public:
|
||||
IIRFilter(uint32_t bands);
|
||||
~IIRFilter();
|
||||
|
||||
void Process(float *samples, uint32_t size);
|
||||
void Reset();
|
||||
|
Loading…
x
Reference in New Issue
Block a user