mirror of
https://github.com/AndroidAudioMods/ViPERFX_RE.git
synced 2025-06-08 10:39:29 +08:00
Update
This commit is contained in:
parent
40169a4975
commit
6f78cc7ff3
@ -281,8 +281,7 @@ void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, u
|
|||||||
break;
|
break;
|
||||||
} // 0x1000A
|
} // 0x1000A
|
||||||
case PARAM_DDC_COEFFICIENTS: {
|
case PARAM_DDC_COEFFICIENTS: {
|
||||||
// TODO: Finish
|
this->viperDdc->SetCoeffs(arrSize, (float *) arr, (float *) (arr + arrSize * 4));
|
||||||
//this->viperDdc->SetCoeffs();
|
|
||||||
break;
|
break;
|
||||||
} // 0x1000B
|
} // 0x1000B
|
||||||
case PARAM_SPECTRUM_EXTENSION_ENABLE: {
|
case PARAM_SPECTRUM_EXTENSION_ENABLE: {
|
||||||
@ -302,7 +301,7 @@ void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, u
|
|||||||
break;
|
break;
|
||||||
} // 0x1000F
|
} // 0x1000F
|
||||||
case PARAM_FIR_EQUALIZER_BAND_LEVEL: {
|
case PARAM_FIR_EQUALIZER_BAND_LEVEL: {
|
||||||
this->iirFilter->SetBandLevel(val1, (float) val2 / 100.0f);
|
this->iirFilter->SetBandLevel((uint32_t) val1, (float) val2 / 100.0f);
|
||||||
break;
|
break;
|
||||||
} // 0x10010
|
} // 0x10010
|
||||||
case PARAM_FIELD_SURROUND_ENABLE: {
|
case PARAM_FIELD_SURROUND_ENABLE: {
|
||||||
@ -398,7 +397,7 @@ void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, u
|
|||||||
break;
|
break;
|
||||||
} // 0x10027
|
} // 0x10027
|
||||||
case PARAM_FIDELITY_BASS_FREQUENCY: {
|
case PARAM_FIDELITY_BASS_FREQUENCY: {
|
||||||
this->viperBass->SetSpeaker(val1);
|
this->viperBass->SetSpeaker((uint32_t) val1);
|
||||||
break;
|
break;
|
||||||
} // 0x10028
|
} // 0x10028
|
||||||
case PARAM_FIDELITY_BASS_GAIN: {
|
case PARAM_FIDELITY_BASS_GAIN: {
|
||||||
|
@ -7,16 +7,16 @@ ViPERDDC::ViPERDDC() {
|
|||||||
this->samplingRate = 44100;
|
this->samplingRate = 44100;
|
||||||
this->setCoeffsOk = false;
|
this->setCoeffsOk = false;
|
||||||
this->arrSize = 0;
|
this->arrSize = 0;
|
||||||
this->arrPtr44100 = nullptr;
|
this->coeffsArr44100 = nullptr;
|
||||||
this->arrPtr48000 = nullptr;
|
this->coeffsArr48000 = nullptr;
|
||||||
this->arr4 = nullptr;
|
this->x2R = nullptr;
|
||||||
this->arr3 = nullptr;
|
this->x2L = nullptr;
|
||||||
this->arr2 = nullptr;
|
this->x1R = nullptr;
|
||||||
this->arr1 = nullptr;
|
this->x1L = nullptr;
|
||||||
this->arr8 = nullptr;
|
this->y2R = nullptr;
|
||||||
this->arr7 = nullptr;
|
this->y2L = nullptr;
|
||||||
this->arr6 = nullptr;
|
this->y1R = nullptr;
|
||||||
this->arr5 = nullptr;
|
this->y1L = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ViPERDDC::~ViPERDDC() {
|
ViPERDDC::~ViPERDDC() {
|
||||||
@ -27,54 +27,118 @@ void ViPERDDC::Process(float *samples, uint32_t size) {
|
|||||||
if (!this->setCoeffsOk) return;
|
if (!this->setCoeffsOk) return;
|
||||||
if (!this->enable) return;
|
if (!this->enable) return;
|
||||||
|
|
||||||
|
float **coeffsArr;
|
||||||
|
|
||||||
switch (this->samplingRate) {
|
switch (this->samplingRate) {
|
||||||
case 44100: {
|
case 44100: {
|
||||||
|
coeffsArr = this->coeffsArr44100;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 48000: {
|
case 48000: {
|
||||||
|
coeffsArr = this->coeffsArr48000;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
VIPER_LOGD("ViPERDDC::Process() -> Invalid sampling rate: %d", this->samplingRate);
|
VIPER_LOGD("ViPERDDC::Process() -> Invalid sampling rate: %d", this->samplingRate);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < size * 2; i += 2) {
|
||||||
|
if (this->arrSize == 0) {
|
||||||
|
samples[i] = 0.0;
|
||||||
|
samples[i + 1] = 0.0;
|
||||||
|
} else {
|
||||||
|
float sample = samples[i];
|
||||||
|
for (uint32_t j = 0; j < this->arrSize; j++) {
|
||||||
|
float *coeffs = coeffsArr[j];
|
||||||
|
|
||||||
|
float b0 = coeffs[0];
|
||||||
|
float b1 = coeffs[1];
|
||||||
|
float b2 = coeffs[2];
|
||||||
|
float a1 = coeffs[3];
|
||||||
|
float a2 = coeffs[4];
|
||||||
|
|
||||||
|
float out =
|
||||||
|
sample * b0 +
|
||||||
|
x1L[j] * b1 +
|
||||||
|
x2L[j] * b2 +
|
||||||
|
y1L[j] * a1 +
|
||||||
|
y2L[j] * a2;
|
||||||
|
|
||||||
|
x2L[j] = x1L[j];
|
||||||
|
x1L[j] = sample;
|
||||||
|
y2L[j] = y1L[j];
|
||||||
|
y1L[j] = out;
|
||||||
|
|
||||||
|
sample = out;
|
||||||
|
}
|
||||||
|
samples[i] = sample;
|
||||||
|
|
||||||
|
sample = samples[i + 1];
|
||||||
|
for (uint32_t j = 0; j < this->arrSize; j++) {
|
||||||
|
float *coeffs = coeffsArr[j];
|
||||||
|
|
||||||
|
float b0 = coeffs[0];
|
||||||
|
float b1 = coeffs[1];
|
||||||
|
float b2 = coeffs[2];
|
||||||
|
float a1 = coeffs[3];
|
||||||
|
float a2 = coeffs[4];
|
||||||
|
|
||||||
|
float out =
|
||||||
|
sample * b0 +
|
||||||
|
x1R[j] * b1 +
|
||||||
|
x2R[j] * b2 +
|
||||||
|
y1R[j] * a1 +
|
||||||
|
y2R[j] * a2;
|
||||||
|
|
||||||
|
x2R[j] = x1R[j];
|
||||||
|
x1R[j] = sample;
|
||||||
|
y2R[j] = y1R[j];
|
||||||
|
y1R[j] = out;
|
||||||
|
|
||||||
|
sample = out;
|
||||||
|
}
|
||||||
|
samples[i + 1] = sample;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViPERDDC::ReleaseResources() {
|
void ViPERDDC::ReleaseResources() {
|
||||||
for (uint32_t i = 0; i < this->arrSize; i++) {
|
for (uint32_t i = 0; i < this->arrSize; i++) {
|
||||||
delete[] this->arrPtr44100[i];
|
delete[] this->coeffsArr44100[i];
|
||||||
delete[] this->arrPtr48000[i];
|
delete[] this->coeffsArr48000[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] this->arrPtr44100;
|
delete[] this->coeffsArr44100;
|
||||||
this->arrPtr44100 = nullptr;
|
this->coeffsArr44100 = nullptr;
|
||||||
|
|
||||||
delete[] this->arrPtr48000;
|
delete[] this->coeffsArr48000;
|
||||||
this->arrPtr48000 = nullptr;
|
this->coeffsArr48000 = nullptr;
|
||||||
|
|
||||||
delete[] this->arr1;
|
delete[] this->x1L;
|
||||||
this->arr1 = nullptr;
|
this->x1L = nullptr;
|
||||||
|
|
||||||
delete[] this->arr2;
|
delete[] this->x1R;
|
||||||
this->arr2 = nullptr;
|
this->x1R = nullptr;
|
||||||
|
|
||||||
delete[] this->arr3;
|
delete[] this->x2L;
|
||||||
this->arr3 = nullptr;
|
this->x2L = nullptr;
|
||||||
|
|
||||||
delete[] this->arr4;
|
delete[] this->x2R;
|
||||||
this->arr4 = nullptr;
|
this->x2R = nullptr;
|
||||||
|
|
||||||
delete[] this->arr5;
|
delete[] this->y1L;
|
||||||
this->arr5 = nullptr;
|
this->y1L = nullptr;
|
||||||
|
|
||||||
delete[] this->arr6;
|
delete[] this->y1R;
|
||||||
this->arr6 = nullptr;
|
this->y1R = nullptr;
|
||||||
|
|
||||||
delete[] this->arr7;
|
delete[] this->y2L;
|
||||||
this->arr7 = nullptr;
|
this->y2L = nullptr;
|
||||||
|
|
||||||
delete[] this->arr8;
|
delete[] this->y2R;
|
||||||
this->arr8 = nullptr;
|
this->y2R = nullptr;
|
||||||
|
|
||||||
this->setCoeffsOk = false;
|
this->setCoeffsOk = false;
|
||||||
}
|
}
|
||||||
@ -83,8 +147,8 @@ void ViPERDDC::Reset() {
|
|||||||
if (!this->setCoeffsOk) return;
|
if (!this->setCoeffsOk) return;
|
||||||
if (this->arrSize == 0) return;
|
if (this->arrSize == 0) return;
|
||||||
|
|
||||||
memset(this->arr1, 0, this->arrSize * 4);
|
memset(this->x1L, 0, this->arrSize * 4);
|
||||||
memset(this->arr2, 0, this->arrSize * 4);
|
memset(this->x1R, 0, this->arrSize * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViPERDDC::SetCoeffs(uint32_t param_1, float *param_2, float *param_3) {
|
void ViPERDDC::SetCoeffs(uint32_t param_1, float *param_2, float *param_3) {
|
||||||
@ -93,33 +157,33 @@ void ViPERDDC::SetCoeffs(uint32_t param_1, float *param_2, float *param_3) {
|
|||||||
if (param_1 == 0) return;
|
if (param_1 == 0) return;
|
||||||
|
|
||||||
this->arrSize = param_1 / 5;
|
this->arrSize = param_1 / 5;
|
||||||
this->arrPtr44100 = new float *[this->arrSize]();
|
this->coeffsArr44100 = new float *[this->arrSize]();
|
||||||
this->arrPtr48000 = new float *[this->arrSize]();
|
this->coeffsArr48000 = new float *[this->arrSize]();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < this->arrSize; i++) {
|
for (uint32_t i = 0; i < this->arrSize; i++) {
|
||||||
this->arrPtr44100[i] = new float[5];
|
this->coeffsArr44100[i] = new float[5];
|
||||||
this->arrPtr44100[i][0] = param_2[i * 5];
|
this->coeffsArr44100[i][0] = param_2[i * 5];
|
||||||
this->arrPtr44100[i][1] = param_2[i * 5 + 1];
|
this->coeffsArr44100[i][1] = param_2[i * 5 + 1];
|
||||||
this->arrPtr44100[i][2] = param_2[i * 5 + 2];
|
this->coeffsArr44100[i][2] = param_2[i * 5 + 2];
|
||||||
this->arrPtr44100[i][3] = param_2[i * 5 + 3];
|
this->coeffsArr44100[i][3] = param_2[i * 5 + 3];
|
||||||
this->arrPtr44100[i][4] = param_2[i * 5 + 4];
|
this->coeffsArr44100[i][4] = param_2[i * 5 + 4];
|
||||||
|
|
||||||
this->arrPtr48000[i] = new float[5];
|
this->coeffsArr48000[i] = new float[5];
|
||||||
this->arrPtr48000[i][0] = param_3[i * 5];
|
this->coeffsArr48000[i][0] = param_3[i * 5];
|
||||||
this->arrPtr48000[i][1] = param_3[i * 5 + 1];
|
this->coeffsArr48000[i][1] = param_3[i * 5 + 1];
|
||||||
this->arrPtr48000[i][2] = param_3[i * 5 + 2];
|
this->coeffsArr48000[i][2] = param_3[i * 5 + 2];
|
||||||
this->arrPtr48000[i][3] = param_3[i * 5 + 3];
|
this->coeffsArr48000[i][3] = param_3[i * 5 + 3];
|
||||||
this->arrPtr48000[i][4] = param_3[i * 5 + 4];
|
this->coeffsArr48000[i][4] = param_3[i * 5 + 4];
|
||||||
}
|
}
|
||||||
|
|
||||||
this->arr1 = new float[this->arrSize]();
|
this->x1L = new float[this->arrSize]();
|
||||||
this->arr2 = new float[this->arrSize]();
|
this->x1R = new float[this->arrSize]();
|
||||||
this->arr3 = new float[this->arrSize]();
|
this->x2L = new float[this->arrSize]();
|
||||||
this->arr4 = new float[this->arrSize]();
|
this->x2R = new float[this->arrSize]();
|
||||||
this->arr5 = new float[this->arrSize]();
|
this->y1L = new float[this->arrSize]();
|
||||||
this->arr6 = new float[this->arrSize]();
|
this->y1R = new float[this->arrSize]();
|
||||||
this->arr7 = new float[this->arrSize]();
|
this->y2L = new float[this->arrSize]();
|
||||||
this->arr8 = new float[this->arrSize]();
|
this->y2R = new float[this->arrSize]();
|
||||||
this->setCoeffsOk = true;
|
this->setCoeffsOk = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,16 +19,16 @@ private:
|
|||||||
bool setCoeffsOk;
|
bool setCoeffsOk;
|
||||||
uint32_t samplingRate;
|
uint32_t samplingRate;
|
||||||
uint32_t arrSize;
|
uint32_t arrSize;
|
||||||
float **arrPtr44100;
|
float **coeffsArr44100;
|
||||||
float **arrPtr48000;
|
float **coeffsArr48000;
|
||||||
float *arr1;
|
float *x1L;
|
||||||
float *arr2;
|
float *x1R;
|
||||||
float *arr3;
|
float *x2L;
|
||||||
float *arr4;
|
float *x2R;
|
||||||
float *arr5;
|
float *y1L;
|
||||||
float *arr6;
|
float *y1R;
|
||||||
float *arr7;
|
float *y2L;
|
||||||
float *arr8;
|
float *y2R;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user