Skip to content

Commit

Permalink
Move close file button to an icon
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshball committed Feb 20, 2024
1 parent e132eb6 commit 4554158
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 22 deletions.
1 change: 1 addition & 0 deletions Resources/svg/delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Resources/svg/random.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions Source/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ MainComponent::MainComponent(OscirenderAudioProcessor& p, OscirenderAudioProcess
};

addAndMakeVisible(closeFileButton);
closeFileButton.setButtonText("Close File");

closeFileButton.onClick = [this] {
juce::SpinLock::ScopedLockType lock(audioProcessor.parsersLock);
Expand Down Expand Up @@ -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<int>());
}

fileLabel.setBounds(row);
bounds.removeFromTop(padding);
closeFileButton.setBounds(bounds.removeFromTop(buttonHeight).removeFromLeft(buttonWidth));

bounds.removeFromTop(padding);
row = bounds.removeFromTop(buttonHeight);
Expand Down
2 changes: 1 addition & 1 deletion Source/MainComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MainComponent : public juce::GroupComponent {

std::unique_ptr<juce::FileChooser> 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;

Expand Down
34 changes: 19 additions & 15 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()

toggleableEffects.push_back(std::make_shared<Effect>(
std::make_shared<BitCrushEffect>(),
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<Effect>(
std::make_shared<BulgeEffect>(),
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<Effect>(
std::make_shared<VectorCancellingEffect>(),
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<Effect>(
[this](int index, Point input, const std::vector<double>& values, double sampleRate) {
Expand All @@ -62,22 +62,24 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()
}, std::vector<EffectParameter*>{
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<Effect>(
auto rippleEffect = std::make_shared<Effect>(
[this](int index, Point input, const std::vector<double>& 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<EffectParameter*>{
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<Effect>(
);
rippleEffect->getParameter("ripplePhase")->lfo->setUnnormalisedValueNotifyingHost((int) LfoType::Sawtooth);
toggleableEffects.push_back(rippleEffect);
auto rotateEffect = std::make_shared<Effect>(
[this](int index, Point input, const std::vector<double>& values, double sampleRate) {
input.rotate(values[0] * std::numbers::pi, values[1] * std::numbers::pi, values[2] * std::numbers::pi);
return input;
Expand All @@ -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<Effect>(
[this](int index, Point input, const std::vector<double>& values, double sampleRate) {
return input + Point(values[0], values[1], values[2]);
Expand All @@ -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<EffectParameter*>{
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<Effect>(
std::make_shared<SmoothEffect>(),
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<Effect>(
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<Effect>(
delayEffect,
std::vector<EffectParameter*>{
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<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),
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<Effect>(
Expand Down
4 changes: 2 additions & 2 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Effect> traceMin = std::make_shared<Effect>(
Expand All @@ -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
)
);

Expand Down
6 changes: 5 additions & 1 deletion Source/parser/FileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ std::vector<std::unique_ptr<Shape>> FileParser::nextFrame() {
return text->draw();
}
auto tempShapes = std::vector<std::unique_ptr<Shape>>();
tempShapes.push_back(std::make_unique<CircleArc>(0, 0, 0.5, 0.5, std::numbers::pi / 4.0, 2 * std::numbers::pi));
// return a square
tempShapes.push_back(std::make_unique<Line>(Point(-0.5, -0.5, 0), Point(0.5, -0.5, 0)));
tempShapes.push_back(std::make_unique<Line>(Point(0.5, -0.5, 0), Point(0.5, 0.5, 0)));
tempShapes.push_back(std::make_unique<Line>(Point(0.5, 0.5, 0), Point(-0.5, 0.5, 0)));
tempShapes.push_back(std::make_unique<Line>(Point(-0.5, 0.5, 0), Point(-0.5, -0.5, 0)));
return tempShapes;
}

Expand Down
2 changes: 2 additions & 0 deletions Source/shape/Line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions Source/shape/Line.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions osci-render.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
<FILE id="LbviBq" name="cube.obj" compile="0" resource="1" file="Resources/models/cube.obj"/>
</GROUP>
<GROUP id="{82BCD6F1-A8BF-F30B-5587-81EE70168883}" name="svg">
<FILE id="sDajXu" name="delete.svg" compile="0" resource="1" file="Resources/svg/delete.svg"/>
<FILE id="IqXIZW" name="demo.svg" compile="0" resource="1" file="Resources/svg/demo.svg"/>
<FILE id="YwkQpy" name="fixed_rotate.svg" compile="0" resource="1"
file="Resources/svg/fixed_rotate.svg"/>
<FILE id="PxYKbt" name="microphone.svg" compile="0" resource="1" file="Resources/svg/microphone.svg"/>
<FILE id="pSc1mq" name="osci.svg" compile="0" resource="1" file="Resources/svg/osci.svg"/>
<FILE id="D2AI1b" name="pencil.svg" compile="0" resource="1" file="Resources/svg/pencil.svg"/>
<FILE id="PFc2q2" name="random.svg" compile="0" resource="1" file="Resources/svg/random.svg"/>
<FILE id="n79IAy" name="record.svg" compile="0" resource="1" file="Resources/svg/record.svg"/>
<FILE id="rXjNlx" name="threshold.svg" compile="0" resource="1" file="Resources/svg/threshold.svg"/>
<FILE id="rFYmV8" name="timer.svg" compile="0" resource="1" file="Resources/svg/timer.svg"/>
Expand Down

0 comments on commit 4554158

Please sign in to comment.