commit ca0fbadf3f54fc4536aff3fd7e6e152bd26e5a31
parent bc75dd275f7ab8183eacdb9b0aa09220ecfff76c
Author: jatinchowdhury18 <jatinchowdhury18@gmail.com>
Date: Sun, 25 Oct 2020 12:07:15 -0700
Add snap buttons for tape speed (#101)
Co-authored-by: jatinchowdhury18 <jatinchowdhury18@users.noreply.github.com>
Diffstat:
5 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -4,6 +4,7 @@ this file.
## [Unreleased]
- Added coloured circle on bottom bar to visualize mix group
+- Added buttons to snap tape speed to conventional values
## [2.6.0] - 2020-09-29
- Added Pre/post emphasis filters for the hysteresis stage.
diff --git a/Plugin/Source/GUI/Assets/gui.xml b/Plugin/Source/GUI/Assets/gui.xml
@@ -94,7 +94,17 @@
class="Slider" padding="0" slider-background="ff595c6b" slider-track="ff9cbcbd"
name="Speed" tooltip="Sets the speed of the tape as it affects the playhead loss effects. Note that this control does not affect the wow/flutter processing."
caption-placement="top-left"/>
- <View flex-grow="0.2" background-color="00000000"/>
+ <View flex-grow="0.55" margin="0" padding="2" background-color="00000000">
+ <TextButton margin="0" padding="2" text="3.75" button-color="00000000" background-color="00000000"
+ onClick="set_speed_3.75" lookAndFeel="SpeedButtonLNF"/>
+ <TextButton text="7.5" margin="0" padding="2" button-color="00000000" background-color="00000000"
+ onClick="set_speed_7.50" lookAndFeel="SpeedButtonLNF"/>
+ <TextButton margin="0" padding="2" text="15" button-color="00000000" border-color=""
+ background-color="00000000" onClick="set_speed_15.00" lookAndFeel="SpeedButtonLNF"/>
+ <TextButton margin="0" padding="2" background-color="00000000" onClick="set_speed_30.00"
+ lookAndFeel="SpeedButtonLNF" text="30" button-color="00000000"/>
+ </View>
+ <View flex-grow="0.01" background-color="00000000"/>
</View>
<View tab-caption="Degrade" padding="0" flex-direction="column" background-color="FF31323A">
<Slider parameter="deg_depth" caption="Depth" class="Slider" name="Depth"
diff --git a/Plugin/Source/GUI/MyLNF.h b/Plugin/Source/GUI/MyLNF.h
@@ -64,5 +64,35 @@ private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComboBoxLNF)
};
+class SpeedButtonLNF : public MyLNF
+{
+public:
+ SpeedButtonLNF() {}
+
+ void drawButtonBackground (Graphics& g, Button& button,
+ const Colour& backgroundColour, bool shouldDrawButtonAsHighlighted,
+ bool shouldDrawButtonAsDown) override
+ {
+ constexpr auto cornerSize = 8.0f;
+ auto bounds = button.getLocalBounds().toFloat().reduced (0.5f, 0.5f);
+
+ auto baseColour = backgroundColour.withMultipliedSaturation (button.hasKeyboardFocus (true) ? 1.3f : 0.9f)
+ .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f);
+
+ if (shouldDrawButtonAsDown || shouldDrawButtonAsHighlighted)
+ baseColour = baseColour.contrasting (shouldDrawButtonAsDown ? 0.2f : 0.05f);
+
+ g.setColour (baseColour);
+ g.fillRoundedRectangle (bounds, cornerSize);
+
+ g.setColour (Colour (0xFF838590));
+ g.drawRoundedRectangle (bounds, cornerSize, 1.0f);
+ }
+
+private:
+
+ JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SpeedButtonLNF)
+};
+
#endif // MYLNF_H_INCLUDED
diff --git a/Plugin/Source/PluginProcessor.cpp b/Plugin/Source/PluginProcessor.cpp
@@ -269,6 +269,17 @@ AudioProcessorEditor* ChowtapeModelAudioProcessor::createEditor()
builder->registerJUCELookAndFeels();
builder->registerLookAndFeel ("MyLNF", std::make_unique<MyLNF>());
builder->registerLookAndFeel ("ComboBoxLNF", std::make_unique<ComboBoxLNF>());
+ builder->registerLookAndFeel ("SpeedButtonLNF", std::make_unique<SpeedButtonLNF>());
+
+ auto* speedHandle = dynamic_cast<AudioParameterFloat*> (vts.getParameter ("speed"));
+ for (auto speed : { 3.75f, 7.5f, 15.0f, 30.0f })
+ {
+ magicState.addTrigger ("set_speed_" + String (speed, 2, false), [speedHandle, speed] {
+ speedHandle->beginChangeGesture();
+ speedHandle->setValueNotifyingHost (speedHandle->convertTo0to1 (speed));
+ speedHandle->endChangeGesture();
+ });
+ }
#if SAVE_PRESETS // Add button to save new presets
magicState.addTrigger ("savepreset", [=]
diff --git a/Plugin/Source/Processors/Loss_Effects/LossFilter.cpp b/Plugin/Source/Processors/Loss_Effects/LossFilter.cpp
@@ -36,7 +36,7 @@ void LossFilter::createParameterLayout (std::vector<std::unique_ptr<RangedAudioP
params.push_back (std::make_unique<AudioParameterFloat> ("speed", "Speed [ips]",
speedRange, 15.0f, String(), AudioProcessorParameter::genericParameter,
- [] (float value, int) { return String (value, 4); }));
+ [] (float value, int) { return String (value, 2); }));
params.push_back (std::make_unique<AudioParameterFloat> ("spacing", "Spacing [cm]",
spaceRange, minDist, String(), AudioProcessorParameter::genericParameter,