2024-02-20 14:14:24 +00:00
|
|
|
#include "DashedLineEffect.h"
|
|
|
|
|
|
|
|
DashedLineEffect::DashedLineEffect() {}
|
|
|
|
|
|
|
|
DashedLineEffect::~DashedLineEffect() {}
|
|
|
|
|
2024-10-23 11:44:31 +00:00
|
|
|
OsciPoint DashedLineEffect::apply(int index, OsciPoint vector, const std::vector<std::atomic<double>>& values, double sampleRate) {
|
2024-02-20 14:14:24 +00:00
|
|
|
// dash length in seconds
|
|
|
|
double dashLength = values[0] / 400;
|
|
|
|
int dashLengthSamples = (int)(dashLength * sampleRate);
|
|
|
|
dashLengthSamples = juce::jmin(dashLengthSamples, MAX_BUFFER);
|
|
|
|
|
2024-08-26 17:09:29 +00:00
|
|
|
if (dashIndex >= dashLengthSamples) {
|
|
|
|
dashIndex = 0;
|
|
|
|
bufferIndex = 0;
|
2024-02-20 14:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
buffer[bufferIndex] = vector;
|
|
|
|
bufferIndex++;
|
|
|
|
|
|
|
|
vector = buffer[dashIndex];
|
|
|
|
|
2024-08-26 17:09:29 +00:00
|
|
|
if (index % 2 == 0) {
|
|
|
|
dashIndex++;
|
2024-02-20 14:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return vector;
|
|
|
|
}
|