Skip to content

Commit

Permalink
Add dashed line effect
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshball committed Feb 20, 2024
1 parent ff1b62d commit e132eb6
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Effect>(
dashedLineEffect,
std::vector<EffectParameter*>{
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<Effect>(
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)
Expand Down
3 changes: 3 additions & 0 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "UGen/Env.h"
#include "UGen/ugen_JuceEnvelopeComponent.h"
#include "audio/CustomEffect.h"
#include "audio/DashedLineEffect.h"

//==============================================================================
/**
Expand Down Expand Up @@ -139,6 +140,8 @@ class OscirenderAudioProcessor : public juce::AudioProcessor, juce::AudioProces

std::shared_ptr<DelayEffect> delayEffect = std::make_shared<DelayEffect>();

std::shared_ptr<DashedLineEffect> dashedLineEffect = std::make_shared<DashedLineEffect>();

std::function<void(int, juce::String, juce::String)> errorCallback = [this](int lineNum, juce::String fileName, juce::String error) { notifyErrorListeners(lineNum, fileName, error); };
std::shared_ptr<CustomEffect> customEffect = std::make_shared<CustomEffect>(errorCallback);

Expand Down
28 changes: 28 additions & 0 deletions Source/audio/DashedLineEffect.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "DashedLineEffect.h"

DashedLineEffect::DashedLineEffect() {}

DashedLineEffect::~DashedLineEffect() {}

Point DashedLineEffect::apply(int index, Point vector, const std::vector<double>& 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;
}
17 changes: 17 additions & 0 deletions Source/audio/DashedLineEffect.h
Original file line number Diff line number Diff line change
@@ -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<double>& values, double sampleRate) override;

private:
const static int MAX_BUFFER = 192000;
std::vector<Point> buffer = std::vector<Point>(MAX_BUFFER);
int dashIndex = 0;
int bufferIndex = 0;
};
6 changes: 5 additions & 1 deletion osci-render.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pluginCharacteristicsValue="pluginProducesMidiOut,pluginWantsMidiIn"
pluginManufacturer="jameshball" aaxIdentifier="sh.ball.oscirender"
cppLanguageStandard="20" projectLineFeed="&#10;" 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">
<MAINGROUP id="j5Ge2T" name="osci-render">
<GROUP id="{5ABCED88-0059-A7AF-9596-DBF91DDB0292}" name="Resources">
Expand Down Expand Up @@ -141,6 +141,10 @@
<FILE id="uvMCNC" name="CustomEffect.cpp" compile="1" resource="0"
file="Source/audio/CustomEffect.cpp"/>
<FILE id="qFZDUh" name="CustomEffect.h" compile="0" resource="0" file="Source/audio/CustomEffect.h"/>
<FILE id="JtasnQ" name="DashedLineEffect.cpp" compile="1" resource="0"
file="Source/audio/DashedLineEffect.cpp"/>
<FILE id="I7B78q" name="DashedLineEffect.h" compile="0" resource="0"
file="Source/audio/DashedLineEffect.h"/>
<FILE id="e6SZox" name="DelayEffect.cpp" compile="1" resource="0" file="Source/audio/DelayEffect.cpp"/>
<FILE id="kpI9pv" name="DelayEffect.h" compile="0" resource="0" file="Source/audio/DelayEffect.h"/>
<FILE id="DiIoN4" name="DistortEffect.cpp" compile="1" resource="0"
Expand Down

0 comments on commit e132eb6

Please sign in to comment.