diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index caac35c9..ac47774d 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -121,6 +121,12 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() new EffectParameter("Delay Length", "Controls the time in seconds between echos.", "delayLength", VERSION_HINT, 0.5, 0.0, 1.0) } )); + toggleableEffects.push_back(std::make_shared( + dashedLineEffect, + std::vector{ + new EffectParameter("Dash Length", "Controls the length of the dashed line.", "dashLength", VERSION_HINT, 0.0, 0.0, 1.0), + } + )); toggleableEffects.push_back(std::make_shared( customEffect, new EffectParameter("Lua Effect", "Controls the strength of the custom Lua effect applied. You can write your own custom effect using Lua by pressing the edit button on the right.", "customEffectStrength", VERSION_HINT, 1.0, 0.0, 1.0) diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 4af132fb..16cf1031 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -25,6 +25,7 @@ #include "UGen/Env.h" #include "UGen/ugen_JuceEnvelopeComponent.h" #include "audio/CustomEffect.h" +#include "audio/DashedLineEffect.h" //============================================================================== /** @@ -139,6 +140,8 @@ class OscirenderAudioProcessor : public juce::AudioProcessor, juce::AudioProces std::shared_ptr delayEffect = std::make_shared(); + std::shared_ptr dashedLineEffect = std::make_shared(); + std::function errorCallback = [this](int lineNum, juce::String fileName, juce::String error) { notifyErrorListeners(lineNum, fileName, error); }; std::shared_ptr customEffect = std::make_shared(errorCallback); diff --git a/Source/audio/DashedLineEffect.cpp b/Source/audio/DashedLineEffect.cpp new file mode 100644 index 00000000..ac586a2b --- /dev/null +++ b/Source/audio/DashedLineEffect.cpp @@ -0,0 +1,28 @@ +#include "DashedLineEffect.h" + +DashedLineEffect::DashedLineEffect() {} + +DashedLineEffect::~DashedLineEffect() {} + +Point DashedLineEffect::apply(int index, Point vector, const std::vector& values, double sampleRate) { + // 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; + } + + buffer[bufferIndex] = vector; + bufferIndex++; + + vector = buffer[dashIndex]; + + if (index % 2 == 0) { + dashIndex++; + } + + return vector; +} diff --git a/Source/audio/DashedLineEffect.h b/Source/audio/DashedLineEffect.h new file mode 100644 index 00000000..c6351e1d --- /dev/null +++ b/Source/audio/DashedLineEffect.h @@ -0,0 +1,17 @@ +#pragma once +#include "EffectApplication.h" +#include "../shape/Point.h" + +class DashedLineEffect : public EffectApplication { +public: + DashedLineEffect(); + ~DashedLineEffect(); + + Point apply(int index, Point input, const std::vector& values, double sampleRate) override; + +private: + const static int MAX_BUFFER = 192000; + std::vector buffer = std::vector(MAX_BUFFER); + int dashIndex = 0; + int bufferIndex = 0; +}; \ No newline at end of file diff --git a/osci-render.jucer b/osci-render.jucer index 10dfbf96..fe1bc7bd 100644 --- a/osci-render.jucer +++ b/osci-render.jucer @@ -5,7 +5,7 @@ pluginCharacteristicsValue="pluginProducesMidiOut,pluginWantsMidiIn" pluginManufacturer="jameshball" aaxIdentifier="sh.ball.oscirender" cppLanguageStandard="20" projectLineFeed=" " headerPath="./include" - version="2.0.8" companyName="James H Ball" companyWebsite="https://osci-render.com" + version="2.1.0" companyName="James H Ball" companyWebsite="https://osci-render.com" companyEmail="james@ball.sh" defines="NOMINMAX=1"> @@ -141,6 +141,10 @@ + +