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
36275e8fba
commit
2d185130a4
@ -28,7 +28,6 @@ Effect::Effect() {
|
|||||||
|
|
||||||
Effect::~Effect() {
|
Effect::~Effect() {
|
||||||
delete this->buffer;
|
delete this->buffer;
|
||||||
this->buffer = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Effect::process(audio_buffer_s *in, audio_buffer_s *out) {
|
int32_t Effect::process(audio_buffer_s *in, audio_buffer_s *out) {
|
||||||
|
@ -67,7 +67,6 @@ ViPER::ViPER() {
|
|||||||
this->viperBass->Reset();
|
this->viperBass->Reset();
|
||||||
|
|
||||||
this->viperClarity = new ViPERClarity();
|
this->viperClarity = new ViPERClarity();
|
||||||
this->viperClarity->SetEnable(false);
|
|
||||||
this->viperClarity->SetSamplingRate(this->sampleRate);
|
this->viperClarity->SetSamplingRate(this->sampleRate);
|
||||||
this->viperClarity->Reset();
|
this->viperClarity->Reset();
|
||||||
|
|
||||||
@ -114,65 +113,26 @@ ViPER::ViPER() {
|
|||||||
|
|
||||||
ViPER::~ViPER() {
|
ViPER::~ViPER() {
|
||||||
delete this->adaptiveBuffer;
|
delete this->adaptiveBuffer;
|
||||||
this->adaptiveBuffer = nullptr;
|
|
||||||
|
|
||||||
delete this->waveBuffer;
|
delete this->waveBuffer;
|
||||||
this->waveBuffer = nullptr;
|
|
||||||
|
|
||||||
delete this->convolver;
|
delete this->convolver;
|
||||||
this->convolver = nullptr;
|
|
||||||
|
|
||||||
delete this->vhe;
|
delete this->vhe;
|
||||||
this->vhe = nullptr;
|
|
||||||
|
|
||||||
delete this->viperDdc;
|
delete this->viperDdc;
|
||||||
this->viperDdc = nullptr;
|
|
||||||
|
|
||||||
delete this->spectrumExtend;
|
delete this->spectrumExtend;
|
||||||
this->spectrumExtend = nullptr;
|
|
||||||
|
|
||||||
delete this->iirFilter;
|
delete this->iirFilter;
|
||||||
this->iirFilter = nullptr;
|
|
||||||
|
|
||||||
delete this->colorfulMusic;
|
delete this->colorfulMusic;
|
||||||
this->colorfulMusic = nullptr;
|
|
||||||
|
|
||||||
delete this->reverberation;
|
delete this->reverberation;
|
||||||
this->reverberation = nullptr;
|
|
||||||
|
|
||||||
delete this->playbackGain;
|
delete this->playbackGain;
|
||||||
this->playbackGain = nullptr;
|
|
||||||
|
|
||||||
delete this->fetCompressor;
|
delete this->fetCompressor;
|
||||||
this->fetCompressor = nullptr;
|
|
||||||
|
|
||||||
delete this->dynamicSystem;
|
delete this->dynamicSystem;
|
||||||
this->dynamicSystem = nullptr;
|
|
||||||
|
|
||||||
delete this->viperBass;
|
delete this->viperBass;
|
||||||
this->viperBass = nullptr;
|
|
||||||
|
|
||||||
delete this->viperClarity;
|
delete this->viperClarity;
|
||||||
this->viperClarity = nullptr;
|
|
||||||
|
|
||||||
delete this->diffSurround;
|
delete this->diffSurround;
|
||||||
this->diffSurround = nullptr;
|
|
||||||
|
|
||||||
delete this->cure;
|
delete this->cure;
|
||||||
this->cure = nullptr;
|
|
||||||
|
|
||||||
delete this->tubeSimulator;
|
delete this->tubeSimulator;
|
||||||
this->tubeSimulator = nullptr;
|
|
||||||
|
|
||||||
delete this->analogX;
|
delete this->analogX;
|
||||||
this->analogX = nullptr;
|
|
||||||
|
|
||||||
delete this->speakerCorrection;
|
delete this->speakerCorrection;
|
||||||
this->speakerCorrection = nullptr;
|
|
||||||
|
|
||||||
for (auto &softwareLimiter: this->softwareLimiters) {
|
for (auto &softwareLimiter: this->softwareLimiters) {
|
||||||
delete softwareLimiter;
|
delete softwareLimiter;
|
||||||
softwareLimiter = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ DiffSurround::DiffSurround() {
|
|||||||
DiffSurround::~DiffSurround() {
|
DiffSurround::~DiffSurround() {
|
||||||
for (auto &buffer : this->buffers) {
|
for (auto &buffer : this->buffers) {
|
||||||
delete buffer;
|
delete buffer;
|
||||||
buffer = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,16 +21,9 @@ ViPERBass::ViPERBass() {
|
|||||||
|
|
||||||
ViPERBass::~ViPERBass() {
|
ViPERBass::~ViPERBass() {
|
||||||
delete this->polyphase;
|
delete this->polyphase;
|
||||||
this->polyphase = nullptr;
|
|
||||||
|
|
||||||
delete this->biquad;
|
delete this->biquad;
|
||||||
this->biquad = nullptr;
|
|
||||||
|
|
||||||
delete this->subwoofer;
|
delete this->subwoofer;
|
||||||
this->subwoofer = nullptr;
|
|
||||||
|
|
||||||
delete this->waveBuffer;
|
delete this->waveBuffer;
|
||||||
this->waveBuffer = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViPERBass::Process(float *samples, uint32_t size) {
|
void ViPERBass::Process(float *samples, uint32_t size) {
|
||||||
@ -74,8 +67,9 @@ void ViPERBass::Process(float *samples, uint32_t size) {
|
|||||||
|
|
||||||
if (this->polyphase->Process(samples, size) == size) {
|
if (this->polyphase->Process(samples, size) == size) {
|
||||||
for (uint32_t i = 0; i < size * 2; i += 2) {
|
for (uint32_t i = 0; i < size * 2; i += 2) {
|
||||||
samples[i] += buffer[i / 2] * this->bassFactor;
|
float x = buffer[i / 2] * this->bassFactor;
|
||||||
samples[i + 1] += buffer[i / 2] * this->bassFactor;
|
samples[i] += x;
|
||||||
|
samples[i + 1] += x;
|
||||||
}
|
}
|
||||||
this->waveBuffer->PopSamples(size, true);
|
this->waveBuffer->PopSamples(size, true);
|
||||||
}
|
}
|
||||||
@ -120,7 +114,7 @@ void ViPERBass::SetSamplingRate(uint32_t samplingRate) {
|
|||||||
this->invertedSamplingRate = 1.0f / (float) samplingRate;
|
this->invertedSamplingRate = 1.0f / (float) samplingRate;
|
||||||
this->polyphase->SetSamplingRate(samplingRate);
|
this->polyphase->SetSamplingRate(samplingRate);
|
||||||
this->biquad->SetLowPassParameter(this->speaker, samplingRate, 0.53);
|
this->biquad->SetLowPassParameter(this->speaker, samplingRate, 0.53);
|
||||||
this->subwoofer->SetBassGain(samplingRate, this->bassFactor * 2.5);
|
this->subwoofer->SetBassGain(samplingRate, this->bassFactor * 2.5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,30 +2,27 @@
|
|||||||
#include "../constants.h"
|
#include "../constants.h"
|
||||||
|
|
||||||
ViPERClarity::ViPERClarity() {
|
ViPERClarity::ViPERClarity() {
|
||||||
for (int i = 0; i < 2; i++) {
|
for (auto &highShelf : this->highShelf) {
|
||||||
this->hiShelf[i].SetFrequency(12000.f);
|
highShelf.SetFrequency(12000.0);
|
||||||
// this->hiShelf[i].SetQuality(100.f);
|
highShelf.SetGain(1.0);
|
||||||
this->hiShelf[i].SetGain(1.f);
|
highShelf.SetSamplingRate(DEFAULT_SAMPLERATE);
|
||||||
this->hiShelf[i].SetSamplingRate(DEFAULT_SAMPLERATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->enabled = false;
|
|
||||||
this->processMode = ClarityMode::NATURAL;
|
this->processMode = ClarityMode::NATURAL;
|
||||||
this->clarityGainPercent = 0.f;
|
this->samplingRate = DEFAULT_SAMPLERATE;
|
||||||
this->samplerate = DEFAULT_SAMPLERATE;
|
this->clarityGainPercent = 0.0;
|
||||||
Reset();
|
this->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViPERClarity::Process(float *samples, uint32_t size) {
|
void ViPERClarity::Process(float *samples, uint32_t size) {
|
||||||
if (this->enabled) {
|
|
||||||
switch (this->processMode) {
|
switch (this->processMode) {
|
||||||
case ClarityMode::NATURAL: {
|
case ClarityMode::NATURAL: {
|
||||||
this->sharp.Process(samples, size);
|
this->noiseSharpening.Process(samples, size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ClarityMode::OZONE: {
|
case ClarityMode::OZONE: {
|
||||||
for (int i = 0; i < size * 2; i++) {
|
for (int i = 0; i < size * 2; i++) {
|
||||||
samples[i] = this->hiShelf[i % 2].Process(samples[i]);
|
samples[i] = (float) this->highShelf[i % 2].Process(samples[i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -34,55 +31,46 @@ void ViPERClarity::Process(float *samples, uint32_t size) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViPERClarity::Reset() {
|
void ViPERClarity::Reset() {
|
||||||
this->sharp.SetSamplingRate(this->samplerate);
|
this->noiseSharpening.SetSamplingRate(this->samplingRate);
|
||||||
this->sharp.Reset();
|
this->noiseSharpening.Reset();
|
||||||
SetClarityToFilter();
|
this->SetClarityToFilter();
|
||||||
for (int i = 0; i < 2; i++) {
|
for (auto &highShelf : this->highShelf) {
|
||||||
this->hiShelf[i].SetFrequency(8250.f);
|
highShelf.SetFrequency(8250.0);
|
||||||
// this->hiShelf[i].SetQuality(100.f);
|
highShelf.SetSamplingRate(this->samplingRate);
|
||||||
this->hiShelf[i].SetSamplingRate(DEFAULT_SAMPLERATE);
|
|
||||||
}
|
}
|
||||||
this->hifi.SetSamplingRate(this->samplerate);
|
this->hifi.SetSamplingRate(this->samplingRate);
|
||||||
this->hifi.Reset();
|
this->hifi.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViPERClarity::SetClarity(float gainPercent) {
|
void ViPERClarity::SetClarity(float gainPercent) {
|
||||||
this->clarityGainPercent = gainPercent;
|
this->clarityGainPercent = gainPercent;
|
||||||
if (this->processMode != ClarityMode::OZONE) {
|
if (this->processMode != ClarityMode::OZONE) {
|
||||||
SetClarityToFilter();
|
this->SetClarityToFilter();
|
||||||
} else {
|
} else {
|
||||||
Reset();
|
this->Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViPERClarity::SetClarityToFilter() {
|
void ViPERClarity::SetClarityToFilter() {
|
||||||
this->sharp.SetGain(this->clarityGainPercent);
|
this->noiseSharpening.SetGain(this->clarityGainPercent);
|
||||||
this->hiShelf[0].SetGain(this->clarityGainPercent + 1.f);
|
this->highShelf[0].SetGain(this->clarityGainPercent + 1.0f);
|
||||||
this->hiShelf[1].SetGain(this->clarityGainPercent + 1.f);
|
this->highShelf[1].SetGain(this->clarityGainPercent + 1.0f);
|
||||||
this->hifi.SetClarity(this->clarityGainPercent + 1.f);
|
this->hifi.SetClarity(this->clarityGainPercent + 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViPERClarity::SetEnable(bool enabled) {
|
void ViPERClarity::SetProcessMode(ClarityMode processMode) {
|
||||||
this->enabled = enabled;
|
if (this->processMode != processMode) {
|
||||||
if (this->enabled) {
|
this->processMode = processMode;
|
||||||
Reset();
|
this->Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViPERClarity::SetProcessMode(ClarityMode mode) {
|
void ViPERClarity::SetSamplingRate(uint32_t samplingRate) {
|
||||||
this->processMode = mode;
|
if (this->samplingRate != samplingRate) {
|
||||||
Reset();
|
this->samplingRate = samplingRate;
|
||||||
}
|
this->Reset();
|
||||||
|
}
|
||||||
void ViPERClarity::SetSamplingRate(uint32_t samplerate) {
|
|
||||||
this->samplerate = samplerate;
|
|
||||||
Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
ViPERClarity::~ViPERClarity() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,31 +5,29 @@
|
|||||||
#include "../utils/HiFi.h"
|
#include "../utils/HiFi.h"
|
||||||
#include "../utils/HighShelf.h"
|
#include "../utils/HighShelf.h"
|
||||||
|
|
||||||
enum ClarityMode {
|
class ViPERClarity {
|
||||||
|
public:
|
||||||
|
enum ClarityMode {
|
||||||
NATURAL,
|
NATURAL,
|
||||||
OZONE,
|
OZONE,
|
||||||
XHIFI
|
XHIFI
|
||||||
};
|
};
|
||||||
|
|
||||||
class ViPERClarity {
|
|
||||||
public:
|
|
||||||
ViPERClarity();
|
ViPERClarity();
|
||||||
~ViPERClarity();
|
|
||||||
|
|
||||||
void Process(float *samples, uint32_t size);
|
void Process(float *samples, uint32_t size);
|
||||||
void Reset();
|
void Reset();
|
||||||
void SetClarity(float gainPercent);
|
void SetClarity(float gainPercent);
|
||||||
void SetClarityToFilter();
|
void SetClarityToFilter();
|
||||||
void SetEnable(bool enabled);
|
void SetProcessMode(ClarityMode processMode);
|
||||||
void SetProcessMode(ClarityMode mode);
|
void SetSamplingRate(uint32_t samplingRate);
|
||||||
void SetSamplingRate(uint32_t samplerate);
|
|
||||||
|
|
||||||
NoiseSharpening sharp;
|
private:
|
||||||
HighShelf hiShelf[2];
|
NoiseSharpening noiseSharpening;
|
||||||
|
HighShelf highShelf[2];
|
||||||
HiFi hifi;
|
HiFi hifi;
|
||||||
bool enabled;
|
|
||||||
ClarityMode processMode;
|
ClarityMode processMode;
|
||||||
uint32_t samplerate;
|
uint32_t samplingRate;
|
||||||
float clarityGainPercent;
|
float clarityGainPercent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ AdaptiveBuffer::AdaptiveBuffer(uint32_t channels, uint32_t length) {
|
|||||||
|
|
||||||
AdaptiveBuffer::~AdaptiveBuffer() {
|
AdaptiveBuffer::~AdaptiveBuffer() {
|
||||||
delete this->buffer;
|
delete this->buffer;
|
||||||
this->buffer = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdaptiveBuffer::FlushBuffer() {
|
void AdaptiveBuffer::FlushBuffer() {
|
||||||
|
@ -28,11 +28,11 @@ void Biquad::Reset() {
|
|||||||
this->y_2 = 0;
|
this->y_2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Biquad::SetBandPassParameter(double frequency, double samplingRate, double qFactor) {
|
void Biquad::SetBandPassParameter(double frequency, double samplingRate, float qFactor) {
|
||||||
double x = (2.0 * M_PI * frequency) / samplingRate;
|
double x = (2.0 * M_PI * frequency) / samplingRate;
|
||||||
double sinX = sin(x);
|
double sinX = sin(x);
|
||||||
double cosX = cos(x);
|
double cosX = cos(x);
|
||||||
double y = sinX / (2.0 * qFactor);
|
double y = sinX / ((double) qFactor * 2.0);
|
||||||
|
|
||||||
double a0 = 1.0 + y;
|
double a0 = 1.0 + y;
|
||||||
double a1 = -cosX * 2.0;
|
double a1 = -cosX * 2.0;
|
||||||
@ -56,7 +56,7 @@ void Biquad::SetCoeffs(double a0, double a1, double a2, double b0, double b1, do
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Biquad::SetHighPassParameter(double frequency, double samplingRate, double param_4, double qFactor, double param_6) {
|
Biquad::SetHighPassParameter(double frequency, double samplingRate, double param_4, float qFactor, double param_6) {
|
||||||
double x = (2.0 * M_PI * frequency) / samplingRate;
|
double x = (2.0 * M_PI * frequency) / samplingRate;
|
||||||
double sinX = sin(x);
|
double sinX = sin(x);
|
||||||
double cosX = cos(x);
|
double cosX = cos(x);
|
||||||
@ -64,7 +64,7 @@ Biquad::SetHighPassParameter(double frequency, double samplingRate, double param
|
|||||||
double y = pow(10.0, param_4 / 40.0);
|
double y = pow(10.0, param_4 / 40.0);
|
||||||
double sqrtY = sqrt(y);
|
double sqrtY = sqrt(y);
|
||||||
|
|
||||||
double z = sinX / 2.0 * sqrt((1.0 / y + y) * (1.0 / qFactor - 1.0) + 2.0);
|
double z = sinX / 2.0 * sqrt((1.0 / y + y) * (1.0 / (double) qFactor - 1.0) + 2.0);
|
||||||
double a = (y - 1.0) * cosX;
|
double a = (y - 1.0) * cosX;
|
||||||
double b = (y + 1.0) + a;
|
double b = (y + 1.0) + a;
|
||||||
double c = (y + 1.0) * cosX;
|
double c = (y + 1.0) * cosX;
|
||||||
@ -81,10 +81,10 @@ Biquad::SetHighPassParameter(double frequency, double samplingRate, double param
|
|||||||
this->SetCoeffs(a0, a1, a2, b0, b1, b2);
|
this->SetCoeffs(a0, a1, a2, b0, b1, b2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Biquad::SetLowPassParameter(double frequency, double samplingRate, double qFactor) {
|
void Biquad::SetLowPassParameter(double frequency, double samplingRate, float qFactor) {
|
||||||
double x = (2.0 * M_PI * frequency) / samplingRate;
|
double x = (2.0 * M_PI * frequency) / samplingRate;
|
||||||
double sinX = sin(x);
|
double sinX = sin(x);
|
||||||
double y = sinX / (qFactor * 2.0);
|
double y = sinX / ((double) qFactor * 2.0);
|
||||||
double cosX = cos(x);
|
double cosX = cos(x);
|
||||||
double z = 1.0 - cosX;
|
double z = 1.0 - cosX;
|
||||||
|
|
||||||
|
@ -8,10 +8,10 @@ public:
|
|||||||
|
|
||||||
double ProcessSample(double sample);
|
double ProcessSample(double sample);
|
||||||
void Reset();
|
void Reset();
|
||||||
void SetBandPassParameter(double frequency, double samplingRate, double qFactor);
|
void SetBandPassParameter(double frequency, double samplingRate, float qFactor);
|
||||||
void SetCoeffs(double a0, double a1, double a2, double b0, double b1, double b2);
|
void SetCoeffs(double a0, double a1, double a2, double b0, double b1, double b2);
|
||||||
void SetHighPassParameter(double frequency, double samplingRate, double param_4, double qFactor, double param_6);
|
void SetHighPassParameter(double frequency, double samplingRate, double param_4, float qFactor, double param_6);
|
||||||
void SetLowPassParameter(double frequency, double samplingRate, double qFactor);
|
void SetLowPassParameter(double frequency, double samplingRate, float qFactor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double x_1;
|
double x_1;
|
||||||
|
@ -14,7 +14,7 @@ void FIR::FilterSamples(int *samples, uint32_t size) {
|
|||||||
this->FilterSamplesInterleaved(samples, size, 1);
|
this->FilterSamplesInterleaved(samples, size, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FIR::FilterSamplesInterleaved(int *samples, uint32_t size, uint32_t channels) {
|
void FIR::FilterSamplesInterleaved(float *samples, uint32_t size, uint32_t channels) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ int FIR::GetBlockLength() {
|
|||||||
return this->blockLength;
|
return this->blockLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FIR::LoadCoefficients(float *coeffs, uint32_t coeffsize, int blockLength) {
|
int FIR::LoadCoefficients(const float *coeffs, uint32_t coeffsize, int blockLength) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ public:
|
|||||||
~FIR();
|
~FIR();
|
||||||
|
|
||||||
void FilterSamples(int *samples, uint32_t size);
|
void FilterSamples(int *samples, uint32_t size);
|
||||||
void FilterSamplesInterleaved(int *samples, uint32_t size, uint32_t channels);
|
void FilterSamplesInterleaved(float *samples, uint32_t size, uint32_t channels);
|
||||||
int GetBlockLength();
|
int GetBlockLength();
|
||||||
int LoadCoefficients(float *coeffs, uint32_t coeffsize, int blockLength);
|
int LoadCoefficients(const float *coeffs, uint32_t coeffsize, int blockLength);
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -10,16 +10,16 @@ double HighShelf::Process(double sample) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighShelf::SetFrequency(double freq) {
|
void HighShelf::SetFrequency(float freq) {
|
||||||
this->frequency = freq;
|
this->frequency = freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighShelf::SetGain(double gain) {
|
void HighShelf::SetGain(float gain) {
|
||||||
this->gain = log10(gain) * 20.0;
|
this->gain = 20.0 * log10((double) gain);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HighShelf::SetSamplingRate(double samplingRate) {
|
void HighShelf::SetSamplingRate(uint32_t samplingRate) {
|
||||||
double x = (2 * M_PI * this->frequency) / samplingRate;
|
double x = (2 * M_PI * this->frequency) / (double) samplingRate;
|
||||||
double sinX = sin(x);
|
double sinX = sin(x);
|
||||||
double cosX = cos(x);
|
double cosX = cos(x);
|
||||||
double y = exp((this->gain * log(10.0)) / 40.0);
|
double y = exp((this->gain * log(10.0)) / 40.0);
|
||||||
@ -38,7 +38,7 @@ void HighShelf::SetSamplingRate(double samplingRate) {
|
|||||||
double f = (y - 1.0) - d;
|
double f = (y - 1.0) - d;
|
||||||
|
|
||||||
this->a0 = 1.0 / c;
|
this->a0 = 1.0 / c;
|
||||||
this->a1 = a * 2.0;
|
this->a1 = f * 2.0;
|
||||||
this->a2 = b - z;
|
this->a2 = b - z;
|
||||||
this->b0 = (e + z) * y;
|
this->b0 = (e + z) * y;
|
||||||
this->b1 = -y * 2.0 * ((y - 1.0) + d);
|
this->b1 = -y * 2.0 * ((y - 1.0) + d);
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
class HighShelf {
|
class HighShelf {
|
||||||
public:
|
public:
|
||||||
double Process(double sample);
|
double Process(double sample);
|
||||||
void SetFrequency(double freq);
|
void SetFrequency(float freq);
|
||||||
void SetGain(double gain);
|
void SetGain(float gain);
|
||||||
void SetSamplingRate(double samplingRate);
|
void SetSamplingRate(uint32_t samplingRate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double frequency;
|
float frequency;
|
||||||
double gain;
|
double gain;
|
||||||
double x_1;
|
double x_1;
|
||||||
double x_2;
|
double x_2;
|
||||||
|
@ -1,11 +1,161 @@
|
|||||||
#include "Polyphase.h"
|
#include "Polyphase.h"
|
||||||
|
#include "../constants.h"
|
||||||
|
|
||||||
|
static const float POLYPHASE_COEFFICIENTS_2[] = {
|
||||||
|
-0.002339,
|
||||||
|
-0.002073,
|
||||||
|
-0.001940,
|
||||||
|
-0.001675,
|
||||||
|
-0.001515,
|
||||||
|
-0.001329,
|
||||||
|
-0.001223,
|
||||||
|
-0.001037,
|
||||||
|
-0.000904,
|
||||||
|
-0.000851,
|
||||||
|
-0.000532,
|
||||||
|
-0.000851,
|
||||||
|
-0.000106,
|
||||||
|
-0.001010,
|
||||||
|
0.000558,
|
||||||
|
-0.001435,
|
||||||
|
0.001302,
|
||||||
|
-0.001967,
|
||||||
|
0.002259,
|
||||||
|
-0.002605,
|
||||||
|
0.003216,
|
||||||
|
-0.003562,
|
||||||
|
0.004784,
|
||||||
|
-0.005475,
|
||||||
|
0.007655,
|
||||||
|
-0.008506,
|
||||||
|
0.017622,
|
||||||
|
-0.024639,
|
||||||
|
0.028679,
|
||||||
|
-0.017303,
|
||||||
|
-0.032507,
|
||||||
|
0.623321,
|
||||||
|
0.184702,
|
||||||
|
-0.166867,
|
||||||
|
0.025729,
|
||||||
|
-0.078490,
|
||||||
|
-0.015735,
|
||||||
|
-0.041199,
|
||||||
|
-0.023151,
|
||||||
|
-0.031524,
|
||||||
|
-0.020121,
|
||||||
|
-0.024985,
|
||||||
|
-0.017303,
|
||||||
|
-0.019616,
|
||||||
|
-0.015018,
|
||||||
|
-0.015204,
|
||||||
|
-0.012838,
|
||||||
|
-0.011881,
|
||||||
|
-0.010951,
|
||||||
|
-0.009516,
|
||||||
|
-0.009090,
|
||||||
|
-0.007788,
|
||||||
|
-0.007442,
|
||||||
|
-0.006353,
|
||||||
|
-0.006087,
|
||||||
|
-0.005183,
|
||||||
|
-0.004970,
|
||||||
|
-0.004253,
|
||||||
|
-0.003987,
|
||||||
|
-0.003482,
|
||||||
|
-0.003216,
|
||||||
|
-0.002871,
|
||||||
|
-0.002578
|
||||||
|
};
|
||||||
|
|
||||||
|
static const float POLYPHASE_COEFFICIENTS_OTHER[] = {
|
||||||
|
-0.014194,
|
||||||
|
-0.002339,
|
||||||
|
-0.006220,
|
||||||
|
-0.019722,
|
||||||
|
-0.020626,
|
||||||
|
-0.014885,
|
||||||
|
-0.012240,
|
||||||
|
-0.012386,
|
||||||
|
-0.011801,
|
||||||
|
-0.011376,
|
||||||
|
-0.016293,
|
||||||
|
-0.018845,
|
||||||
|
-0.018327,
|
||||||
|
-0.013902,
|
||||||
|
-0.014951,
|
||||||
|
-0.015895,
|
||||||
|
-0.019044,
|
||||||
|
-0.017928,
|
||||||
|
-0.020094,
|
||||||
|
-0.017715,
|
||||||
|
-0.018845,
|
||||||
|
-0.015377,
|
||||||
|
-0.018354,
|
||||||
|
-0.016665,
|
||||||
|
-0.018951,
|
||||||
|
-0.011416,
|
||||||
|
-0.019469,
|
||||||
|
-0.017250,
|
||||||
|
0.003549,
|
||||||
|
-0.076045,
|
||||||
|
0.288350,
|
||||||
|
0.267751,
|
||||||
|
-0.041212,
|
||||||
|
-0.005130,
|
||||||
|
-0.088418,
|
||||||
|
-0.089348,
|
||||||
|
-0.087686,
|
||||||
|
-0.065625,
|
||||||
|
-0.041305,
|
||||||
|
-0.013343,
|
||||||
|
0.001422,
|
||||||
|
0.010313,
|
||||||
|
0.005834,
|
||||||
|
-0.001170,
|
||||||
|
-0.014499,
|
||||||
|
-0.021822,
|
||||||
|
-0.030792,
|
||||||
|
-0.029331,
|
||||||
|
-0.031071,
|
||||||
|
-0.018407,
|
||||||
|
-0.027271,
|
||||||
|
-0.008373,
|
||||||
|
-0.010791,
|
||||||
|
-0.040680,
|
||||||
|
0.229171,
|
||||||
|
0.080324,
|
||||||
|
-0.070955,
|
||||||
|
0.021689,
|
||||||
|
-0.046607,
|
||||||
|
-0.025011,
|
||||||
|
-0.026886,
|
||||||
|
-0.027271,
|
||||||
|
-0.032919
|
||||||
|
};
|
||||||
|
|
||||||
Polyphase::Polyphase(int unknown1) {
|
Polyphase::Polyphase(int unknown1) {
|
||||||
|
this->samplingRate = DEFAULT_SAMPLERATE;
|
||||||
|
this->fir1 = new FIR();
|
||||||
|
this->fir2 = new FIR();
|
||||||
|
this->waveBuffer1 = new WaveBuffer(2, 0x1000);
|
||||||
|
this->waveBuffer2 = new WaveBuffer(2, 0x1000);
|
||||||
|
this->buffer = new float[0x7e0];
|
||||||
|
|
||||||
|
if (unknown1 == 2) {
|
||||||
|
this->fir1->LoadCoefficients(POLYPHASE_COEFFICIENTS_2, sizeof(POLYPHASE_COEFFICIENTS_2) / sizeof(float), 1008);
|
||||||
|
this->fir2->LoadCoefficients(POLYPHASE_COEFFICIENTS_2, sizeof(POLYPHASE_COEFFICIENTS_2) / sizeof(float), 1008);
|
||||||
|
} else if (unknown1 > 2) {
|
||||||
|
this->fir1->LoadCoefficients(POLYPHASE_COEFFICIENTS_OTHER, sizeof(POLYPHASE_COEFFICIENTS_OTHER) / sizeof(float), 1008);
|
||||||
|
this->fir2->LoadCoefficients(POLYPHASE_COEFFICIENTS_OTHER, sizeof(POLYPHASE_COEFFICIENTS_OTHER) / sizeof(float), 1008);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Polyphase::~Polyphase() {
|
Polyphase::~Polyphase() {
|
||||||
|
delete this->fir1;
|
||||||
|
delete this->fir2;
|
||||||
|
delete this->waveBuffer1;
|
||||||
|
delete this->waveBuffer2;
|
||||||
|
delete this->buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Polyphase::GetLatency() {
|
uint32_t Polyphase::GetLatency() {
|
||||||
@ -13,14 +163,33 @@ uint32_t Polyphase::GetLatency() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Polyphase::Process(float *samples, uint32_t size) {
|
uint32_t Polyphase::Process(float *samples, uint32_t size) {
|
||||||
|
if (this->waveBuffer1->PushSamples(samples, size) != 0) {
|
||||||
|
uint32_t bufferOffset = this->waveBuffer1->GetBufferOffset();
|
||||||
|
while (bufferOffset >= 1008) {
|
||||||
|
if (this->waveBuffer1->PopSamples(this->buffer, 1008, false) == 1008) {
|
||||||
|
this->fir1->FilterSamplesInterleaved(this->buffer, 1008, 2);
|
||||||
|
this->fir2->FilterSamplesInterleaved(this->buffer + 1, 1008, 2);
|
||||||
|
this->waveBuffer2->PushSamples(this->buffer, 1008);
|
||||||
|
}
|
||||||
|
bufferOffset = this->waveBuffer1->GetBufferOffset();
|
||||||
|
}
|
||||||
|
if (this->waveBuffer2->GetBufferOffset() >= size) {
|
||||||
|
this->waveBuffer2->PopSamples(samples, size, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Polyphase::Reset() {
|
void Polyphase::Reset() {
|
||||||
|
this->fir1->Reset();
|
||||||
|
this->fir2->Reset();
|
||||||
|
this->waveBuffer1->Reset();
|
||||||
|
this->waveBuffer2->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Polyphase::SetSamplingRate(uint32_t samplingRate) {
|
void Polyphase::SetSamplingRate(uint32_t samplingRate) {
|
||||||
|
if (this->samplingRate != samplingRate) {
|
||||||
|
this->samplingRate = samplingRate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,9 +19,7 @@ private:
|
|||||||
FIR *fir2;
|
FIR *fir2;
|
||||||
WaveBuffer *waveBuffer1;
|
WaveBuffer *waveBuffer1;
|
||||||
WaveBuffer *waveBuffer2;
|
WaveBuffer *waveBuffer2;
|
||||||
int *unknown1;
|
float *buffer;
|
||||||
bool enabled;
|
|
||||||
// 3 unknowns
|
|
||||||
uint32_t samplingRate;
|
uint32_t samplingRate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ TimeConstDelay::TimeConstDelay() {
|
|||||||
|
|
||||||
TimeConstDelay::~TimeConstDelay() {
|
TimeConstDelay::~TimeConstDelay() {
|
||||||
delete this->samples;
|
delete this->samples;
|
||||||
this->samples = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float TimeConstDelay::ProcessSample(float sample) {
|
float TimeConstDelay::ProcessSample(float sample) {
|
||||||
|
@ -10,7 +10,6 @@ WaveBuffer::WaveBuffer(int channels, uint32_t size) {
|
|||||||
|
|
||||||
WaveBuffer::~WaveBuffer() {
|
WaveBuffer::~WaveBuffer() {
|
||||||
delete this->buffer;
|
delete this->buffer;
|
||||||
this->buffer = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t WaveBuffer::GetBufferOffset() {
|
uint32_t WaveBuffer::GetBufferOffset() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user