2023-03-28 14:52:51 +00:00
|
|
|
#include "SmoothEffect.h"
|
|
|
|
|
2023-07-11 21:28:54 +00:00
|
|
|
SmoothEffect::SmoothEffect() {}
|
2023-03-28 14:52:51 +00:00
|
|
|
|
|
|
|
SmoothEffect::~SmoothEffect() {}
|
|
|
|
|
2023-07-14 14:34:24 +00:00
|
|
|
Vector2 SmoothEffect::apply(int index, Vector2 input, const std::vector<double>& values, double sampleRate) {
|
|
|
|
double weight = values[0];
|
2023-07-11 21:28:54 +00:00
|
|
|
weight *= 0.95;
|
2023-07-14 14:34:24 +00:00
|
|
|
double strength = 10;
|
2023-07-11 21:28:54 +00:00
|
|
|
weight = std::log(strength * weight + 1) / std::log(strength + 1);
|
2023-07-13 19:11:24 +00:00
|
|
|
// TODO: This doesn't consider the sample rate!
|
2023-07-11 21:28:54 +00:00
|
|
|
leftAvg = weight * leftAvg + (1 - weight) * input.x;
|
|
|
|
rightAvg = weight * rightAvg + (1 - weight) * input.y;
|
|
|
|
return Vector2(leftAvg, rightAvg);
|
2023-03-28 14:52:51 +00:00
|
|
|
}
|