FFB.hpp (3228B)
1 #pragma once 2 3 #include "bogaudio.hpp" 4 #include "filters/multimode.hpp" 5 6 using namespace bogaudio::dsp; 7 8 extern Model* modelFFB; 9 10 namespace bogaudio { 11 12 struct FFB : BGModule { 13 enum ParamsIds { 14 LOWPASS_PARAM, 15 BAND_1_PARAM, 16 BAND_2_PARAM, 17 BAND_3_PARAM, 18 BAND_4_PARAM, 19 BAND_5_PARAM, 20 BAND_6_PARAM, 21 BAND_7_PARAM, 22 BAND_8_PARAM, 23 BAND_9_PARAM, 24 BAND_10_PARAM, 25 BAND_11_PARAM, 26 BAND_12_PARAM, 27 HIGHPASS_PARAM, 28 CV_PARAM, 29 NUM_PARAMS 30 }; 31 32 enum InputsIds { 33 IN_INPUT, 34 CV_INPUT, 35 NUM_INPUTS 36 }; 37 38 enum OutputsIds { 39 ALL_OUTPUT, 40 ODD_OUTPUT, 41 EVEN_OUTPUT, 42 NUM_OUTPUTS 43 }; 44 45 enum LightsIds { 46 NUM_LIGHTS 47 }; 48 49 struct Engine { 50 MultimodeFilter8 _lowPass; 51 FourPoleButtworthBandpassFilter _bandPasses[12]; 52 MultimodeFilter8 _highPass; 53 Amplifier _amplifiers[14]; 54 bogaudio::dsp::SlewLimiter _slews[14]; 55 float _semitonesOffset = 0.0f; 56 float _bandFrequencies[14] {}; 57 58 Engine() { 59 sampleRateChange(); 60 } 61 62 void sampleRateChange(); 63 void setSemitonesOffset(float semitonesOffset); 64 void configureBands(float sr, float semitonesOffset); 65 float bandFrequency(int i, float semitonesOffset); 66 }; 67 68 Engine* _engines[maxChannels] {}; 69 float _levels[14] {}; 70 71 FFB() { 72 config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); 73 configParam<AmplifierParamQuantity>(BAND_1_PARAM, 0.0f, 1.0f, 1.0f, "Band 1 level"); 74 configParam<AmplifierParamQuantity>(BAND_5_PARAM, 0.0f, 1.0f, 1.0f, "Band 5 level"); 75 configParam<AmplifierParamQuantity>(BAND_9_PARAM, 0.0f, 1.0f, 1.0f, "Band 9 level"); 76 configParam<AmplifierParamQuantity>(BAND_2_PARAM, 0.0f, 1.0f, 1.0f, "Band 2 level"); 77 configParam<AmplifierParamQuantity>(BAND_6_PARAM, 0.0f, 1.0f, 1.0f, "Band 6 level"); 78 configParam<AmplifierParamQuantity>(BAND_10_PARAM, 0.0f, 1.0f, 1.0f, "Band 10 level"); 79 configParam<AmplifierParamQuantity>(BAND_3_PARAM, 0.0f, 1.0f, 1.0f, "Band 3 level"); 80 configParam<AmplifierParamQuantity>(BAND_7_PARAM, 0.0f, 1.0f, 1.0f, "Band 7 level"); 81 configParam<AmplifierParamQuantity>(BAND_11_PARAM, 0.0f, 1.0f, 1.0f, "Band 11 level"); 82 configParam<AmplifierParamQuantity>(BAND_4_PARAM, 0.0f, 1.0f, 1.0f, "Band 4 level"); 83 configParam<AmplifierParamQuantity>(BAND_8_PARAM, 0.0f, 1.0f, 1.0f, "Band 8 level"); 84 configParam<AmplifierParamQuantity>(BAND_12_PARAM, 0.0f, 1.0f, 1.0f, "Band 12 level"); 85 configParam<AmplifierParamQuantity>(LOWPASS_PARAM, 0.0f, 1.0f, 1.0f, "Lowpass level"); 86 configParam(CV_PARAM, -1.0f, 1.0f, 0.0f, "Frequency offset", " semitones", 0.0f, 12.0f); 87 configParam<AmplifierParamQuantity>(HIGHPASS_PARAM, 0.0f, 1.0f, 1.0f, "Highpass level"); 88 configBypass(IN_INPUT, ALL_OUTPUT); 89 configBypass(IN_INPUT, ODD_OUTPUT); 90 configBypass(IN_INPUT, EVEN_OUTPUT); 91 92 configInput(IN_INPUT, "Signal"); 93 configInput(CV_INPUT, "Frequency CV"); 94 95 configOutput(ALL_OUTPUT, "All filters mix"); 96 configOutput(ODD_OUTPUT, "Odd filters mix"); 97 configOutput(EVEN_OUTPUT, "Even filters mix"); 98 } 99 100 void sampleRateChange() override; 101 bool active() override; 102 int channels() override; 103 void addChannel(int c) override; 104 void removeChannel(int c) override; 105 void modulate() override; 106 void modulateChannel(int c) override; 107 void processChannel(const ProcessArgs& args, int c) override; 108 }; 109 110 } // namespace bogaudio