PluginProcessor.h (5683B)
1 /* 2 ============================================================================== 3 4 This file was auto-generated! 5 6 It contains the basic framework code for a JUCE plugin processor. 7 8 ============================================================================== 9 */ 10 11 #include <nlohmann/json.hpp> 12 #include "RTNeuralLSTM.h" 13 #include "AmpOSCReceiver.h" 14 #include "Eq4Band.h" 15 #include "CabSim.h" 16 #include "Delay.h" 17 18 #pragma once 19 20 #include "../JuceLibraryCode/JuceHeader.h" 21 22 #define GAIN_ID "gain" 23 #define GAIN_NAME "Gain" 24 #define MODEL_ID "model" 25 #define MODEL_NAME "Model" 26 #define IR_ID "ir" 27 #define IR_NAME "Ir" 28 #define MASTER_ID "master" 29 #define MASTER_NAME "Master" 30 #define BASS_ID "bass" 31 #define BASS_NAME "Bass" 32 #define MID_ID "mid" 33 #define MID_NAME "Mid" 34 #define TREBLE_ID "treble" 35 #define TREBLE_NAME "Treble" 36 #define PRESENCE_ID "presence" 37 #define PRESENCE_NAME "Presence" 38 #define DELAY_ID "delay" 39 #define DELAY_NAME "Delay" 40 #define REVERB_ID "reverb" 41 #define REVERB_NAME "Reverb" 42 43 //============================================================================== 44 /** 45 */ 46 class NeuralPiAudioProcessor : public AudioProcessor 47 { 48 public: 49 //============================================================================== 50 NeuralPiAudioProcessor(); 51 ~NeuralPiAudioProcessor(); 52 53 //============================================================================== 54 void prepareToPlay (double sampleRate, int samplesPerBlock) override; 55 void releaseResources() override; 56 57 #ifndef JucePlugin_PreferredChannelConfigurations 58 bool isBusesLayoutSupported (const BusesLayout& layouts) const override; 59 #endif 60 61 void processBlock (AudioBuffer<float>&, MidiBuffer&) override; 62 63 //============================================================================== 64 AudioProcessorEditor* createEditor() override; 65 bool hasEditor() const override; 66 67 //============================================================================== 68 const String getName() const override; 69 70 bool acceptsMidi() const override; 71 bool producesMidi() const override; 72 bool isMidiEffect() const override; 73 double getTailLengthSeconds() const override; 74 75 //============================================================================== 76 int getNumPrograms() override; 77 int getCurrentProgram() override; 78 void setCurrentProgram (int index) override; 79 const String getProgramName (int index) override; 80 void changeProgramName (int index, const String& newName) override; 81 82 //============================================================================== 83 void getStateInformation (MemoryBlock& destData) override; 84 void setStateInformation (const void* data, int sizeInBytes) override; 85 86 int getModelIndex(float model_param); 87 int getIrIndex(float ir_param); 88 void loadConfig(File configFile); 89 void loadIR(File irFile); 90 void setupDataDirectories(); 91 void installTones(); 92 93 void set_ampEQ(float bass_slider, float mid_slider, float treble_slider, float presence_slider); 94 void set_delayParams(float paramValue); 95 void set_reverbParams(float paramValue); 96 97 float convertLogScale(float in_value, float x_min, float x_max, float y_min, float y_max); 98 99 float decibelToLinear(float dbValue); 100 101 void addDirectory(const File& file); 102 void addDirectoryIR(const File& file); 103 void resetDirectory(const File& file); 104 void resetDirectoryIR(const File& file); 105 std::vector<File> jsonFiles; 106 std::vector<File> irFiles; 107 File currentDirectory = File::getCurrentWorkingDirectory().getFullPathName(); 108 File userAppDataDirectory = File::getSpecialLocation(File::userDocumentsDirectory).getChildFile(JucePlugin_Manufacturer).getChildFile(JucePlugin_Name); 109 File userAppDataDirectory_tones = userAppDataDirectory.getFullPathName() + "/tones"; 110 File userAppDataDirectory_irs = userAppDataDirectory.getFullPathName() + "/irs"; 111 112 // Pedal/amp states 113 int amp_state = 1; // 0 = off, 1 = on 114 int custom_tone = 0; // 0 = custom tone loaded, 1 = default channel tone 115 File loaded_tone; 116 juce::String loaded_tone_name; 117 const char* char_filename = ""; 118 int model_loaded = 0; 119 int current_model_index = 0; 120 float num_models = 0.0; 121 int model_index = 0; // Used in processBlock when converting slider param to model index 122 bool lstm_state = true; 123 124 juce::String loaded_ir_name; 125 float num_irs = 0.0; 126 int ir_loaded = 0; 127 int custom_ir = 0; // 0 = custom tone loaded, 1 = default channel tone 128 File loaded_ir; 129 bool ir_state = true; 130 int current_ir_index = 0; 131 int ir_index = 0; 132 133 // The number of parameters for the model 134 // 0 is for a snap shot model 135 // The PluginEditor uses this to determin which knobs to color red 136 int params = 0; 137 138 RT_LSTM LSTM; 139 140 juce::dsp::Reverb::Parameters rev_params; 141 142 private: 143 var dummyVar; 144 Eq4Band eq4band; // Amp EQ 145 146 AudioParameterFloat* gainParam; 147 AudioParameterFloat* masterParam; 148 AudioParameterFloat* bassParam; 149 AudioParameterFloat* midParam; 150 AudioParameterFloat* trebleParam; 151 AudioParameterFloat* presenceParam; 152 AudioParameterFloat* modelParam; 153 AudioParameterFloat* irParam; 154 AudioParameterFloat* delayParam; 155 AudioParameterFloat* reverbParam; 156 157 dsp::IIR::Filter<float> dcBlocker; 158 159 // IR processing 160 CabSim cabSimIR; 161 162 // Effects 163 enum 164 { 165 delayIndex, 166 reverbIndex 167 }; 168 169 juce::dsp::ProcessorChain<Delay<float>, juce::dsp::Reverb> fxChain; 170 171 //============================================================================== 172 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NeuralPiAudioProcessor) 173 };