From 4554158155e7a3cb140f9ef872d3808ec4ff6c0a Mon Sep 17 00:00:00 2001 From: James Ball Date: Tue, 20 Feb 2024 14:57:52 +0000 Subject: [PATCH] Move close file button to an icon --- Resources/svg/delete.svg | 1 + Resources/svg/random.svg | 1 + Source/MainComponent.cpp | 10 +++++++--- Source/MainComponent.h | 2 +- Source/PluginProcessor.cpp | 34 +++++++++++++++++++--------------- Source/PluginProcessor.h | 4 ++-- Source/parser/FileParser.cpp | 6 +++++- Source/shape/Line.cpp | 2 ++ Source/shape/Line.h | 1 + osci-render.jucer | 2 ++ 10 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 Resources/svg/delete.svg create mode 100644 Resources/svg/random.svg diff --git a/Resources/svg/delete.svg b/Resources/svg/delete.svg new file mode 100644 index 00000000..8b82122a --- /dev/null +++ b/Resources/svg/delete.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Resources/svg/random.svg b/Resources/svg/random.svg new file mode 100644 index 00000000..d69aa6d3 --- /dev/null +++ b/Resources/svg/random.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index 0670823f..52248707 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -32,7 +32,6 @@ MainComponent::MainComponent(OscirenderAudioProcessor& p, OscirenderAudioProcess }; addAndMakeVisible(closeFileButton); - closeFileButton.setButtonText("Close File"); closeFileButton.onClick = [this] { juce::SpinLock::ScopedLockType lock(audioProcessor.parsersLock); @@ -163,9 +162,14 @@ void MainComponent::resized() { row.removeFromLeft(rowPadding); inputEnabled.setBounds(row.removeFromLeft(20)); row.removeFromLeft(rowPadding); + if (audioProcessor.getCurrentFileIndex() != -1) { + closeFileButton.setBounds(row.removeFromRight(20)); + row.removeFromRight(rowPadding); + } else { + closeFileButton.setBounds(juce::Rectangle()); + } + fileLabel.setBounds(row); - bounds.removeFromTop(padding); - closeFileButton.setBounds(bounds.removeFromTop(buttonHeight).removeFromLeft(buttonWidth)); bounds.removeFromTop(padding); row = bounds.removeFromTop(buttonHeight); diff --git a/Source/MainComponent.h b/Source/MainComponent.h index efb28e4f..66bd9ca3 100644 --- a/Source/MainComponent.h +++ b/Source/MainComponent.h @@ -25,7 +25,7 @@ class MainComponent : public juce::GroupComponent { std::unique_ptr chooser; juce::TextButton fileButton; - juce::TextButton closeFileButton; + SvgButton closeFileButton{"closeFile", juce::String(BinaryData::delete_svg), juce::Colours::red}; SvgButton inputEnabled{"inputEnabled", juce::String(BinaryData::microphone_svg), juce::Colours::white, juce::Colours::red, audioProcessor.inputEnabled}; juce::Label fileLabel; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index ac47774d..31cc4e53 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -35,15 +35,15 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() toggleableEffects.push_back(std::make_shared( std::make_shared(), - new EffectParameter("Bit Crush", "Limits the resolution of points drawn to the screen, making the object look pixelated, and making the audio sound more 'digital' and distorted.", "bitCrush", VERSION_HINT, 0.0, 0.0, 1.0) + new EffectParameter("Bit Crush", "Limits the resolution of points drawn to the screen, making the object look pixelated, and making the audio sound more 'digital' and distorted.", "bitCrush", VERSION_HINT, 0.6, 0.0, 1.0) )); toggleableEffects.push_back(std::make_shared( std::make_shared(), - new EffectParameter("Bulge", "Applies a bulge that makes the centre of the image larger, and squishes the edges of the image. This applies a distortion to the audio.", "bulge", VERSION_HINT, 0.0, 0.0, 1.0) + new EffectParameter("Bulge", "Applies a bulge that makes the centre of the image larger, and squishes the edges of the image. This applies a distortion to the audio.", "bulge", VERSION_HINT, 0.5, 0.0, 1.0) )); toggleableEffects.push_back(std::make_shared( std::make_shared(), - new EffectParameter("Vector Cancelling", "Inverts the audio and image every few samples to 'cancel out' the audio, making the audio quiet, and distorting the image.", "vectorCancelling", VERSION_HINT, 0.0, 0.0, 1.0) + new EffectParameter("Vector Cancelling", "Inverts the audio and image every few samples to 'cancel out' the audio, making the audio quiet, and distorting the image.", "vectorCancelling", VERSION_HINT, 0.1111111, 0.0, 1.0) )); toggleableEffects.push_back(std::make_shared( [this](int index, Point input, const std::vector& values, double sampleRate) { @@ -62,22 +62,24 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() }, std::vector{ new EffectParameter("Distort X", "Distorts the image in the horizontal direction by jittering the audio sample being drawn.", "distortX", VERSION_HINT, 0.0, 0.0, 1.0), new EffectParameter("Distort Y", "Distorts the image in the vertical direction by jittering the audio sample being drawn.", "distortY", VERSION_HINT, 0.0, 0.0, 1.0), - new EffectParameter("Distort Z", "Distorts the depth of the image by jittering the audio sample being drawn.", "distortZ", VERSION_HINT, 0.0, 0.0, 1.0), + new EffectParameter("Distort Z", "Distorts the depth of the image by jittering the audio sample being drawn.", "distortZ", VERSION_HINT, 0.1, 0.0, 1.0), } )); - toggleableEffects.push_back(std::make_shared( + auto rippleEffect = std::make_shared( [this](int index, Point input, const std::vector& values, double sampleRate) { double phase = values[1] * std::numbers::pi; double distance = 100 * values[2] * (input.x * input.x + input.y * input.y); input.z += values[0] * std::sin(phase + distance); return input; }, std::vector{ - new EffectParameter("Ripple Depth", "Controls how large the ripples applied to the image are.", "rippleDepth", VERSION_HINT, 0.0, 0.0, 1.0), + new EffectParameter("Ripple Depth", "Controls how large the ripples applied to the image are.", "rippleDepth", VERSION_HINT, 0.2, 0.0, 1.0), new EffectParameter("Ripple Phase", "Controls the position of the ripple. Animate this to see a moving ripple effect.", "ripplePhase", VERSION_HINT, 0.0, -1.0, 1.0), - new EffectParameter("Ripple Amount", "Controls how many ripples are applied to the image.", "rippleAmount", VERSION_HINT, 0.1, 0.0, 1.0), + new EffectParameter("Ripple Amount", "Controls how many ripples are applied to the image.", "rippleAmount", VERSION_HINT, 0.1, 0.0, 1.0), } - )); - toggleableEffects.push_back(std::make_shared( + ); + rippleEffect->getParameter("ripplePhase")->lfo->setUnnormalisedValueNotifyingHost((int) LfoType::Sawtooth); + toggleableEffects.push_back(rippleEffect); + auto rotateEffect = std::make_shared( [this](int index, Point input, const std::vector& values, double sampleRate) { input.rotate(values[0] * std::numbers::pi, values[1] * std::numbers::pi, values[2] * std::numbers::pi); return input; @@ -86,7 +88,9 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() new EffectParameter("Rotate Y", "Controls the rotation of the object in the Y axis.", "rotateY", VERSION_HINT, 0.0, -1.0, 1.0), new EffectParameter("Rotate Z", "Controls the rotation of the object in the Z axis.", "rotateZ", VERSION_HINT, 0.0, -1.0, 1.0), } - )); + ); + rotateEffect->getParameter("rotateZ")->lfo->setUnnormalisedValueNotifyingHost((int) LfoType::Sawtooth); + toggleableEffects.push_back(rotateEffect); toggleableEffects.push_back(std::make_shared( [this](int index, Point input, const std::vector& values, double sampleRate) { return input + Point(values[0], values[1], values[2]); @@ -103,28 +107,28 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() double newY = input.x * std::sin(length) + input.y * std::cos(length); return Point(newX, newY, input.z); }, std::vector{ - new EffectParameter("Swirl", "Swirls the image in a spiral pattern.", "swirl", VERSION_HINT, 0.0, -1.0, 1.0), + new EffectParameter("Swirl", "Swirls the image in a spiral pattern.", "swirl", VERSION_HINT, 0.3, -1.0, 1.0), } )); toggleableEffects.push_back(std::make_shared( std::make_shared(), - new EffectParameter("Smoothing", "This works as a low-pass frequency filter that removes high frequencies, making the image look smoother, and audio sound less harsh.", "smoothing", VERSION_HINT, 0.0, 0.0, 1.0) + new EffectParameter("Smoothing", "This works as a low-pass frequency filter that removes high frequencies, making the image look smoother, and audio sound less harsh.", "smoothing", VERSION_HINT, 0.75, 0.0, 1.0) )); toggleableEffects.push_back(std::make_shared( wobbleEffect, - new EffectParameter("Wobble", "Adds a sine wave of the prominent frequency in the audio currently playing. The sine wave's frequency is slightly offset to create a subtle 'wobble' in the image. Increasing the slider increases the strength of the wobble.", "wobble", VERSION_HINT, 0.0, 0.0, 1.0) + new EffectParameter("Wobble", "Adds a sine wave of the prominent frequency in the audio currently playing. The sine wave's frequency is slightly offset to create a subtle 'wobble' in the image. Increasing the slider increases the strength of the wobble.", "wobble", VERSION_HINT, 0.3, 0.0, 1.0) )); toggleableEffects.push_back(std::make_shared( delayEffect, std::vector{ - new EffectParameter("Delay Decay", "Adds repetitions, delays, or echos to the audio. This slider controls the volume of the echo.", "delayDecay", VERSION_HINT, 0.0, 0.0, 1.0), + new EffectParameter("Delay Decay", "Adds repetitions, delays, or echos to the audio. This slider controls the volume of the echo.", "delayDecay", VERSION_HINT, 0.4, 0.0, 1.0), 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), + new EffectParameter("Dash Length", "Controls the length of the dashed line.", "dashLength", VERSION_HINT, 0.2, 0.0, 1.0), } )); toggleableEffects.push_back(std::make_shared( diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 16cf1031..4fc147d5 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -124,7 +124,7 @@ class OscirenderAudioProcessor : public juce::AudioProcessor, juce::AudioProces "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, 1.0, 0.0, 1.0 + VERSION_HINT, 0.75, 0.0, 1.0 ) ); std::shared_ptr traceMin = std::make_shared( @@ -134,7 +134,7 @@ class OscirenderAudioProcessor : public juce::AudioProcessor, juce::AudioProces "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.0, 0.0, 1.0 + VERSION_HINT, 0.25, 0.0, 1.0 ) ); diff --git a/Source/parser/FileParser.cpp b/Source/parser/FileParser.cpp index 2baf0dca..c3195aa2 100644 --- a/Source/parser/FileParser.cpp +++ b/Source/parser/FileParser.cpp @@ -41,7 +41,11 @@ std::vector> FileParser::nextFrame() { return text->draw(); } auto tempShapes = std::vector>(); - tempShapes.push_back(std::make_unique(0, 0, 0.5, 0.5, std::numbers::pi / 4.0, 2 * std::numbers::pi)); + // return a square + tempShapes.push_back(std::make_unique(Point(-0.5, -0.5, 0), Point(0.5, -0.5, 0))); + tempShapes.push_back(std::make_unique(Point(0.5, -0.5, 0), Point(0.5, 0.5, 0))); + tempShapes.push_back(std::make_unique(Point(0.5, 0.5, 0), Point(-0.5, 0.5, 0))); + tempShapes.push_back(std::make_unique(Point(-0.5, 0.5, 0), Point(-0.5, -0.5, 0))); return tempShapes; } diff --git a/Source/shape/Line.cpp b/Source/shape/Line.cpp index 94de698a..e25dd947 100644 --- a/Source/shape/Line.cpp +++ b/Source/shape/Line.cpp @@ -4,6 +4,8 @@ Line::Line(double x1, double y1, double x2, double y2) : x1(x1), y1(y1), z1(0), Line::Line(double x1, double y1, double z1, double x2, double y2, double z2) : x1(x1), y1(y1), z1(z1), x2(x2), y2(y2), z2(z2) {} +Line::Line(Point p1, Point p2) : x1(p1.x), y1(p1.y), z1(p1.z), x2(p2.x), y2(p2.y), z2(p2.z) {} + Point Line::nextVector(double drawingProgress) { return Point( x1 + (x2 - x1) * drawingProgress, diff --git a/Source/shape/Line.h b/Source/shape/Line.h index 394b4538..7f8a744a 100644 --- a/Source/shape/Line.h +++ b/Source/shape/Line.h @@ -7,6 +7,7 @@ class Line : public Shape { public: Line(double x1, double y1, double x2, double y2); Line(double x1, double y1, double z1, double x2, double y2, double z2); + Line(Point p1, Point p2); Point nextVector(double drawingProgress) override; void scale(double x, double y, double z) override; diff --git a/osci-render.jucer b/osci-render.jucer index fe1bc7bd..29498edc 100644 --- a/osci-render.jucer +++ b/osci-render.jucer @@ -16,12 +16,14 @@ + +