2021-09-18 13:37:23 +02:00
|
|
|
#include "VHE.h"
|
|
|
|
#include "../constants.h"
|
|
|
|
|
|
|
|
VHE::VHE() {
|
|
|
|
enabled = false;
|
|
|
|
effectLevel = 0;
|
|
|
|
convSize = 0;
|
2022-09-23 04:15:43 +02:00
|
|
|
samplingRate = DEFAULT_SAMPLERATE;
|
2021-09-18 13:37:23 +02:00
|
|
|
|
2022-09-18 03:38:22 +02:00
|
|
|
bufA = new WaveBuffer(2, 0x1000);
|
|
|
|
bufB = new WaveBuffer(2, 0x1000);
|
2021-09-18 13:37:23 +02:00
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
VHE::~VHE() {
|
|
|
|
delete bufA;
|
|
|
|
delete bufB;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VHE::Process(float *source, float *dest, int frameSize) {
|
|
|
|
if (enabled && convLeft.InstanceUsable() && convRight.InstanceUsable()) {
|
|
|
|
if (bufA->PushSamples(source, frameSize) != 0) {
|
|
|
|
while (bufA->GetBufferOffset() > convSize) {
|
2022-09-18 03:38:22 +02:00
|
|
|
float *buffer = bufA->GetBuffer();
|
2021-09-18 13:37:23 +02:00
|
|
|
convLeft.ConvolveInterleaved(buffer, 0);
|
|
|
|
convRight.ConvolveInterleaved(buffer, 1);
|
|
|
|
bufB->PushSamples(buffer, convSize);
|
|
|
|
bufA->PopSamples(convSize, true);
|
|
|
|
}
|
|
|
|
bufB->PopSamples(dest, frameSize, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VHE::Reset() {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VHE::GetEnabled() {
|
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VHE::SetEffectLevel(uint32_t level) {
|
|
|
|
if (level < 5) {
|
|
|
|
this->effectLevel = level;
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VHE::SetEnable(bool enabled) {
|
|
|
|
this->enabled = enabled;
|
|
|
|
if (enabled) {
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VHE::SetSamplingRate(uint32_t srate) {
|
2022-09-23 04:15:43 +02:00
|
|
|
this->samplingRate = srate;
|
2021-09-18 13:37:23 +02:00
|
|
|
Reset();
|
|
|
|
}
|