SmartGuitarAmp

Guitar plugin made with JUCE that uses neural networks to emulate a tube amplifier
Log | Files | Refs | Submodules | README

commit 82570c764d5da9ebb0b2ded727cd8854540c4dce
parent 661f0470709f358024280f9c501e4be55f22b82f
Author: keith <[email protected]>
Date:   Mon, 12 Oct 2020 17:05:44 -0500

Added ability to save knob states after gui closes and reopens

Diffstat:
Mplugins/SmartAmp/Source/PluginEditor.cpp | 21++++++++++-----------
Mplugins/SmartAmp/Source/PluginProcessor.cpp | 16+++++++++++++++-
Mplugins/SmartAmp/Source/PluginProcessor.h | 11+++++++++++
3 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/plugins/SmartAmp/Source/PluginEditor.cpp b/plugins/SmartAmp/Source/PluginEditor.cpp @@ -44,13 +44,12 @@ WaveNetVaAudioProcessorEditor::WaveNetVaAudioProcessorEditor (WaveNetVaAudioProc 0.0); addAndMakeVisible(ampLED); - addAndMakeVisible(ampPresenceKnob); ampPresenceKnob.setLookAndFeel(&ampSilverKnobLAF); ampPresenceKnob.addListener(this); //ampPresenceKnob.setSkewFactorFromMidPoint(1000.0); // Not working because of custom lookAndFeel class ampPresenceKnob.setRange(-10.0, 10.0); - ampPresenceKnob.setValue(0.0); + ampPresenceKnob.setValue(processor.ampPresenceKnobState); ampPresenceKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag); ampPresenceKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 75, 20); ampPresenceKnob.setNumDecimalPlacesToDisplay(1); @@ -60,7 +59,7 @@ WaveNetVaAudioProcessorEditor::WaveNetVaAudioProcessorEditor (WaveNetVaAudioProc ampCleanBassKnob.setLookAndFeel(&ampSilverKnobLAF); ampCleanBassKnob.addListener(this); ampCleanBassKnob.setRange(-8.0, 8.0); - ampCleanBassKnob.setValue(0.0); + ampCleanBassKnob.setValue(processor.ampCleanBassKnobState); ampCleanBassKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag); ampCleanBassKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20); ampCleanBassKnob.setNumDecimalPlacesToDisplay(1); @@ -70,7 +69,7 @@ WaveNetVaAudioProcessorEditor::WaveNetVaAudioProcessorEditor (WaveNetVaAudioProc ampCleanMidKnob.setLookAndFeel(&ampSilverKnobLAF); ampCleanMidKnob.addListener(this); ampCleanMidKnob.setRange(-8.0, 8.0); - ampCleanMidKnob.setValue(0.0); + ampCleanMidKnob.setValue(processor.ampCleanMidKnobState); ampCleanMidKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag); ampCleanMidKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20); ampCleanMidKnob.setNumDecimalPlacesToDisplay(1); @@ -80,7 +79,7 @@ WaveNetVaAudioProcessorEditor::WaveNetVaAudioProcessorEditor (WaveNetVaAudioProc ampCleanTrebleKnob.setLookAndFeel(&ampSilverKnobLAF); ampCleanTrebleKnob.addListener(this); ampCleanTrebleKnob.setRange(-8.0, 8.0); - ampCleanTrebleKnob.setValue(0.0); + ampCleanTrebleKnob.setValue(processor.ampCleanTrebleKnobState); ampCleanTrebleKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag); ampCleanTrebleKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20); ampCleanTrebleKnob.setNumDecimalPlacesToDisplay(1); @@ -90,7 +89,7 @@ WaveNetVaAudioProcessorEditor::WaveNetVaAudioProcessorEditor (WaveNetVaAudioProc ampCleanGainKnob.setLookAndFeel(&ampSilverKnobLAF); ampCleanGainKnob.addListener(this); ampCleanGainKnob.setRange(0.0, 20.0); - ampCleanGainKnob.setValue(10.0); + ampCleanGainKnob.setValue(processor.ampCleanGainKnobState); ampCleanGainKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag); ampCleanGainKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20); ampCleanGainKnob.setNumDecimalPlacesToDisplay(1); @@ -100,7 +99,7 @@ WaveNetVaAudioProcessorEditor::WaveNetVaAudioProcessorEditor (WaveNetVaAudioProc ampLeadBassKnob.setLookAndFeel(&ampSilverKnobLAF); ampLeadBassKnob.addListener(this); ampLeadBassKnob.setRange(-8.0, 8.0); - ampLeadBassKnob.setValue(0.0); + ampLeadBassKnob.setValue(processor.ampLeadBassKnobState); ampLeadBassKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag); ampLeadBassKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20); ampLeadBassKnob.setNumDecimalPlacesToDisplay(1); @@ -110,7 +109,7 @@ WaveNetVaAudioProcessorEditor::WaveNetVaAudioProcessorEditor (WaveNetVaAudioProc ampLeadMidKnob.setLookAndFeel(&ampSilverKnobLAF); ampLeadMidKnob.addListener(this); ampLeadMidKnob.setRange(-8.0, 8.0); - ampLeadMidKnob.setValue(0.0); + ampLeadMidKnob.setValue(processor.ampLeadMidKnobState); ampLeadMidKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag); ampLeadMidKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20); ampLeadMidKnob.setNumDecimalPlacesToDisplay(1); @@ -120,7 +119,7 @@ WaveNetVaAudioProcessorEditor::WaveNetVaAudioProcessorEditor (WaveNetVaAudioProc ampLeadTrebleKnob.setLookAndFeel(&ampSilverKnobLAF); ampLeadTrebleKnob.addListener(this); ampLeadTrebleKnob.setRange(-8.0, 8.0); - ampLeadTrebleKnob.setValue(0.0); + ampLeadTrebleKnob.setValue(processor.ampCleanTrebleKnobState); ampLeadTrebleKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag); ampLeadTrebleKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20); ampLeadTrebleKnob.setNumDecimalPlacesToDisplay(1); @@ -130,7 +129,7 @@ WaveNetVaAudioProcessorEditor::WaveNetVaAudioProcessorEditor (WaveNetVaAudioProc ampLeadGainKnob.setLookAndFeel(&ampSilverKnobLAF); ampLeadGainKnob.addListener(this); ampLeadGainKnob.setRange(0.0, 20.0); - ampLeadGainKnob.setValue(10.0); + ampLeadGainKnob.setValue(processor.ampLeadGainKnobState); ampLeadGainKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag); ampLeadGainKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20); ampLeadGainKnob.setNumDecimalPlacesToDisplay(1); @@ -140,7 +139,7 @@ WaveNetVaAudioProcessorEditor::WaveNetVaAudioProcessorEditor (WaveNetVaAudioProc ampMasterKnob.setLookAndFeel(&ampSilverKnobLAF); ampMasterKnob.addListener(this); ampMasterKnob.setRange(-24.0, 0.0); - ampMasterKnob.setValue(-12.0); + ampMasterKnob.setValue(processor.ampMasterKnobState); ampMasterKnob.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag); ampMasterKnob.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 50, 20 ); ampMasterKnob.setNumDecimalPlacesToDisplay(1); diff --git a/plugins/SmartAmp/Source/PluginProcessor.cpp b/plugins/SmartAmp/Source/PluginProcessor.cpp @@ -239,25 +239,39 @@ float WaveNetVaAudioProcessor::convertLogScale(float in_value, float x_min, floa return converted_value; } - void WaveNetVaAudioProcessor::set_ampCleanDrive(float db_ampCleanDrive) { ampCleanDrive = decibelToLinear(db_ampCleanDrive); + ampCleanGainKnobState = db_ampCleanDrive; } void WaveNetVaAudioProcessor::set_ampLeadDrive(float db_ampLeadDrive) { ampLeadDrive = decibelToLinear(db_ampLeadDrive); + ampLeadGainKnobState = db_ampLeadDrive; } void WaveNetVaAudioProcessor::set_ampMaster(float db_ampMaster) { ampMaster = decibelToLinear(db_ampMaster); + ampMasterKnobState = db_ampMaster; } void WaveNetVaAudioProcessor::set_ampEQ(float bass_slider, float mid_slider, float treble_slider, float presence_slider) { eq4band.setParameters(bass_slider, mid_slider, treble_slider, presence_slider); + + // Set knob states for saving positions when closing/reopening GUI + if ( amp_lead == 1 ) { + ampCleanBassKnobState = bass_slider; + ampCleanMidKnobState = mid_slider; + ampCleanTrebleKnobState = treble_slider; + } else { + ampLeadBassKnobState = bass_slider; + ampLeadMidKnobState = mid_slider; + ampLeadTrebleKnobState = treble_slider; + } + ampPresenceKnobState = presence_slider; } float WaveNetVaAudioProcessor::decibelToLinear(float dbValue) diff --git a/plugins/SmartAmp/Source/PluginProcessor.h b/plugins/SmartAmp/Source/PluginProcessor.h @@ -75,6 +75,17 @@ public: int amp_state = 1; // 0 = off, 1 = on int amp_lead = 1; // 1 = clean, 0 = lead + // Amp knob states + float ampPresenceKnobState = 0.0; + float ampCleanBassKnobState = 0.0; + float ampCleanMidKnobState = 0.0; + float ampCleanTrebleKnobState = 0.0; + float ampCleanGainKnobState = 10.0; + float ampLeadBassKnobState = 0.0; + float ampLeadMidKnobState = 0.0; + float ampLeadTrebleKnobState = 0.0; + float ampLeadGainKnobState = 10.0; + float ampMasterKnobState = -12.0; private: WaveNet waveNet; // Amp Clean Channel / Lead Channel