ViPERFX_RE/src/cpp/viper/effects/SpeakerCorrection.cpp

50 lines
1.5 KiB
C++
Raw Normal View History

2021-07-30 21:51:26 +02:00
#include "SpeakerCorrection.h"
#include "../constants.h"
SpeakerCorrection::SpeakerCorrection() {
this->samplerate = DEFAULT_SAMPLERATE;
this->enabled = false;
Reset();
}
void SpeakerCorrection::Process(float *samples, uint32_t size) {
for (int i = 0; i < size * 2; i++) {
float sample = samples[i];
int index = i % 2;
sample = this->lowpass[index].ProcessSample(sample);
sample = this->highpass[index].ProcessSample(sample);
float tmp = sample / 2.f;
samples[i] = tmp + this->bandpass[index].ProcessSample(tmp);
}
}
void SpeakerCorrection::Reset() {
this->lowpass[0].Reset();
this->lowpass[1].Reset();
this->bandpass[0].Reset();
this->bandpass[1].Reset();
this->highpass[0].RefreshFilter(FilterType::HIGHPASS, 0.f, 80.f, (float) this->samplerate, 1.f, false);
this->highpass[1].RefreshFilter(FilterType::HIGHPASS, 0.f, 80.f, (float) this->samplerate, 1.f, false);
2021-07-30 21:51:26 +02:00
this->lowpass[0].SetLowPassParameter(13500.f, this->samplerate, 1.0);
this->lowpass[1].SetLowPassParameter(13500.f, this->samplerate, 1.0);
this->bandpass[0].SetBandPassParameter(420.f, this->samplerate, 3.88f);
this->bandpass[1].SetBandPassParameter(420.f, this->samplerate, 3.88f);
}
void SpeakerCorrection::SetEnable(bool enabled) {
this->enabled = enabled;
2021-07-31 01:15:40 +02:00
if (this->enabled) {
Reset();
}
2021-07-30 21:51:26 +02:00
}
void SpeakerCorrection::SetSamplingRate(uint32_t samplerate) {
this->samplerate = samplerate;
Reset();
}
2022-09-06 17:57:23 +02:00
SpeakerCorrection::~SpeakerCorrection() {
}