ViPERFX_RE/src/cpp/viper/effects/TubeSimulator.cpp

38 lines
831 B
C++
Raw Normal View History

2021-07-27 09:47:15 +02:00
#include "TubeSimulator.h"
TubeSimulator::TubeSimulator() {
this->acc[0] = 0.f;
this->acc[1] = 0.f;
2022-10-11 00:36:38 +02:00
this->enable = false;
2021-07-27 09:47:15 +02:00
}
void TubeSimulator::Reset() {
this->acc[0] = 0.f;
this->acc[1] = 0.f;
2022-10-11 00:36:38 +02:00
this->enable = false;
}
void TubeSimulator::SetEnable(bool enable) {
if (this->enable != enable) {
if (!this->enable) {
Reset();
}
this->enable = enable;
}
2021-07-27 09:47:15 +02:00
}
void TubeSimulator::TubeProcess(float *buffer, uint32_t size) {
2022-10-11 00:36:38 +02:00
if (this->enable) {
2021-07-27 09:47:15 +02:00
for (int x = 0; x < size; x++) {
this->acc[0] = (this->acc[0] + buffer[2 * x]) / 2.f;
this->acc[1] = (this->acc[1] + buffer[2 * x + 1]) / 2.f;
buffer[2 * x] = this->acc[0];
buffer[2 * x + 1] = this->acc[1];
2021-07-27 09:47:15 +02:00
}
}
2022-09-06 17:57:23 +02:00
}
TubeSimulator::~TubeSimulator() {
}