diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 4ed2db7..cff5a36 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -121,8 +121,8 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() { } )); toggleableEffects.push_back(custom); - toggleableEffects.push_back(traceMax); - toggleableEffects.push_back(traceMin); + toggleableEffects.push_back(traceLength); + toggleableEffects.push_back(traceStart); for (int i = 0; i < toggleableEffects.size(); i++) { auto effect = toggleableEffects[i]; diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index d4a5e21..2a2962c 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -72,20 +72,20 @@ public: ) ); - std::shared_ptr traceMax = std::make_shared( + std::shared_ptr traceLength = std::make_shared( new EffectParameter( - "Trace max", - "Defines the maximum proportion of the image that is drawn before skipping to the next frame. This has the effect of 'tracing' out the image from a single dot when animated. By default, we draw until the end of the frame, so this value is 1.0.", - "traceMax", - VERSION_HINT, 0.75, 0.0, 1.0 + "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 ) ); - std::shared_ptr traceMin = std::make_shared( + std::shared_ptr traceStart = std::make_shared( new EffectParameter( - "Trace min", - "Defines the proportion of the image that drawing starts from. 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.", - "traceMin", - VERSION_HINT, 0.25, 0.0, 1.0 + "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 ) ); diff --git a/Source/audio/ShapeVoice.cpp b/Source/audio/ShapeVoice.cpp index 3a8dd2d..750351f 100644 --- a/Source/audio/ShapeVoice.cpp +++ b/Source/audio/ShapeVoice.cpp @@ -2,8 +2,8 @@ #include "../PluginProcessor.h" ShapeVoice::ShapeVoice(OscirenderAudioProcessor& p) : audioProcessor(p) { - actualTraceMin = audioProcessor.traceMin->getValue(); - actualTraceMax = audioProcessor.traceMax->getValue(); + actualTraceStart = audioProcessor.traceStart->getValue(); + actualTraceLength = audioProcessor.traceLength->getValue(); } bool ShapeVoice::canPlaySound(juce::SynthesiserSound* sound) { @@ -86,13 +86,13 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star } for (auto sample = startSample; sample < startSample + numSamples; ++sample) { - bool traceMinEnabled = audioProcessor.traceMin->enabled->getBoolValue(); - bool traceMaxEnabled = audioProcessor.traceMax->enabled->getBoolValue(); + bool traceStartEnabled = audioProcessor.traceStart->enabled->getBoolValue(); + bool traceLengthEnabled = audioProcessor.traceLength->enabled->getBoolValue(); // update length increment - double traceMax = traceMaxEnabled ? actualTraceMax : 1.0; - double traceMin = traceMinEnabled ? actualTraceMin : 0.0; - double proportionalLength = (traceMax) * frameLength; + double traceLen = traceLengthEnabled ? actualTraceLength : 1.0; + double traceMin = traceStartEnabled ? actualTraceStart : 0.0; + double proportionalLength = traceLen * frameLength; lengthIncrement = juce::jmax(proportionalLength / (audioProcessor.currentSampleRate / actualFrequency), MIN_LENGTH_INCREMENT); OsciPoint channels; @@ -147,14 +147,14 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star outputBuffer.addSample(0, sample, x * gain); } - double traceMinValue = audioProcessor.traceMin->getActualValue(); - double traceMaxValue = audioProcessor.traceMax->getActualValue(); - traceMaxValue = traceMaxEnabled ? traceMaxValue : 1.0; - traceMinValue = traceMinEnabled ? traceMinValue : 0.0; - actualTraceMax = traceMaxValue; - actualTraceMin = traceMinValue; - if (actualTraceMin < 0) { - actualTraceMin = 0; + double traceStartValue = audioProcessor.traceStart->getActualValue(); + double traceLengthValue = audioProcessor.traceLength->getActualValue(); + traceLengthValue = traceLengthEnabled ? traceLengthValue : 1.0; + traceStartValue = traceStartEnabled ? traceStartValue : 0.0; + actualTraceLength = traceLengthValue; + actualTraceStart = traceStartValue; + if (actualTraceStart < 0) { + actualTraceStart = 0; } if (!renderingSample) { @@ -163,8 +163,8 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star double drawnFrameLength = frameLength; bool willLoopOver = false; - if (traceMaxEnabled || traceMinEnabled) { - drawnFrameLength *= actualTraceMax + actualTraceMin; + if (traceLengthEnabled || traceStartEnabled) { + drawnFrameLength *= actualTraceLength + actualTraceStart; } if (!renderingSample && frameDrawn >= drawnFrameLength) { @@ -178,11 +178,11 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star // TODO: updateFrame already iterates over all the shapes, // so we can improve performance by calculating frameDrawn - // and shapeDrawn directly. frameDrawn is simply actualTraceMin * frameLength + // 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 (traceMinEnabled) { - while (frameDrawn < actualTraceMin * frameLength) { + if (traceStartEnabled) { + while (frameDrawn < actualTraceStart * frameLength) { incrementShapeDrawing(); } } diff --git a/Source/audio/ShapeVoice.h b/Source/audio/ShapeVoice.h index 76a878f..95b3888 100644 --- a/Source/audio/ShapeVoice.h +++ b/Source/audio/ShapeVoice.h @@ -27,8 +27,8 @@ private: OscirenderAudioProcessor& audioProcessor; std::vector> frame; std::atomic sound = nullptr; - double actualTraceMin; - double actualTraceMax; + double actualTraceStart; + double actualTraceLength; double frameLength = 0.0; int currentShape = 0;