Merge trace parameters into one effect

pull/277/head
James H Ball 2025-01-19 18:35:46 +00:00
rodzic bcd8b69cc6
commit 225ddaa979
3 zmienionych plików z 31 dodań i 32 usunięć

Wyświetl plik

@ -121,8 +121,8 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() : CommonAudioProcessor(Buse
}
));
toggleableEffects.push_back(custom);
toggleableEffects.push_back(traceLength);
toggleableEffects.push_back(traceStart);
toggleableEffects.push_back(trace);
trace->getParameter("traceLength")->lfo->setUnnormalisedValueNotifyingHost((int) LfoType::Sawtooth);
for (int i = 0; i < toggleableEffects.size(); i++) {
auto effect = toggleableEffects[i];

Wyświetl plik

@ -72,21 +72,21 @@ public:
)
);
std::shared_ptr<Effect> traceLength = std::make_shared<Effect>(
new EffectParameter(
"Trace Length",
"Defines how much of the frame is drawn per cycle. This has the effect of 'tracing' out the image from a single dot when animated. By default, we draw the whole frame, corresponding to a value of 1.0.",
"traceLength",
VERSION_HINT, 1.0, 0.0, 1.0, 0.001, 0.001
)
);
std::shared_ptr<Effect> traceStart = std::make_shared<Effect>(
new EffectParameter(
"Trace Start",
"Defines how far into the frame the drawing is started at. This has the effect of 'tracing' out the image from a single dot when animated. By default, we start drawing from the beginning of the frame, so this value is 0.0.",
"traceStart",
VERSION_HINT, 0.0, 0.0, 1.0, 0.001, 0.001
)
std::shared_ptr<Effect> trace = std::make_shared<Effect>(
std::vector<EffectParameter*>{
new EffectParameter(
"Trace Start",
"Defines how far into the frame the drawing is started at. This has the effect of 'tracing' out the image from a single dot when animated. By default, we start drawing from the beginning of the frame, so this value is 0.0.",
"traceStart",
VERSION_HINT, 0.0, 0.0, 1.0, 0.001, 0.001
),
new EffectParameter(
"Trace Length",
"Defines how much of the frame is drawn per cycle. This has the effect of 'tracing' out the image from a single dot when animated. By default, we draw the whole frame, corresponding to a value of 1.0.",
"traceLength",
VERSION_HINT, 1.0, 0.0, 1.0, 0.001, 0.001
),
}
);
std::shared_ptr<DelayEffect> delayEffect = std::make_shared<DelayEffect>();

Wyświetl plik

@ -2,8 +2,8 @@
#include "../PluginProcessor.h"
ShapeVoice::ShapeVoice(OscirenderAudioProcessor& p) : audioProcessor(p) {
actualTraceStart = audioProcessor.traceStart->getValue();
actualTraceLength = audioProcessor.traceLength->getValue();
actualTraceStart = audioProcessor.trace->getValue(0);
actualTraceLength = audioProcessor.trace->getValue(1);
}
bool ShapeVoice::canPlaySound(juce::SynthesiserSound* sound) {
@ -86,12 +86,11 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star
}
for (auto sample = startSample; sample < startSample + numSamples; ++sample) {
bool traceStartEnabled = audioProcessor.traceStart->enabled->getBoolValue();
bool traceLengthEnabled = audioProcessor.traceLength->enabled->getBoolValue();
bool traceEnabled = audioProcessor.trace->enabled->getBoolValue();
// update length increment
double traceLen = traceLengthEnabled ? actualTraceLength : 1.0;
double traceMin = traceStartEnabled ? actualTraceStart : 0.0;
double traceLen = traceEnabled ? actualTraceLength : 1.0;
double traceMin = traceEnabled ? actualTraceStart : 0.0;
double proportionalLength = std::max(0.001, traceLen) * frameLength;
lengthIncrement = juce::jmax(proportionalLength / (audioProcessor.currentSampleRate / actualFrequency), MIN_LENGTH_INCREMENT);
@ -147,11 +146,11 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star
outputBuffer.addSample(0, sample, x * gain);
}
double traceStartValue = audioProcessor.traceStart->getActualValue();
double traceLengthValue = audioProcessor.traceLength->getActualValue();
traceLengthValue = traceLengthEnabled ? traceLengthValue : 1.0;
traceStartValue = traceStartEnabled ? traceStartValue : 0.0;
actualTraceLength = std::max(0.001, traceLengthValue);
double traceStartValue = audioProcessor.trace->getActualValue(0);
double traceLengthValue = audioProcessor.trace->getActualValue(1);
traceLengthValue = traceEnabled ? traceLengthValue : 1.0;
traceStartValue = traceEnabled ? traceStartValue : 0.0;
actualTraceLength = std::max(0.01, traceLengthValue);
actualTraceStart = traceStartValue;
if (actualTraceStart < 0) {
actualTraceStart = 0;
@ -163,7 +162,7 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star
double drawnFrameLength = frameLength;
bool willLoopOver = false;
if (traceLengthEnabled || traceStartEnabled) {
if (traceEnabled) {
drawnFrameLength *= actualTraceLength + actualTraceStart;
}
@ -172,8 +171,8 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star
frameLength = sound.load()->updateFrame(frame);
}
frameDrawn -= drawnFrameLength;
if (traceLengthEnabled || traceStartEnabled) {
shapeDrawn = frameDrawn;
if (traceEnabled) {
shapeDrawn = juce::jlimit(0.0, frame[currentShape]->len, frameDrawn);
}
currentShape = 0;
@ -182,7 +181,7 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star
// and shapeDrawn directly. frameDrawn is simply actualTraceStart * frameLength
// but shapeDrawn is the amount of the current shape that has been drawn so
// we need to iterate over all the shapes to calculate it.
if (traceStartEnabled) {
if (traceEnabled) {
while (frameDrawn < actualTraceStart * frameLength) {
incrementShapeDrawing();
}