osci-render/Source/audio/VectorCancellingEffect.cpp

24 wiersze
650 B
C++

#include "VectorCancellingEffect.h"
VectorCancellingEffect::VectorCancellingEffect() {}
VectorCancellingEffect::~VectorCancellingEffect() {}
OsciPoint VectorCancellingEffect::apply(int index, OsciPoint input, const std::vector<std::atomic<double>>& values, double sampleRate) {
double value = values[0];
if (value < 0.001) {
return input;
}
double frequency = 1.0 + 9.0 * value;
if (index < lastIndex) {
nextInvert = nextInvert - lastIndex + frequency;
}
lastIndex = index;
if (index >= nextInvert) {
nextInvert += frequency;
} else {
input.scale(-1, -1, 1);
}
return input;
}