osci-render/Source/audio/DashedLineEffect.cpp

29 wiersze
654 B
C++

2024-02-20 14:14:24 +00:00
#include "DashedLineEffect.h"
DashedLineEffect::DashedLineEffect() {}
DashedLineEffect::~DashedLineEffect() {}
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);
if (dashIndex >= dashLengthSamples) {
dashIndex = 0;
bufferIndex = 0;
2024-02-20 14:14:24 +00:00
}
buffer[bufferIndex] = vector;
bufferIndex++;
vector = buffer[dashIndex];
if (index % 2 == 0) {
dashIndex++;
2024-02-20 14:14:24 +00:00
}
return vector;
}