NeuralPi

Raspberry Pi guitar pedal using neural networks to emulate real amps and effects
Log | Files | Refs | Submodules | README

PluginEditor.h (5859B)


      1 /*
      2   ==============================================================================
      3 
      4     This file was auto-generated!
      5 
      6     It contains the basic framework code for a JUCE plugin editor.
      7 
      8   ==============================================================================
      9 */
     10 
     11 #pragma once
     12 
     13 #include "../JuceLibraryCode/JuceHeader.h"
     14 #include "PluginProcessor.h"
     15 #include "AmpOSCReceiver.h"
     16 //#include "myLookAndFeel.h"
     17 #include <stdlib.h>
     18 
     19 //==============================================================================
     20 /**
     21 */
     22 class NeuralPiAudioProcessorEditor  : public AudioProcessorEditor,
     23                                       private Button::Listener,
     24                                       private Slider::Listener,
     25                                       private Value::Listener,
     26                                       private Label::Listener,
     27                                       private Timer
     28                                 
     29 {
     30 public:
     31     NeuralPiAudioProcessorEditor (NeuralPiAudioProcessor&);
     32     ~NeuralPiAudioProcessorEditor();
     33 
     34     //==============================================================================
     35     void paint (Graphics&) override;
     36     void resized() override;
     37 
     38     AmpOSCReceiver oscReceiver;
     39     OSCSender oscSender;
     40 
     41     String outgoingIP{ "127.0.0.1" };
     42     int outgoingPort{ 24024 };
     43     int incomingPort{ 25024 };
     44 
     45     String ampName{ "NeuralPi" };
     46     String gainAddressPattern{ "/parameter/NeuralPi/Gain" };
     47     String masterAddressPattern{ "/parameter/NeuralPi/Master" };
     48     String modelAddressPattern{ "/parameter/NeuralPi/Model" };
     49     String irAddressPattern{ "/parameter/NeuralPi/Ir" };
     50     String bassAddressPattern{ "/parameter/NeuralPi/Bass" };
     51     String midAddressPattern{ "/parameter/NeuralPi/Mid" };
     52     String trebleAddressPattern{ "/parameter/NeuralPi/Treble" };
     53     String presenceAddressPattern{ "/parameter/NeuralPi/Presence" };
     54     String delayAddressPattern{ "/parameter/NeuralPi/Delay" };
     55     String reverbAddressPattern{ "/parameter/NeuralPi/Reverb" };
     56 
     57     const String gainName{ "gain" };
     58     const String masterName{ "master" };
     59     const String bassName{ "bass" };
     60     const String midName{ "mid" };
     61     const String trebleName{ "treble" };
     62     const String presenceName{ "presence" };
     63     const String delayName{ "delay" };
     64     const String reverbName{ "reverb" };
     65 
     66     const String modelName{ "model" };
     67     const String irName{ "ir" };
     68 
     69     // For the FileChooser to load json models and IR files
     70     std::unique_ptr<FileChooser> myChooser;
     71 
     72 private:
     73     // This reference is provided as a quick way for your editor to
     74     // access the processor object that created it.
     75     NeuralPiAudioProcessor& processor;
     76 
     77     Image background = ImageCache::getFromMemory(BinaryData::npi_background_jpg, BinaryData::npi_background_jpgSize);
     78 
     79     // Amp Widgets
     80     Slider ampGainKnob;
     81     Slider ampMasterKnob;
     82     Slider modelKnob;
     83     Slider irKnob;
     84     //ImageButton ampOnButton;
     85     //ImageButton ampLED;
     86     ComboBox modelSelect;
     87     ComboBox irSelect;
     88     Slider ampBassKnob;
     89     Slider ampMidKnob;
     90     Slider ampTrebleKnob;
     91     Slider ampPresenceKnob;
     92     Slider ampDelayKnob;
     93     Slider ampReverbKnob;
     94 
     95     Label GainLabel;
     96     Label LevelLabel;
     97     Label BassLabel;
     98     Label MidLabel;
     99     Label TrebleLabel;
    100     Label PresenceLabel;
    101     Label DelayLabel;
    102     Label ReverbLabel;
    103     Label toneDropDownLabel;
    104     Label irDropDownLabel;
    105     Label versionLabel;
    106 
    107     File test_file;
    108     File model_folder;
    109 
    110     TextButton loadButton;
    111     TextButton loadIR;
    112     ToggleButton irButton;
    113     ToggleButton lstmButton;
    114 
    115     juce::LookAndFeel_V4 blueLookAndFeel;
    116     juce::LookAndFeel_V4 redLookAndFeel;
    117     
    118     juce::String fname;
    119     virtual void buttonClicked(Button* button) override;
    120     void modelSelectChanged();
    121     void loadButtonClicked();
    122     void updateToggleState(juce::Button* button, juce::String name);
    123     void irSelectChanged();
    124     void loadIRClicked();
    125     virtual void sliderValueChanged(Slider* slider) override;
    126 
    127 
    128     Label ampNameLabel{ {}, "Amp Name (no spaces): " };
    129     Label ampNameField{ {}, "NeuralPi" };
    130 
    131     Label ipLabel{ {}, "Target IP Address: " };
    132     Label ipField{ {}, "127.0.0.1" };
    133 
    134     Label outPortNumberLabel{ {}, "Outgoing OSC Port: " };
    135     Label outPortNumberField{ {}, "24024" };
    136 
    137     Label inPortNumberLabel{ {}, "Incoming OSC Port: " };
    138     Label inPortNumberField{ {}, "25024" };
    139 
    140     Label gainLabel{ {}, "Gain" };
    141     Label masterLabel{ {}, "Master" };
    142 
    143     Label modelLabel{ {}, "Model" };
    144 
    145     Label inConnectedLabel{ "(connected)" };
    146     Label outConnectedLabel{ "(connected)" };
    147 
    148     // OSC Messages
    149     Slider& getGainSlider();
    150     Slider& getMasterSlider();
    151     Slider& getModelSlider();
    152     Slider& getIrSlider();
    153     Slider& getBassSlider();
    154     Slider& getMidSlider();
    155     Slider& getTrebleSlider();
    156     Slider& getPresenceSlider();
    157     Slider& getDelaySlider();
    158     Slider& getReverbSlider();
    159 
    160     Label& getOutPortNumberField();
    161     Label& getInPortNumberField();
    162     Label& getIPField();
    163     Label& getAmpNameField();
    164     Label& getOutConnectedLabel();
    165     Label& getInConnectedLabel();
    166     void buildAddressPatterns();
    167     void connectSender();
    168     void updateOutgoingIP(String ip);
    169     void updateOutgoingPort(int port);
    170     void labelTextChanged(Label* labelThatHasChanged) override;
    171     void updateInConnectedLabel();
    172     void updateOutConnectedLabel(bool connected);
    173     // This callback is invoked if an OSC message has been received setting either value.
    174     void valueChanged(Value& value) override;
    175     void timerCallback() override;
    176 
    177     AudioProcessorParameter* getParameter(const String& paramId);
    178 
    179     float getParameterValue(const String& paramId);
    180     void setParameterValue(const String& paramId, float value);
    181     void setParamKnobColor();
    182 
    183     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NeuralPiAudioProcessorEditor)
    184 };