ToneControl.h (1348B)
1 #ifndef TONECONTROL_H_INCLUDED 2 #define TONECONTROL_H_INCLUDED 3 4 #include <JuceHeader.h> 5 6 using SmoothGain = SmoothedValue<float, ValueSmoothingTypes::Multiplicative>; 7 8 struct ToneStage 9 { 10 std::vector<chowdsp::ShelfFilter<float>> tone; 11 std::vector<SmoothGain> lowGain, highGain, tFreq; 12 float fs = 44100.0f; 13 14 ToneStage(); 15 16 void prepare (double sampleRate, int numChannels); 17 void processBlock (AudioBuffer<float>& buffer); 18 void setLowGain (float lowGainDB); 19 void setHighGain (float highGainDB); 20 void setTransFreq (float newTFreq); 21 }; 22 23 class ToneControl 24 { 25 public: 26 ToneControl (AudioProcessorValueTreeState& vts); 27 28 static void createParameterLayout (std::vector<std::unique_ptr<RangedAudioParameter>>& params); 29 void prepare (double sampleRate, int numChannels); 30 void setDBScale (float newDBScale) { dbScale = newDBScale; }; 31 32 void processBlockIn (AudioBuffer<float>& buffer); 33 void processBlockOut (AudioBuffer<float>& buffer); 34 35 private: 36 ToneStage toneIn, toneOut; 37 38 std::atomic<float>* onOffParam = nullptr; 39 chowdsp::FloatParameter* bassParam = nullptr; 40 chowdsp::FloatParameter* trebleParam = nullptr; 41 chowdsp::FloatParameter* tFreqParam = nullptr; 42 43 float dbScale = 1.0f; 44 45 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToneControl) 46 }; 47 48 #endif // TONECONTROL_H_INCLUDED