Deluge Firmware 1.3.0
Build date: 2025.09.27
Loading...
Searching...
No Matches
mod_controllable_audio.h
1/*
2 * Copyright © 2016-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include "definitions_cxx.hpp"
21#include "deluge/dsp/granular/GranularProcessor.h"
22#include "dsp/compressor/rms_feedback.h"
23#include "dsp/delay/delay.h"
24#include "dsp_ng/core/types.hpp"
25#include "hid/button.h"
26#include "model/fx/stutterer.h"
27#include "model/mod_controllable/ModFXProcessor.h"
28#include "model/mod_controllable/filters/filter_config.h"
29#include "model/mod_controllable/mod_controllable.h"
30#include "modulation/knob.h"
31#include "modulation/lfo.h"
32#include "modulation/midi/midi_knob_array.h"
33#include "modulation/params/param_descriptor.h"
34#include "modulation/params/param_set.h"
35#include "modulation/sidechain/sidechain.h"
36
37class Clip;
38class Knob;
39class MIDICable;
40class ModelStack;
42class ParamManager;
43class Serializer;
44class Serializer;
45class Deserializer;
46
47class ModControllableAudio : public ModControllable {
48public:
49 ModControllableAudio();
50 virtual ~ModControllableAudio();
51 virtual void cloneFrom(ModControllableAudio* other);
52
53 void processStutter(deluge::dsp::StereoBuffer<q31_t> buffer, ParamManager* paramManager);
54 void processReverbSendAndVolume(deluge::dsp::StereoBuffer<q31_t> buffer, int32_t* reverbBuffer,
55 int32_t postFXVolume, int32_t postReverbVolume, int32_t reverbSendAmount,
56 int32_t pan = 0, bool doAmplitudeIncrement = false);
57 void writeAttributesToFile(Serializer& writer);
58 void writeTagsToFile(Serializer& writer);
59 virtual Error readTagFromFile(Deserializer& reader, char const* tagName, ParamManagerForTimeline* paramManager,
60 int32_t readAutomationUpToPos, ArpeggiatorSettings* arpSettings, Song* song);
61 void processSRRAndBitcrushing(deluge::dsp::StereoBuffer<q31_t> buffer, int32_t* postFXVolume,
62 ParamManager* paramManager);
63 static void writeParamAttributesToFile(Serializer& writer, ParamManager* paramManager, bool writeAutomation,
64 int32_t* valuesForOverride = nullptr);
65 static void writeParamTagsToFile(Serializer& writer, ParamManager* paramManager, bool writeAutomation,
66 int32_t* valuesForOverride = nullptr);
67 static bool readParamTagFromFile(Deserializer& reader, char const* tagName, ParamManagerForTimeline* paramManager,
68 int32_t readAutomationUpToPos);
69 static void initParams(ParamManager* paramManager);
70 virtual void wontBeRenderedForAWhile();
71 void beginStutter(ParamManagerForTimeline* paramManager);
72 void endStutter(ParamManagerForTimeline* paramManager);
73 virtual ModFXType getModFXType() = 0;
74 virtual bool setModFXType(ModFXType newType);
75 bool offerReceivedCCToLearnedParamsForClip(MIDICable& cable, uint8_t channel, uint8_t ccNumber, uint8_t value,
76 ModelStackWithTimelineCounter* modelStack, int32_t noteRowIndex = -1);
77 bool offerReceivedCCToLearnedParamsForSong(MIDICable& cable, uint8_t channel, uint8_t ccNumber, uint8_t value,
78 ModelStackWithThreeMainThings* modelStackWithThreeMainThings);
79 bool offerReceivedPitchBendToLearnedParams(MIDICable& cable, uint8_t channel, uint8_t data1, uint8_t data2,
80 ModelStackWithTimelineCounter* modelStack, int32_t noteRowIndex = -1);
84 virtual bool learnKnob(MIDICable* cable, ParamDescriptor paramDescriptor, uint8_t whichKnob, uint8_t modKnobMode,
85 uint8_t midiChannel, Song* song);
86 bool unlearnKnobs(ParamDescriptor paramDescriptor, Song* song);
87 virtual void ensureInaccessibleParamPresetValuesWithoutKnobsAreZero(Song* song) {} // Song may be NULL
88 bool isBitcrushingEnabled(ParamManager* paramManager);
89 bool isSRREnabled(ParamManager* paramManager);
90 bool hasBassAdjusted(ParamManager* paramManager);
91 bool hasTrebleAdjusted(ParamManager* paramManager);
93
94 // EQ
95 int32_t bassFreq{}; // These two should eventually not be variables like this
96 int32_t trebleFreq{};
97
98 int32_t withoutTrebleL;
99 int32_t bassOnlyL;
100 int32_t withoutTrebleR;
101 int32_t bassOnlyR;
102
103 // Delay
104 deluge::dsp::Delay delay;
105 StutterConfig stutterConfig;
106
107 bool sampleRateReductionOnLastTime;
108 uint8_t clippingAmount; // Song probably doesn't currently use this?
109 FilterMode lpfMode;
110 FilterMode hpfMode;
111 FilterRoute filterRoute;
112
113 // Mod FX
114 ModFXType modFXType_;
115 ModFXProcessor modfx{};
117 deluge::dsp::GranularProcessor* grainFX{nullptr};
118
119 uint32_t lowSampleRatePos{};
120 uint32_t highSampleRatePos{};
121 deluge::dsp::StereoSample<q31_t> lastSample;
122 deluge::dsp::StereoSample<q31_t> grabbedSample;
123 deluge::dsp::StereoSample<q31_t> lastGrabbedSample;
124
125 SideChain sidechain; // Song doesn't use this, despite extending this class
126
127 deluge::fast_vector<MIDIKnob> midi_knobs;
128 int32_t postReverbVolumeLastTime{};
129
130protected:
131 void processFX(deluge::dsp::StereoBuffer<q31_t> buffer, ModFXType modFXType, int32_t modFXRate, int32_t modFXDepth,
132 const deluge::dsp::Delay::State& delayWorkingState, int32_t* postFXVolume,
133 ParamManager* paramManager, bool anySoundComingIn, q31_t reverbSendAmount);
134 void switchDelayPingPong();
135 void switchDelayAnalog();
136 void switchDelaySyncType();
137 void switchDelaySyncLevel();
138 void switchLPFMode();
139 void switchHPFMode();
140 void clearModFXMemory();
141
147
148 char const* getFilterTypeDisplayName(FilterType currentFilterType);
149 char const* getFilterModeDisplayName(FilterType currentFilterType);
150 char const* getLPFModeDisplayName();
151 char const* getHPFModeDisplayName();
152 char const* getDelayTypeDisplayName();
153 char const* getDelayPingPongStatusDisplayName();
154 char const* getDelaySyncTypeDisplayName();
155 void getDelaySyncLevelDisplayName(char* displayName);
156 char const* getSidechainDisplayName();
157
158 void displayFilterSettings(bool on, FilterType currentFilterType);
159 void displayDelaySettings(bool on);
160 void displaySidechainAndReverbSettings(bool on);
161 void displayOtherModKnobSettings(uint8_t whichModButton, bool on);
162
163protected:
164 // returns whether it succeeded
165 bool enableGrain();
166 void disableGrain();
167
168private:
169 void doEQ(bool doBass, bool doTreble, int32_t* inputL, int32_t* inputR, int32_t bassAmount, int32_t trebleAmount);
170 ModelStackWithThreeMainThings* addNoteRowIndexAndStuff(ModelStackWithTimelineCounter* modelStack,
171 int32_t noteRowIndex);
172 void switchHPFModeWithOff();
173 void switchLPFModeWithOff();
174
175 void processGrainFX(deluge::dsp::StereoBuffer<q31_t> buffer, int32_t modFXRate, int32_t modFXDepth,
176 int32_t* postFXVolume, UnpatchedParamSet* unpatchedParams, bool anySoundComingIn,
177 q31_t verbAmount);
178};
Definition arpeggiator.h:46
Definition clip.h:46
Definition storage_manager.h:185
Definition knob.h:24
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition midi_device.h:94
Definition knob.h:34
virtual bool learnKnob(MIDICable *cable, ParamDescriptor paramDescriptor, uint8_t whichKnob, uint8_t modKnobMode, uint8_t midiChannel, Song *song)
Definition mod_controllable_audio.cpp:1506
deluge::modulation::params::Kind unpatchedParamKind_
Definition mod_controllable_audio.h:146
ModelStackWithAutoParam * getParamFromMIDIKnob(MIDIKnob &knob, ModelStackWithThreeMainThings *modelStack) override
Check that autoParam isn't NULL, after calling this.
Definition mod_controllable_audio.cpp:1002
void displayOtherModKnobSettings(uint8_t whichModButton, bool on)
displays names of parameters assigned to gold knobs
Definition mod_controllable_audio.cpp:1683
Definition ModFXProcessor.h:26
Definition model_stack.h:269
Definition model_stack.h:231
Definition model_stack.h:129
Definition model_stack.h:123
Definition param_descriptor.h:27
Definition param_manager.h:174
Definition param_manager.h:45
Definition storage_manager.h:119
Definition sidechain.h:27
Definition song.h:104
Definition param_set.h:98
Definition delay.h:30
Definition GranularProcessor.h:48
Definition rms_feedback.h:27
Kind
Definition param.h:42
Definition stutterer.h:27
Definition delay.h:32