AnalogTapeModel

Physical modelling signal processing for analog tape recording
Log | Files | Refs | Submodules | README | LICENSE

commit 10423503ca509caebf99be040fd97a7ea806f37f
parent b38a94e16b53fcf0bdce136cfb473714eba95551
Author: jatinchowdhury18 <jatinchowdhury18@users.noreply.github.com>
Date:   Sat, 18 Apr 2020 17:40:18 -0700

Migrate GUI to Foley's GUI Magic

Diffstat:
M.gitmodules | 3+++
MPlugin/CHOWTapeModel.jucer | 39+++++++--------------------------------
DPlugin/Source/GUI Components/HysteresisControls.cpp | 37-------------------------------------
DPlugin/Source/GUI Components/HysteresisControls.h | 37-------------------------------------
DPlugin/Source/GUI Components/LossControls.cpp | 45---------------------------------------------
DPlugin/Source/GUI Components/LossControls.h | 32--------------------------------
DPlugin/Source/GUI Components/MainControls.cpp | 40----------------------------------------
DPlugin/Source/GUI Components/MainControls.h | 45---------------------------------------------
DPlugin/Source/GUI Components/TimingControls.cpp | 33---------------------------------
DPlugin/Source/GUI Components/TimingControls.h | 28----------------------------
DPlugin/Source/GUI Extras/ChowSlider.h | 24------------------------
DPlugin/Source/GUI Extras/MyLNF.h | 52----------------------------------------------------
DPlugin/Source/PluginEditor.cpp | 100-------------------------------------------------------------------------------
DPlugin/Source/PluginEditor.h | 62--------------------------------------------------------------
MPlugin/Source/PluginProcessor.cpp | 17+++++------------
MPlugin/Source/PluginProcessor.h | 2++
MPlugin/Source/Processors/Loss_Effects/LossFilter.h | 24++++++++++++------------
APlugin/Source/gui.xml | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
APlugin/foleys_gui_magic | 1+
19 files changed, 106 insertions(+), 591 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -1,3 +1,6 @@ [submodule "Plugin/Juce"] path = Plugin/Juce url = https://github.com/jatinchowdhury18/JUCE.git +[submodule "Plugin/foleys_gui_magic"] + path = Plugin/foleys_gui_magic + url = https://github.com/ffAudio/foleys_gui_magic.git diff --git a/Plugin/CHOWTapeModel.jucer b/Plugin/CHOWTapeModel.jucer @@ -2,29 +2,11 @@ <JUCERPROJECT id="jDoXPz" name="CHOWTapeModel" projectType="audioplug" jucerVersion="5.4.4" version="2.0.0" pluginFormats="buildAU,buildStandalone,buildVST,buildVST3" - cppLanguageStandard="17" companyName="chowdsp" companyEmail="chowdsp@gmail.com"> + cppLanguageStandard="17" companyName="chowdsp" companyEmail="chowdsp@gmail.com" + defines="FOLEYS_SHOW_GUI_EDITOR_PALLETTE=0"> <MAINGROUP id="pXbPvR" name="CHOWTapeModel"> <GROUP id="{0178B10A-4A61-796A-5AB2-915D32AF6EEE}" name="Source"> - <GROUP id="{95079A80-7AE7-EAEE-9302-0BC2E901D700}" name="GUI Components"> - <FILE id="U6ldtW" name="HysteresisControls.cpp" compile="1" resource="0" - file="Source/GUI Components/HysteresisControls.cpp"/> - <FILE id="pgwXn0" name="HysteresisControls.h" compile="0" resource="0" - file="Source/GUI Components/HysteresisControls.h"/> - <FILE id="yCHTFN" name="LossControls.cpp" compile="1" resource="0" - file="Source/GUI Components/LossControls.cpp"/> - <FILE id="qv9Pbi" name="LossControls.h" compile="0" resource="0" file="Source/GUI Components/LossControls.h"/> - <FILE id="mpMg4X" name="MainControls.cpp" compile="1" resource="0" - file="Source/GUI Components/MainControls.cpp"/> - <FILE id="A4qTd6" name="MainControls.h" compile="0" resource="0" file="Source/GUI Components/MainControls.h"/> - <FILE id="mSX91i" name="TimingControls.cpp" compile="1" resource="0" - file="Source/GUI Components/TimingControls.cpp"/> - <FILE id="Gd9QVZ" name="TimingControls.h" compile="0" resource="0" - file="Source/GUI Components/TimingControls.h"/> - </GROUP> - <GROUP id="{25D57C01-20AB-46DC-E9B3-80021429D612}" name="GUI Extras"> - <FILE id="ddmwEV" name="ChowSlider.h" compile="0" resource="0" file="Source/GUI Extras/ChowSlider.h"/> - <FILE id="gFXfuJ" name="MyLNF.h" compile="0" resource="0" file="Source/GUI Extras/MyLNF.h"/> - </GROUP> + <FILE id="Xn3V5v" name="gui.xml" compile="0" resource="1" file="Source/gui.xml"/> <GROUP id="{43BBFC88-4D0A-01B8-2635-3748470B94F4}" name="Processors"> <GROUP id="{6052B1B0-83EF-DBFA-991C-FC0B47A949C9}" name="Hysteresis"> <FILE id="Qe4tlV" name="HysteresisProcessing.cpp" compile="1" resource="0" @@ -54,9 +36,6 @@ file="Source/PluginProcessor.cpp"/> <FILE id="JDgaoP" name="PluginProcessor.h" compile="0" resource="0" file="Source/PluginProcessor.h"/> - <FILE id="pmhzjP" name="PluginEditor.cpp" compile="1" resource="0" - file="Source/PluginEditor.cpp"/> - <FILE id="HqaJqZ" name="PluginEditor.h" compile="0" resource="0" file="Source/PluginEditor.h"/> </GROUP> </MAINGROUP> <EXPORTFORMATS> @@ -73,14 +52,13 @@ <MODULEPATH id="juce_audio_processors" path="Juce/modules"/> <MODULEPATH id="juce_audio_utils" path="Juce/modules"/> <MODULEPATH id="juce_core" path="Juce/modules"/> - <MODULEPATH id="juce_cryptography" path="Juce/modules"/> <MODULEPATH id="juce_data_structures" path="Juce/modules"/> <MODULEPATH id="juce_events" path="Juce/modules"/> <MODULEPATH id="juce_graphics" path="Juce/modules"/> <MODULEPATH id="juce_gui_basics" path="Juce/modules"/> <MODULEPATH id="juce_gui_extra" path="Juce/modules"/> - <MODULEPATH id="juce_opengl" path="Juce/modules"/> <MODULEPATH id="juce_dsp" path="Juce/modules"/> + <MODULEPATH id="foleys_gui_magic" path="."/> </MODULEPATHS> </XCODE_MAC> <VS2017 targetFolder="Builds/VisualStudio2017"> @@ -96,14 +74,13 @@ <MODULEPATH id="juce_audio_processors" path="Juce/modules"/> <MODULEPATH id="juce_audio_utils" path="Juce/modules"/> <MODULEPATH id="juce_core" path="Juce/modules"/> - <MODULEPATH id="juce_cryptography" path="Juce/modules"/> <MODULEPATH id="juce_data_structures" path="Juce/modules"/> <MODULEPATH id="juce_events" path="Juce/modules"/> <MODULEPATH id="juce_graphics" path="Juce/modules"/> <MODULEPATH id="juce_gui_basics" path="Juce/modules"/> <MODULEPATH id="juce_gui_extra" path="Juce/modules"/> - <MODULEPATH id="juce_opengl" path="Juce/modules"/> <MODULEPATH id="juce_dsp" path="Juce/modules"/> + <MODULEPATH id="foleys_gui_magic" path="."/> </MODULEPATHS> </VS2017> <LINUX_MAKE targetFolder="Builds/LinuxMakefile"> @@ -119,18 +96,18 @@ <MODULEPATH id="juce_audio_processors" path="Juce/modules"/> <MODULEPATH id="juce_audio_utils" path="Juce/modules"/> <MODULEPATH id="juce_core" path="Juce/modules"/> - <MODULEPATH id="juce_cryptography" path="Juce/modules"/> <MODULEPATH id="juce_data_structures" path="Juce/modules"/> <MODULEPATH id="juce_events" path="Juce/modules"/> <MODULEPATH id="juce_graphics" path="Juce/modules"/> <MODULEPATH id="juce_gui_basics" path="Juce/modules"/> <MODULEPATH id="juce_gui_extra" path="Juce/modules"/> - <MODULEPATH id="juce_opengl" path="Juce/modules"/> <MODULEPATH id="juce_dsp" path="Juce/modules"/> + <MODULEPATH id="foleys_gui_magic" path="."/> </MODULEPATHS> </LINUX_MAKE> </EXPORTFORMATS> <MODULES> + <MODULE id="foleys_gui_magic" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> <MODULE id="juce_audio_basics" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> <MODULE id="juce_audio_devices" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> <MODULE id="juce_audio_formats" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> @@ -139,14 +116,12 @@ <MODULE id="juce_audio_processors" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> <MODULE id="juce_audio_utils" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> <MODULE id="juce_core" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> - <MODULE id="juce_cryptography" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> <MODULE id="juce_data_structures" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> <MODULE id="juce_dsp" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> <MODULE id="juce_events" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> <MODULE id="juce_graphics" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> <MODULE id="juce_gui_basics" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> <MODULE id="juce_gui_extra" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> - <MODULE id="juce_opengl" showAllCode="1" useLocalCopy="0" useGlobalPath="0"/> </MODULES> <LIVE_SETTINGS> <WINDOWS/> diff --git a/Plugin/Source/GUI Components/HysteresisControls.cpp b/Plugin/Source/GUI Components/HysteresisControls.cpp @@ -1,37 +0,0 @@ -#include "HysteresisControls.h" -#include "../PluginEditor.h" - -HysteresisControls::HysteresisControls (ChowtapeModelAudioProcessor& proc) : - processor (proc) -{ - auto createSliderAnbdLabel = [=, &proc] (FullSlider& slider, String id) - { - ChowtapeModelAudioProcessorEditor::createSlider (slider.slider, proc.getVTS(), id, slider.attach, *this, myLNF); - ChowtapeModelAudioProcessorEditor::createLabel (slider.label, slider.slider.getName(), this); - }; - - createSliderAnbdLabel (driveSlide, "drive"); - createSliderAnbdLabel (satSlide, "sat"); - createSliderAnbdLabel (widthSlide, "width"); -} - -void HysteresisControls::paint (Graphics& g) -{ - g.setColour (Colours::antiquewhite); - g.setFont (Font ((float) nameHeight).boldened()); - - g.drawFittedText ("Hysteresis Parameters:", Rectangle<int> (xOffset, yOffset, width, labelHeight), - Justification::centredLeft, 1); -} - -void HysteresisControls::resized() -{ - driveSlide.label.setBounds (0, 2 * yOffset + labelY, sliderWidth, labelHeight); - driveSlide.slider.setBounds (0, 2 * yOffset + sliderY, sliderWidth, sliderWidth); - - satSlide.label.setBounds (driveSlide.slider.getRight(), 2 * yOffset + labelY, sliderWidth, labelHeight); - satSlide.slider.setBounds (driveSlide.slider.getRight(), 2 * yOffset + sliderY, sliderWidth, sliderWidth); - - widthSlide.label.setBounds (satSlide.slider.getRight(), 2 * yOffset + labelY, sliderWidth, labelHeight); - widthSlide.slider.setBounds (satSlide.slider.getRight(), 2 * yOffset + sliderY, sliderWidth, sliderWidth); -} diff --git a/Plugin/Source/GUI Components/HysteresisControls.h b/Plugin/Source/GUI Components/HysteresisControls.h @@ -1,37 +0,0 @@ -#ifndef BIASCONTROLS_H_INCLUDED -#define BIASCONTROLS_H_INCLUDED - -#include "../PluginProcessor.h" -#include "../GUI Extras/ChowSlider.h" -#include "../GUI Extras/MyLNF.h" - -using SliderAttachment = AudioProcessorValueTreeState::SliderAttachment; - -struct FullSlider -{ - Slider slider; - Label label; - std::unique_ptr<SliderAttachment> attach; -}; - -class HysteresisControls : public Component -{ -public: - HysteresisControls (ChowtapeModelAudioProcessor& proc); - - void paint (Graphics&) override; - void resized() override; - -private: - MyLNF myLNF; - - ChowtapeModelAudioProcessor& processor; - - FullSlider driveSlide; - FullSlider satSlide; - FullSlider widthSlide; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HysteresisControls) -}; - -#endif //BIASCONTROLS_H_INCLUDED diff --git a/Plugin/Source/GUI Components/LossControls.cpp b/Plugin/Source/GUI Components/LossControls.cpp @@ -1,45 +0,0 @@ -#include "LossControls.h" -#include "../PluginEditor.h" - -LossControls::LossControls (ChowtapeModelAudioProcessor& proc) : - processor (proc) -{ - std::function<String (double)> mmFunc = [] (double value) { return String (value * 1000.0f, 2, true) + " mm"; }; - - auto createSliderAndLabel = [=, &proc] (FullSlider& slider, String id, String suffix= {}, std::function<String (double)> textFromValue = {}) - { - ChowtapeModelAudioProcessorEditor::createSlider (slider.slider, proc.getVTS(), id, slider.attach, *this, myLNF, suffix, {}, textFromValue); - ChowtapeModelAudioProcessorEditor::createLabel (slider.label, slider.slider.getName(), this); - }; - - createSliderAndLabel (speedSlider, "speed", " ips"); - createSliderAndLabel (spacingSlider, "spacing", "", mmFunc); - createSliderAndLabel (thicknessSlider, "thick", "", mmFunc); - createSliderAndLabel (gapSlider, "gap", "", mmFunc); -} - -void LossControls::paint (Graphics& g) -{ - g.setColour (Colours::antiquewhite); - g.setFont (Font ((float) nameHeight).boldened()); - - g.drawFittedText ("Playhead Parameters:", Rectangle<int> (xOffset, yOffset, width, labelHeight), - Justification::centredLeft, 1); -} - -void LossControls::resized() -{ - const int smallSliderWidth = 90; - - spacingSlider.label.setBounds (0, 2 * yOffset + labelY, smallSliderWidth, labelHeight); - spacingSlider.slider.setBounds (0, 2 * yOffset + sliderY, smallSliderWidth, sliderWidth); - - thicknessSlider.label.setBounds (spacingSlider.slider.getRight(), 2 * yOffset + labelY, smallSliderWidth, labelHeight); - thicknessSlider.slider.setBounds (spacingSlider.slider.getRight(), 2 * yOffset + sliderY, smallSliderWidth, sliderWidth); - - gapSlider.label.setBounds (thicknessSlider.slider.getRight(), 2 * yOffset + labelY, smallSliderWidth, labelHeight); - gapSlider.slider.setBounds (thicknessSlider.slider.getRight(), 2 * yOffset + sliderY, smallSliderWidth, sliderWidth); - - speedSlider.label.setBounds (gapSlider.slider.getRight(), 2 * yOffset + labelY, smallSliderWidth, labelHeight); - speedSlider.slider.setBounds (gapSlider.slider.getRight(), 2 * yOffset + sliderY, smallSliderWidth, sliderWidth); -} diff --git a/Plugin/Source/GUI Components/LossControls.h b/Plugin/Source/GUI Components/LossControls.h @@ -1,32 +0,0 @@ -#ifndef LOSSCONTROLS_H_INCLUDED -#define LOSSCONTROLS_H_INCLUDED - -#include "../PluginProcessor.h" -#include "../GUI Extras/ChowSlider.h" -#include "../GUI Extras/MyLNF.h" -#include "HysteresisControls.h" - -using SliderAttachment = AudioProcessorValueTreeState::SliderAttachment; - -class LossControls : public Component -{ -public: - LossControls (ChowtapeModelAudioProcessor& proc); - - void paint (Graphics&) override; - void resized() override; - -private: - MyLNF myLNF; - - ChowtapeModelAudioProcessor& processor; - - FullSlider speedSlider; - FullSlider spacingSlider; - FullSlider thicknessSlider; - FullSlider gapSlider; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LossControls) -}; - -#endif //LOSSCONTROLS_H_INCLUDED diff --git a/Plugin/Source/GUI Components/MainControls.cpp b/Plugin/Source/GUI Components/MainControls.cpp @@ -1,40 +0,0 @@ -#include "MainControls.h" -#include "../PluginEditor.h" - -MainControls::MainControls (ChowtapeModelAudioProcessor& proc) : - processor (proc) -{ - ChowtapeModelAudioProcessorEditor::createSlider (gainInKnob, proc.getVTS(), "ingain", gainInAttach, *this, myLNF, " dB"); - ChowtapeModelAudioProcessorEditor::createSlider (gainOutKnob, proc.getVTS(), "outgain", gainOutAttach, *this, myLNF, " dB"); - ChowtapeModelAudioProcessorEditor::createComboBox (oversampling, proc.getVTS(), "os", osAttach, this, StringArray ({"2x", "4x", "8x", "16x"})); - // ChowtapeModelAudioProcessorEditor::createComboBox (oversampling, processor.overSampling, this); - // ChowtapeModelAudioProcessorEditor::createComboBox (tapeSpeed, processor.tapeSpeed, this); - // //ChowtapeModelAudioProcessorEditor::createComboBox (tapeType, processor.tapeType, this); - // oversampling.setEnabled (false); - - ChowtapeModelAudioProcessorEditor::createLabel (inGainLabel, gainInKnob.getName(), this); - ChowtapeModelAudioProcessorEditor::createLabel (outGainLabel, gainOutKnob.getName(), this); - ChowtapeModelAudioProcessorEditor::createLabel (oversampleLabel, oversampling.getName(), this); - // ChowtapeModelAudioProcessorEditor::createLabel (speedLabel, processor.tapeSpeed, this); - // //ChowtapeModelAudioProcessorEditor::createLabel (typeLabel, processor.tapeType, this); -} - -void MainControls::paint (Graphics&) {} - -void MainControls::resized() -{ - inGainLabel.setBounds (0, labelY, sliderWidth, labelHeight); - gainInKnob.setBounds (0, sliderY, sliderWidth, sliderWidth); - - oversampleLabel.setBounds (gainInKnob.getRight() - 7 * xOffset, 2 * labelY + yOffset, tapeWidth, labelHeight); - oversampling.setBounds (gainInKnob.getRight(), oversampleLabel.getBottom(), overWidth, boxHeight); - - // speedLabel.setBounds (oversampling.getRight(), 2 * labelY + yOffset, tapeWidth, labelHeight); - // tapeSpeed.setBounds (oversampling.getRight() + 2 * xOffset, speedLabel.getBottom(), tapeWidth, boxHeight); - // - // typeLabel.setBounds (gainInKnob.getRight(), oversampling.getBottom() + yOffset, typeWidth, labelHeight); - // tapeType.setBounds (gainInKnob.getRight(), typeLabel.getBottom(), typeWidth, boxHeight); - - outGainLabel.setBounds (getWidth() - sliderWidth, labelY, sliderWidth, labelHeight); - gainOutKnob.setBounds (getWidth() - sliderWidth, sliderY, sliderWidth, sliderWidth); -} diff --git a/Plugin/Source/GUI Components/MainControls.h b/Plugin/Source/GUI Components/MainControls.h @@ -1,45 +0,0 @@ -#ifndef MAINCONTROLS_H_INCLUDED -#define MAINCONTROLS_H_INCLUDED - -#include "../PluginProcessor.h" -#include "../GUI Extras/ChowSlider.h" -#include "../GUI Extras/MyLNF.h" - -using SliderAttachment = AudioProcessorValueTreeState::SliderAttachment; -using ComboBoxAttachment = AudioProcessorValueTreeState::ComboBoxAttachment; - -class MainControls : public Component -{ -public: - MainControls (ChowtapeModelAudioProcessor& proc); - - void paint (Graphics&) override; - void resized() override; - -private: - MyLNF myLNF; - - ChowtapeModelAudioProcessor& processor; - - Slider gainInKnob; - Slider gainOutKnob; - - std::unique_ptr<SliderAttachment> gainInAttach; - std::unique_ptr<SliderAttachment> gainOutAttach; - - ComboBox oversampling; - std::unique_ptr<ComboBoxAttachment> osAttach; - - // ComboBox tapeSpeed; - // ComboBox tapeType; - - Label inGainLabel; - Label outGainLabel; - Label oversampleLabel; - // Label speedLabel; - // Label typeLabel; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainControls) -}; - -#endif //MAINCONTROLS_H_INCLUDED diff --git a/Plugin/Source/GUI Components/TimingControls.cpp b/Plugin/Source/GUI Components/TimingControls.cpp @@ -1,33 +0,0 @@ -#include "TimingControls.h" -#include "../PluginEditor.h" - -TimingControls::TimingControls (ChowtapeModelAudioProcessor& proc) : - processor (proc) -{ - auto createSliderAndLabel = [=, &proc] (FullSlider& slider, String id) - { - ChowtapeModelAudioProcessorEditor::createSlider (slider.slider, proc.getVTS(), id, slider.attach, *this, myLNF); - ChowtapeModelAudioProcessorEditor::createLabel (slider.label, slider.slider.getName(), this); - }; - - createSliderAndLabel (depthSlide, "depth"); - createSliderAndLabel (rateSlide, "rate"); -} - -void TimingControls::paint (Graphics& g) -{ - g.setColour (Colours::antiquewhite); - g.setFont (Font ((float) nameHeight).boldened()); - - g.drawFittedText ("Flutter Parameters:", Rectangle<int> (xOffset, yOffset, width, labelHeight), - Justification::centredLeft, 1); -} - -void TimingControls::resized() -{ - rateSlide.label.setBounds (0, 2 * yOffset + labelY, sliderWidth, labelHeight); - rateSlide.slider.setBounds (0, 2 * yOffset + sliderY, sliderWidth, sliderWidth); - - depthSlide.label.setBounds (rateSlide.slider.getRight(), 2 * yOffset + labelY, sliderWidth, labelHeight); - depthSlide.slider.setBounds (rateSlide.slider.getRight(), 2 * yOffset + sliderY, sliderWidth, sliderWidth); -} diff --git a/Plugin/Source/GUI Components/TimingControls.h b/Plugin/Source/GUI Components/TimingControls.h @@ -1,28 +0,0 @@ -#ifndef TIMINGCONTROLS_H_INCLUDED -#define TIMINGCONTROLS_H_INCLUDED - -#include "../PluginProcessor.h" -#include "../GUI Extras/ChowSlider.h" -#include "../GUI Extras/MyLNF.h" -#include "HysteresisControls.h" - -class TimingControls : public Component -{ -public: - TimingControls (ChowtapeModelAudioProcessor& proc); - - void paint (Graphics&) override; - void resized() override; - -private: - MyLNF myLNF; - - ChowtapeModelAudioProcessor& processor; - - FullSlider rateSlide; - FullSlider depthSlide; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TimingControls) -}; - -#endif //TIMINGCONTROLS_H_INCLUDED diff --git a/Plugin/Source/GUI Extras/ChowSlider.h b/Plugin/Source/GUI Extras/ChowSlider.h @@ -1,24 +0,0 @@ -#ifndef CHOWSLIDER_H_INCLUDED -#define CHOWSLIDER_H_INCLUDED - -#include "JuceHeader.h" - -class ChowSlider : public Slider -{ -public: - ChowSlider() {} - - void setDefaultValue (const float value) { defaultValue = value; } - - void mouseDoubleClick (const MouseEvent&) override - { - setValue (defaultValue); - } - -private: - float defaultValue = 0.0f; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChowSlider) -}; - -#endif //CHOWSLIDER_H_INCLUDED diff --git a/Plugin/Source/GUI Extras/MyLNF.h b/Plugin/Source/GUI Extras/MyLNF.h @@ -1,52 +0,0 @@ -#ifndef MYLNF_H_INCLUDED -#define MYLNF_H_INCLUDED - -#include "JuceHeader.h" - -class MyLNF : public LookAndFeel_V4 -{ -public: - MyLNF() - { - setColour (ComboBox::outlineColourId, Colours::darkorange); - - setColour (PopupMenu::backgroundColourId, Colours::black); - setColour (PopupMenu::textColourId, Colours::antiquewhite); - setColour (PopupMenu::highlightedBackgroundColourId, Colours::darkgrey); - } - - Font getTextButtonFont (TextButton& button, int buttonHeight) override - { - return LookAndFeel_V4::getTextButtonFont (button, buttonHeight).boldened(); - } - - void drawRotarySlider (Graphics& g, int x, int y, int width, int height, float sliderPos, - float rotaryStartAngle, float rotaryEndAngle, Slider& slider) override - { - auto outline = slider.findColour (Slider::rotarySliderOutlineColourId); - auto fill = slider.isEnabled() ? slider.findColour (Slider::rotarySliderFillColourId) : Colours::grey; - - auto bounds = Rectangle<int> (x, y, width, height).toFloat().reduced (10); - - auto radius = jmin (bounds.getWidth(), bounds.getHeight()) / 2.0f; - auto toAngle = rotaryStartAngle + sliderPos * (rotaryEndAngle - rotaryStartAngle); - auto lineW = jmin (5.0f, radius * 0.1f); - auto arcRadius = radius - lineW; - - g.setColour (outline); - g.fillEllipse (Rectangle<float> (radius * 2.0f, radius * 2.0f).withCentre (bounds.getCentre())); - - g.setColour (fill); - g.fillEllipse (Rectangle<float> (arcRadius * 2.0f, arcRadius * 2.0f).withCentre (bounds.getCentre())); - - Point<float> thumbPoint (bounds.getCentreX() + arcRadius * std::cos (toAngle - MathConstants<float>::halfPi), - bounds.getCentreY() + arcRadius * std::sin (toAngle - MathConstants<float>::halfPi)); - g.setColour (slider.findColour (Slider::thumbColourId)); - g.drawLine (bounds.getCentreX(), bounds.getCentreY(), thumbPoint.x, thumbPoint.y, lineW); - } - -private: - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MyLNF) -}; - -#endif //MYLNF_H_INCLUDED diff --git a/Plugin/Source/PluginEditor.cpp b/Plugin/Source/PluginEditor.cpp @@ -1,100 +0,0 @@ -#include "PluginProcessor.h" -#include "PluginEditor.h" - -//============================================================================== -ChowtapeModelAudioProcessorEditor::ChowtapeModelAudioProcessorEditor (ChowtapeModelAudioProcessor& p) - : AudioProcessorEditor (&p), processor (p) -{ - mainControls.reset (new MainControls (processor)); - addAndMakeVisible (mainControls.get()); - - biasControls.reset (new HysteresisControls (processor)); - addAndMakeVisible (biasControls.get()); - - lossControls.reset (new LossControls (processor)); - addAndMakeVisible (lossControls.get()); - - timingControls.reset (new TimingControls (processor)); - addAndMakeVisible (timingControls.get()); - - setSize (width, height); -} - -ChowtapeModelAudioProcessorEditor::~ChowtapeModelAudioProcessorEditor() -{ -} - -void ChowtapeModelAudioProcessorEditor::createSlider (Slider& slider, AudioProcessorValueTreeState& vts, String paramID, - std::unique_ptr<SliderAttachment>& attachment, Component& comp, LookAndFeel& myLNF, - String suffix, std::function<void()> onValueChange, - std::function<String (double)> textFromValue, std::function<double (String)> valueFromText) -{ - comp.addAndMakeVisible (slider); - attachment.reset (new SliderAttachment (vts, paramID, slider)); - - slider.setName (vts.getParameter (paramID)->name); - slider.textFromValueFunction = textFromValue; - slider.valueFromTextFunction = valueFromText; - slider.setNumDecimalPlacesToDisplay (2); - slider.setTextValueSuffix (suffix); - slider.onValueChange = onValueChange; - - slider.setLookAndFeel (&myLNF); - slider.setSliderStyle(Slider::RotaryHorizontalVerticalDrag); - slider.setColour(Slider::rotarySliderFillColourId, Colours::black); - slider.setColour(Slider::rotarySliderOutlineColourId, Colours::darkred); - slider.setColour(Slider::thumbColourId, Colours::antiquewhite); - slider.setTextBoxStyle(Slider::TextBoxBelow, false, 80, 20); - slider.setColour(Slider::textBoxTextColourId, Colours::antiquewhite); - slider.setColour(Slider::textBoxOutlineColourId, Colours::antiquewhite); -} - -void ChowtapeModelAudioProcessorEditor::createComboBox (ComboBox& box, AudioProcessorValueTreeState& vts, String paramID, - std::unique_ptr<ComboBoxAttachment>& attachment, Component* comp, - StringArray choices) -{ - attachment.reset (new ComboBoxAttachment (vts, paramID, box)); - - box.setName (vts.getParameter (paramID)->name); - box.addItemList (choices, 1); - box.setSelectedItemIndex ((int) *vts.getRawParameterValue (paramID), dontSendNotification); - - box.setColour (ComboBox::backgroundColourId, Colours::black); - box.setColour (ComboBox::outlineColourId, Colours::saddlebrown); - box.setColour (ComboBox::textColourId, Colours::antiquewhite); - box.setColour (ComboBox::arrowColourId, Colours::antiquewhite); - - comp->addAndMakeVisible (box); -} - -void ChowtapeModelAudioProcessorEditor::createLabel (Label& label, String name, Component* comp) -{ - label.setText (name, dontSendNotification); - label.setJustificationType (Justification::centred); - label.setColour (Label::textColourId, Colours::antiquewhite); - label.setFont (17.0f); - - comp->addAndMakeVisible (label); -} - -//============================================================================== -void ChowtapeModelAudioProcessorEditor::paint (Graphics& g) -{ - g.fillAll (Colours::saddlebrown); - - g.setColour (Colours::antiquewhite); - g.setFont (Font ((float) nameHeight).boldened()); - g.drawFittedText ("CHOW Tape Model", getLocalBounds().removeFromTop (nameHeight), Justification::centred, 1); - - g.drawHorizontalLine (sectionHeight, 0, width); - g.drawHorizontalLine (2 * sectionHeight, 0, width); - g.drawHorizontalLine (3 * sectionHeight, 0, width); -} - -void ChowtapeModelAudioProcessorEditor::resized() -{ - mainControls->setBounds (0, 0, width, sectionHeight); - biasControls->setBounds (0, sectionHeight, width, sectionHeight); - lossControls->setBounds (0, 2 * sectionHeight, width, sectionHeight); - timingControls->setBounds (0, 3 * sectionHeight, width, sectionHeight); -} diff --git a/Plugin/Source/PluginEditor.h b/Plugin/Source/PluginEditor.h @@ -1,62 +0,0 @@ -#pragma once - -#include "PluginProcessor.h" -#include "GUI Extras/MyLNF.h" -#include "GUI Extras/ChowSlider.h" -#include "GUI Components/HysteresisControls.h" -#include "GUI Components/MainControls.h" -#include "GUI Components/LossControls.h" -#include "GUI Components/TimingControls.h" - -enum -{ - width = 375, - sectionHeight = 150, - height = 4 * sectionHeight, - - nameHeight = 20, - - xOffset = 2, - yOffset = 5, - - labelY = 15, - labelHeight = 20, - - sliderWidth = 110, - sliderY = 25, - - overWidth = 90, - tapeWidth = 90, - typeWidth = 150, - speedWidth = 150, - boxHeight = 25, -}; - -class ChowtapeModelAudioProcessorEditor : public AudioProcessorEditor -{ -public: - ChowtapeModelAudioProcessorEditor (ChowtapeModelAudioProcessor&); - ~ChowtapeModelAudioProcessorEditor(); - - //============================================================================== - void paint (Graphics&) override; - void resized() override; - - static void createSlider (Slider& slider, AudioProcessorValueTreeState& vts, String paramID, - std::unique_ptr<SliderAttachment>& attachment, Component& comp, LookAndFeel& myLNF, - String suffix = "", std::function<void()> onValueChange = {}, - std::function<String (double)> textFromValue = {}, std::function<double (String)> valueFromText = {}); - static void createComboBox (ComboBox& box, AudioProcessorValueTreeState& vts, String paramID, - std::unique_ptr<ComboBoxAttachment>& attachment, Component* comp, StringArray choices); - static void createLabel (Label& label, String name, Component* comp); - -private: - ChowtapeModelAudioProcessor& processor; - - std::unique_ptr<MainControls> mainControls; - std::unique_ptr<HysteresisControls> biasControls; - std::unique_ptr<LossControls> lossControls; - std::unique_ptr<TimingControls> timingControls; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChowtapeModelAudioProcessorEditor) -}; diff --git a/Plugin/Source/PluginProcessor.cpp b/Plugin/Source/PluginProcessor.cpp @@ -9,7 +9,6 @@ */ #include "PluginProcessor.h" -#include "PluginEditor.h" //============================================================================== ChowtapeModelAudioProcessor::ChowtapeModelAudioProcessor() @@ -39,8 +38,8 @@ AudioProcessorValueTreeState::ParameterLayout ChowtapeModelAudioProcessor::creat { std::vector<std::unique_ptr<RangedAudioParameter>> params; - params.push_back (std::make_unique<AudioParameterFloat> ("ingain", "Input Gain", -30.0f, 6.0f, 0.0f)); - params.push_back (std::make_unique<AudioParameterFloat> ("outgain", "Output Gain", -30.0f, 30.0f, 0.0f)); + params.push_back (std::make_unique<AudioParameterFloat> ("ingain", "Input Gain [dB]", -30.0f, 6.0f, 0.0f)); + params.push_back (std::make_unique<AudioParameterFloat> ("outgain", "Output Gain [dB]", -30.0f, 30.0f, 0.0f)); HysteresisProcessor::createParameterLayout (params); LossFilter::createParameterLayout (params); @@ -179,24 +178,18 @@ bool ChowtapeModelAudioProcessor::hasEditor() const AudioProcessorEditor* ChowtapeModelAudioProcessor::createEditor() { - return new ChowtapeModelAudioProcessorEditor (*this); + return new foleys::MagicPluginEditor (magicState, BinaryData::gui_xml, BinaryData::gui_xmlSize); } //============================================================================== void ChowtapeModelAudioProcessor::getStateInformation (MemoryBlock& destData) { - auto state = vts.copyState(); - std::unique_ptr<XmlElement> xml (state.createXml()); - copyXmlToBinary (*xml, destData); + magicState.getStateInformation (destData); } void ChowtapeModelAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { - std::unique_ptr<XmlElement> xmlState (getXmlFromBinary (data, sizeInBytes)); - - if (xmlState.get() != nullptr) - if (xmlState->hasTagName (vts.state.getType())) - vts.replaceState (ValueTree::fromXml (*xmlState)); + magicState.setStateInformation (data, sizeInBytes); } //============================================================================== diff --git a/Plugin/Source/PluginProcessor.h b/Plugin/Source/PluginProcessor.h @@ -71,6 +71,8 @@ private: Flutter flutter; GainProcessor outGain; + foleys::MagicProcessorState magicState { *this, vts }; + //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChowtapeModelAudioProcessor) }; diff --git a/Plugin/Source/Processors/Loss_Effects/LossFilter.h b/Plugin/Source/Processors/Loss_Effects/LossFilter.h @@ -25,18 +25,18 @@ public: NormalisableRange<float> speedRange (1.0f, 100.0f); // meters per second speedRange.setSkewForCentre (15.0f); - NormalisableRange<float> spaceRange ((float) 1.0e-9, 0.01f); - spaceRange.setSkewForCentre ((float) 1.0e-6); + NormalisableRange<float> spaceRange ((float) 1.0e-6, 100.0f); + spaceRange.setSkewForCentre ((float) 1.0); - NormalisableRange<float> thickRange ((float) 1.0e-9, 0.0001f); - thickRange.setSkewForCentre (0.0000001f); + NormalisableRange<float> thickRange ((float) 1.0e-6, 10.0f); + thickRange.setSkewForCentre (0.0001f); - NormalisableRange<float> gapRange ((float) 1.0e-9, 0.01f); - gapRange.setSkewForCentre ((float) 1.0e-6); + NormalisableRange<float> gapRange ((float) 1.0e-6, 100.0f); + gapRange.setSkewForCentre ((float) 1.0e-3); - params.push_back (std::make_unique<AudioParameterFloat> ("speed", "Speed", speedRange, 15.0f)); - params.push_back (std::make_unique<AudioParameterFloat> ("spacing", "Spacing", spaceRange, (float) 1.0e-9)); - params.push_back (std::make_unique<AudioParameterFloat> ("thick", "Thickness", thickRange, (float) 1.0e-9)); + params.push_back (std::make_unique<AudioParameterFloat> ("speed", "Speed [ips]", speedRange, 15.0f)); + params.push_back (std::make_unique<AudioParameterFloat> ("spacing", "Spacing [mm]", spaceRange, (float) 1.0e-9)); + params.push_back (std::make_unique<AudioParameterFloat> ("thick", "Thickness [mm]", thickRange, (float) 1.0e-9)); params.push_back (std::make_unique<AudioParameterFloat> ("gap", "Gap", gapRange, (float) 1.0e-9)); } @@ -75,10 +75,10 @@ public: { const auto freq = ((float) k * binWidth); // + (binWidth / 2.0f); const auto waveNumber = MathConstants<float>::twoPi * jmax (freq, 20.0f) / (*speed * 0.0254f); - const auto thickTimesK = waveNumber * *thickness; - const auto kGapOverTwo = waveNumber * *gap / 2.0f; + const auto thickTimesK = waveNumber * (*thickness * (float) 1.0e-3); + const auto kGapOverTwo = waveNumber * (*gap * (float) 1.0e-3) / 2.0f; - H[k] = expf (-1.0f * waveNumber * *spacing); // Spacing loss formula + H[k] = expf (-1.0f * waveNumber * (*spacing * (float) 1.0e-3)); // Spacing loss formula H[k] *= (1.0f - expf (-thickTimesK)) / thickTimesK; H[k] *= sinf (kGapOverTwo) / kGapOverTwo; H[curOrder - k - 1] = H[k]; diff --git a/Plugin/Source/gui.xml b/Plugin/Source/gui.xml @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<magic> + <Styles> + <Style name="default"> + <Nodes/> + <Classes> + <plot-view border="2" background-color="black" border-color="silver" display="contents"/> + <nomargin margin="0" padding="0" border="0"/> + <group margin="5" padding="5" border="2" flex-direction="column"/> + </Classes> + <Types> + <Slider border="0" slider-type="rotary" slider-textbox="textbox-below"/> + <ToggleButton border="0" max-height="50" caption-size="0" text="Active"/> + <TextButton border="0" max-height="50" caption-size="0"/> + <ComboBox border="0" max-height="50" caption-size="0"/> + <Plot border="0" margin="0" padding="0" background-color="00000000" + radius="0"/> + <XYDragComponent border="0" margin="0" padding="0" background-color="00000000" + radius="0"/> + </Types> + </Style> + </Styles> + <View id="root" resizable="1" resize-corner="1" flex-direction="column" + background-color="FF7D2C2C" padding="0"> + <View max-height="40" padding="0" background-color="FF7D2C2C"> + <Label text="CHOW Tape Model" font-size="20" padding="0" background-color="FF7D2C2C" + border=""/> + </View> + <View background-color="FF7D2C2C" padding="0"> + <View flex-direction="column"> + <Label max-height="40"/> + <Slider caption="Output Gain [dB]" parameter="outgain" slider-textbox="textbox-below" + slider-type="rotary" max-height="200"/> + <ComboBox caption="Oversampling" parameter="os" max-height="80"/> + <Slider caption="Input Gain [dB]" parameter="ingain" slider-textbox="textbox-below" + slider-type="rotary" max-height="200"/> + </View> + <View flex-direction="column" tab-color=""> + <Label max-height="40" text="Hysteresis" font-size="18" justification="centred"/> + <Slider caption="Bias" parameter="width" slider-type="rotary" slider-textbox="textbox-below"/> + <Slider caption="Saturation" parameter="sat" slider-textbox="textbox-below" + slider-type="rotary"/> + <Slider caption="Drive" parameter="drive" slider-type="rotary" slider-textbox="textbox-below"/> + </View> + <View display="tabbed" padding="0"> + <View flex-direction="column" tab-caption="0" tab-color="" background-color="" + padding="0"> + <Label max-height="40" text="Loss" justification="centred" font-size="18" + padding="0"/> + <Slider caption="Gap [mm]" parameter="gap" slider-type="rotary" slider-textbox="textbox-below" + background-color=""/> + <Slider caption="Thickness [mm]" parameter="thick" slider-textbox="textbox-below" + slider-type="rotary"/> + <Slider caption="Spacing [mm]" parameter="spacing" slider-type="rotary" + slider-textbox="textbox-below" lookAndFeel="LookAndFeel_V4"/> + <Slider caption="Speed [ips]" parameter="speed" slider-type="rotary" + slider-textbox="textbox-below"/> + </View> + <View tab-caption="1" padding="0"> + <Label text="Degrade" justification="centred" font-size="18" max-height="40"/> + </View> + <View tab-caption="2" padding="0"> + <Label text="CHEW" justification="centred" font-size="18" max-height="40"/> + </View> + </View> + <View flex-direction="column"> + <Label max-height="40" text="Flutter" justification="centred" font-size="18"/> + <Slider caption="Depth" parameter="depth" slider-type="rotary" slider-textbox="textbox-below" + max-height="200"/> + <Slider caption="Rate" parameter="rate" slider-textbox="textbox-below" + slider-type="rotary" max-height="200"/> + </View> + </View> + </View> +</magic> diff --git a/Plugin/foleys_gui_magic b/Plugin/foleys_gui_magic @@ -0,0 +1 @@ +Subproject commit 0691e2342567259db532fc8578b3c3a80a6bc29f