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
9e81c8b1d0
commit
420c09be29
@ -28,8 +28,8 @@ void Biquad::Reset() {
|
||||
this->y_2 = 0;
|
||||
}
|
||||
|
||||
void Biquad::SetBandPassParameter(double frequency, double samplingRate, float qFactor) {
|
||||
double x = (2.0 * M_PI * frequency) / samplingRate;
|
||||
void Biquad::SetBandPassParameter(float frequency, uint32_t samplingRate, float qFactor) {
|
||||
double x = (2.0 * M_PI * (double) frequency) / (double) samplingRate;
|
||||
double sinX = sin(x);
|
||||
double cosX = cos(x);
|
||||
double y = sinX / ((double) qFactor * 2.0);
|
||||
@ -56,8 +56,8 @@ void Biquad::SetCoeffs(double a0, double a1, double a2, double b0, double b1, do
|
||||
}
|
||||
|
||||
void
|
||||
Biquad::SetHighPassParameter(double frequency, double samplingRate, double param_4, float qFactor, double param_6) {
|
||||
double x = (2.0 * M_PI * frequency) / samplingRate;
|
||||
Biquad::SetHighPassParameter(float frequency, uint32_t samplingRate, double param_4, float qFactor, double param_6) {
|
||||
double x = (2.0 * M_PI * (double) frequency) / (double) samplingRate;
|
||||
double sinX = sin(x);
|
||||
double cosX = cos(x);
|
||||
|
||||
@ -81,8 +81,8 @@ Biquad::SetHighPassParameter(double frequency, double samplingRate, double param
|
||||
this->SetCoeffs(a0, a1, a2, b0, b1, b2);
|
||||
}
|
||||
|
||||
void Biquad::SetLowPassParameter(double frequency, double samplingRate, float qFactor) {
|
||||
double x = (2.0 * M_PI * frequency) / samplingRate;
|
||||
void Biquad::SetLowPassParameter(float frequency, uint32_t samplingRate, float qFactor) {
|
||||
double x = (2.0 * M_PI * (double) frequency) / (double) samplingRate;
|
||||
double sinX = sin(x);
|
||||
double y = sinX / ((double) qFactor * 2.0);
|
||||
double cosX = cos(x);
|
||||
|
@ -8,10 +8,10 @@ public:
|
||||
|
||||
double ProcessSample(double sample);
|
||||
void Reset();
|
||||
void SetBandPassParameter(double frequency, double samplingRate, float qFactor);
|
||||
void SetBandPassParameter(float frequency, uint32_t samplingRate, float qFactor);
|
||||
void SetCoeffs(double a0, double a1, double a2, double b0, double b1, double b2);
|
||||
void SetHighPassParameter(double frequency, double samplingRate, double param_4, float qFactor, double param_6);
|
||||
void SetLowPassParameter(double frequency, double samplingRate, float qFactor);
|
||||
void SetHighPassParameter(float frequency, uint32_t samplingRate, double param_4, float qFactor, double param_6);
|
||||
void SetLowPassParameter(float frequency, uint32_t samplingRate, float qFactor);
|
||||
|
||||
private:
|
||||
double x_1;
|
||||
|
@ -24,7 +24,70 @@ double MultiBiquad::ProcessSample(double sample) {
|
||||
}
|
||||
|
||||
void
|
||||
MultiBiquad::RefreshFilter(FilterType type, double gainAmp, double freq, double samplingRate, double qFactor, bool param_7) {
|
||||
MultiBiquad::RefreshFilter(FilterType type, float gainAmp, float frequency, uint32_t samplingRate, float qFactor, bool param_7) {
|
||||
float gain;
|
||||
|
||||
if (type - 5 < 3) { // type - 5 < 3 is always true... right?
|
||||
gain = pow(10.0f, gainAmp / 40.0f);
|
||||
} else {
|
||||
gain = pow(10.0f, gainAmp / 20.0f);
|
||||
}
|
||||
|
||||
double x = (2.0 * M_PI * (double) frequency) / (double) samplingRate;
|
||||
double sinX = sin(x);
|
||||
double cosX = cos(x);
|
||||
|
||||
double y;
|
||||
double z;
|
||||
|
||||
if (type - 6 < 2) {
|
||||
y = sinX / 2.0 * sqrt((1.0 / ((double) gain * 2.0)) * (1.0 / (double) qFactor - 1.0) + 2.0);
|
||||
z = sqrt((double) gain) * y;
|
||||
} else if (!param_7) {
|
||||
y = sinX / ((double) qFactor / 2.0);
|
||||
z = -1.0;
|
||||
} else {
|
||||
y = sinh(((double) qFactor * (log(2) / 2.0) * x) / sinX);
|
||||
z = -1.0;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case LOWPASS: {
|
||||
|
||||
break;
|
||||
}
|
||||
case HIGHPASS: {
|
||||
|
||||
break;
|
||||
}
|
||||
case BANDPASS: {
|
||||
|
||||
break;
|
||||
}
|
||||
case BANDSTOP: {
|
||||
|
||||
break;
|
||||
}
|
||||
case ALLPASS: {
|
||||
|
||||
break;
|
||||
}
|
||||
case PEAK: {
|
||||
|
||||
break;
|
||||
}
|
||||
case LOWSHELF: {
|
||||
|
||||
break;
|
||||
}
|
||||
case HIGHSHELF: {
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool uVar1;
|
||||
double dVar4;
|
||||
double dVar5;
|
||||
@ -42,7 +105,7 @@ MultiBiquad::RefreshFilter(FilterType type, double gainAmp, double freq, double
|
||||
double b2;
|
||||
|
||||
dVar10 = pow(10.0, gainAmp / 40.0);
|
||||
dVar4 = (freq * 2 * M_PI) / samplingRate;
|
||||
dVar4 = (frequency * 2 * M_PI) / samplingRate;
|
||||
dVar5 = sin(dVar4);
|
||||
dVar11 = cos(dVar4);
|
||||
uVar1 = type == HIGHSHELF;
|
||||
|
@ -1,14 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
enum FilterType {
|
||||
LOWPASS,
|
||||
HIGHPASS,
|
||||
BANDPASS,
|
||||
BANDSTOP,
|
||||
ALLPASS,
|
||||
PEAK,
|
||||
LOWSHELF,
|
||||
HIGHSHELF
|
||||
LOWPASS = 0,
|
||||
HIGHPASS = 1,
|
||||
BANDPASS = 2,
|
||||
BANDSTOP = 3,
|
||||
ALLPASS = 4,
|
||||
PEAK = 5,
|
||||
LOWSHELF = 6,
|
||||
HIGHSHELF = 7
|
||||
};
|
||||
|
||||
class MultiBiquad {
|
||||
@ -16,11 +16,18 @@ public:
|
||||
MultiBiquad();
|
||||
|
||||
double ProcessSample(double sample);
|
||||
void RefreshFilter(FilterType type, float gainAmp, float frequency, uint32_t samplingRate, float qFactor, bool param_7);
|
||||
|
||||
void RefreshFilter(FilterType type, double gainAmp, double freq, double samplingRate, double qFactor, bool param_7);
|
||||
|
||||
double y_2, y_1, x_2, x_1;
|
||||
double b0, b1, b2, a1, a2;
|
||||
private:
|
||||
double x_1;
|
||||
double x_2;
|
||||
double y_1;
|
||||
double y_2;
|
||||
double a1;
|
||||
double a2;
|
||||
double b0;
|
||||
double b1;
|
||||
double b2;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include "WaveBuffer.h"
|
||||
#include "FIR.h"
|
||||
#include "WaveBuffer.h"
|
||||
|
||||
class Polyphase {
|
||||
public:
|
||||
|
@ -19,18 +19,18 @@ void Subwoofer::Process(float *samples, uint32_t size) {
|
||||
double tmp = this->peak[index].ProcessSample(sample);
|
||||
tmp = this->peakLow[index].ProcessSample(tmp);
|
||||
tmp = this->lowpass[index].ProcessSample(tmp - sample);
|
||||
samples[i] = (float) ((sample / 2.0) + (tmp * 0.6f));
|
||||
samples[i] = (float) ((sample / 2.0) + (tmp * 0.6));
|
||||
}
|
||||
}
|
||||
|
||||
void Subwoofer::SetBassGain(uint32_t samplerate, float gainDb) {
|
||||
double gain = 20.0 * log10( gainDb);
|
||||
double gainLower = 20.0 * log10( gainDb / 8.0);
|
||||
void Subwoofer::SetBassGain(uint32_t samplingRate, float gainDb) {
|
||||
float gain = 20.0f * log10( gainDb);
|
||||
float gainLower = 20.0f * log10( gainDb / 8.0f);
|
||||
|
||||
this->peak[0].RefreshFilter(FilterType::PEAK, gain, 44.0, (double) samplerate, 0.75, true);
|
||||
this->peak[1].RefreshFilter(FilterType::PEAK, gain, 44.0, (double) samplerate, 0.75, true);
|
||||
this->peakLow[0].RefreshFilter(FilterType::PEAK, gainLower, 80.0, (double) samplerate, 0.2, true);
|
||||
this->peakLow[1].RefreshFilter(FilterType::PEAK, gainLower, 80.0, (double) samplerate, 0.2, true);
|
||||
this->lowpass[0].RefreshFilter(FilterType::LOWPASS, 0.0, 380.0, (double) samplerate, 0.6, false);
|
||||
this->lowpass[1].RefreshFilter(FilterType::LOWPASS, 0.0, 380.0, (double) samplerate, 0.6, false);
|
||||
this->peak[0].RefreshFilter(FilterType::PEAK, gain, 44.0, (double) samplingRate, 0.75, true);
|
||||
this->peak[1].RefreshFilter(FilterType::PEAK, gain, 44.0, (double) samplingRate, 0.75, true);
|
||||
this->peakLow[0].RefreshFilter(FilterType::PEAK, gainLower, 80.0, (double) samplingRate, 0.2, true);
|
||||
this->peakLow[1].RefreshFilter(FilterType::PEAK, gainLower, 80.0, (double) samplingRate, 0.2, true);
|
||||
this->lowpass[0].RefreshFilter(FilterType::LOWPASS, 0.0, 380.0, (double) samplingRate, 0.6, false);
|
||||
this->lowpass[1].RefreshFilter(FilterType::LOWPASS, 0.0, 380.0, (double) samplingRate, 0.6, false);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ public:
|
||||
Subwoofer();
|
||||
|
||||
void Process(float *samples, uint32_t size);
|
||||
void SetBassGain(uint32_t samplerate, float gainDb);
|
||||
void SetBassGain(uint32_t samplingRate, float gainDb);
|
||||
|
||||
private:
|
||||
MultiBiquad peak[2];
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "WaveBuffer.h"
|
||||
#include <cstring>
|
||||
|
||||
WaveBuffer::WaveBuffer(int channels, uint32_t size) {
|
||||
WaveBuffer::WaveBuffer(uint32_t channels, uint32_t size) {
|
||||
this->channels = channels;
|
||||
this->size = size * channels;
|
||||
this->index = 0;
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
class WaveBuffer {
|
||||
public:
|
||||
WaveBuffer(int channels, uint32_t size);
|
||||
WaveBuffer(uint32_t channels, uint32_t size);
|
||||
|
||||
~WaveBuffer();
|
||||
|
||||
@ -24,7 +24,7 @@ private:
|
||||
float *buffer;
|
||||
uint32_t size;
|
||||
uint32_t index;
|
||||
int channels;
|
||||
uint32_t channels;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user