ViPERFX_RE/src/viper/effects/TubeSimulator.cpp

36 lines
833 B
C++
Raw Normal View History

2021-07-27 09:47:15 +02:00
#include "TubeSimulator.h"
2022-12-14 02:56:26 +01:00
// Iscle: Verified with the latest version at 13/12/2022
2023-05-15 02:15:46 +02:00
TubeSimulator::TubeSimulator() :
acc({
0.0, 0.0
}),
enable(false) {}
2021-07-27 09:47:15 +02:00
void TubeSimulator::Reset() {
2022-12-14 02:56:26 +01:00
this->acc[0] = 0.0;
this->acc[1] = 0.0;
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-12-14 02:56:26 +01:00
if (!this->enable) return;
2022-09-06 17:57:23 +02:00
2022-12-14 02:56:26 +01:00
for (uint32_t i = 0; i < size; i += 2) {
this->acc[0] = (this->acc[0] + buffer[i * 2]) / 2.0;
this->acc[1] = (this->acc[1] + buffer[i * 2 + 1]) / 2.0;
buffer[i * 2] = (float) this->acc[0];
buffer[i * 2 + 1] = (float) this->acc[1];
}
2022-09-06 17:57:23 +02:00
}