osci-render/Source/audio/WobbleEffect.cpp

15 wiersze
543 B
C++
Czysty Zwykły widok Historia

#include "WobbleEffect.h"
WobbleEffect::WobbleEffect(PitchDetector& pitchDetector) : pitchDetector(pitchDetector) {}
WobbleEffect::~WobbleEffect() {}
2024-01-07 16:17:20 +00:00
Point WobbleEffect::apply(int index, Point input, const std::vector<double>& values, double sampleRate) {
// TODO: this doesn't consider sample rate
smoothedFrequency = smoothedFrequency * 0.99995 + pitchDetector.frequency * 0.00005;
double theta = nextPhase(smoothedFrequency, sampleRate);
2024-02-20 15:32:52 +00:00
double delta = 0.5 * values[0] * std::sin(theta);
return input + delta;
}