Deluge Firmware 1.3.0
Build date: 2025.04.16
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/stereo_sample.h"
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(std::span<StereoSample> buffer, ParamManager* paramManager);
54 void processReverbSendAndVolume(std::span<StereoSample> buffer, int32_t* reverbBuffer, int32_t postFXVolume,
55 int32_t postReverbVolume, int32_t reverbSendAmount, int32_t pan = 0,
56 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(std::span<StereoSample> buffer, int32_t* postFXVolume, ParamManager* paramManager);
62 static void writeParamAttributesToFile(Serializer& writer, ParamManager* paramManager, bool writeAutomation,
63 int32_t* valuesForOverride = nullptr);
64 static void writeParamTagsToFile(Serializer& writer, ParamManager* paramManager, bool writeAutomation,
65 int32_t* valuesForOverride = nullptr);
66 static bool readParamTagFromFile(Deserializer& reader, char const* tagName, ParamManagerForTimeline* paramManager,
67 int32_t readAutomationUpToPos);
68 static void initParams(ParamManager* paramManager);
69 virtual void wontBeRenderedForAWhile();
70 void beginStutter(ParamManagerForTimeline* paramManager);
71 void endStutter(ParamManagerForTimeline* paramManager);
72 virtual ModFXType getModFXType() = 0;
73 virtual bool setModFXType(ModFXType newType);
74 bool offerReceivedCCToLearnedParamsForClip(MIDICable& cable, uint8_t channel, uint8_t ccNumber, uint8_t value,
75 ModelStackWithTimelineCounter* modelStack, int32_t noteRowIndex = -1);
76 bool offerReceivedCCToLearnedParamsForSong(MIDICable& cable, uint8_t channel, uint8_t ccNumber, uint8_t value,
77 ModelStackWithThreeMainThings* modelStackWithThreeMainThings);
78 bool offerReceivedPitchBendToLearnedParams(MIDICable& cable, uint8_t channel, uint8_t data1, uint8_t data2,
79 ModelStackWithTimelineCounter* modelStack, int32_t noteRowIndex = -1);
83 virtual bool learnKnob(MIDICable* cable, ParamDescriptor paramDescriptor, uint8_t whichKnob, uint8_t modKnobMode,
84 uint8_t midiChannel, Song* song);
85 bool unlearnKnobs(ParamDescriptor paramDescriptor, Song* song);
86 virtual void ensureInaccessibleParamPresetValuesWithoutKnobsAreZero(Song* song) {} // Song may be NULL
87 bool isBitcrushingEnabled(ParamManager* paramManager);
88 bool isSRREnabled(ParamManager* paramManager);
89 bool hasBassAdjusted(ParamManager* paramManager);
90 bool hasTrebleAdjusted(ParamManager* paramManager);
92
93 // EQ
94 int32_t bassFreq{}; // These two should eventually not be variables like this
95 int32_t trebleFreq{};
96
97 int32_t withoutTrebleL;
98 int32_t bassOnlyL;
99 int32_t withoutTrebleR;
100 int32_t bassOnlyR;
101
102 // Delay
103 Delay delay;
104 StutterConfig stutterConfig;
105
106 bool sampleRateReductionOnLastTime;
107 uint8_t clippingAmount; // Song probably doesn't currently use this?
108 FilterMode lpfMode;
109 FilterMode hpfMode;
110 FilterRoute filterRoute;
111
112 // Mod FX
113 ModFXType modFXType_;
114 ModFXProcessor modfx{};
115 RMSFeedbackCompressor compressor;
116 GranularProcessor* grainFX{nullptr};
117
118 uint32_t lowSampleRatePos{};
119 uint32_t highSampleRatePos{};
120 StereoSample lastSample;
121 StereoSample grabbedSample;
122 StereoSample lastGrabbedSample;
123
124 SideChain sidechain; // Song doesn't use this, despite extending this class
125
126 deluge::fast_vector<MIDIKnob> midi_knobs;
127 int32_t postReverbVolumeLastTime{};
128
129protected:
130 void processFX(std::span<StereoSample> buffer, ModFXType modFXType, int32_t modFXRate, int32_t modFXDepth,
131 const Delay::State& delayWorkingState, int32_t* postFXVolume, ParamManager* paramManager,
132 bool anySoundComingIn, q31_t reverbSendAmount);
133 void switchDelayPingPong();
134 void switchDelayAnalog();
135 void switchDelaySyncType();
136 void switchDelaySyncLevel();
137 void switchLPFMode();
138 void switchHPFMode();
139 void clearModFXMemory();
140
146
147 char const* getFilterTypeDisplayName(FilterType currentFilterType);
148 char const* getFilterModeDisplayName(FilterType currentFilterType);
149 char const* getLPFModeDisplayName();
150 char const* getHPFModeDisplayName();
151 char const* getDelayTypeDisplayName();
152 char const* getDelayPingPongStatusDisplayName();
153 char const* getDelaySyncTypeDisplayName();
154 void getDelaySyncLevelDisplayName(char* displayName);
155 char const* getSidechainDisplayName();
156
157 void displayFilterSettings(bool on, FilterType currentFilterType);
158 void displayDelaySettings(bool on);
159 void displaySidechainAndReverbSettings(bool on);
160 void displayOtherModKnobSettings(uint8_t whichModButton, bool on);
161
162protected:
163 // returns whether it succeeded
164 bool enableGrain();
165 void disableGrain();
166
167private:
168 void doEQ(bool doBass, bool doTreble, int32_t* inputL, int32_t* inputR, int32_t bassAmount, int32_t trebleAmount);
169 ModelStackWithThreeMainThings* addNoteRowIndexAndStuff(ModelStackWithTimelineCounter* modelStack,
170 int32_t noteRowIndex);
171 void switchHPFModeWithOff();
172 void switchLPFModeWithOff();
173
174 void processGrainFX(std::span<StereoSample> buffer, int32_t modFXRate, int32_t modFXDepth, int32_t* postFXVolume,
175 UnpatchedParamSet* unpatchedParams, bool anySoundComingIn, q31_t verbAmount);
176};
Definition arpeggiator.h:46
Definition clip.h:46
Definition delay.h:28
Definition storage_manager.h:185
Definition GranularProcessor.h:46
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:1488
deluge::modulation::params::Kind unpatchedParamKind_
Definition mod_controllable_audio.h:145
ModelStackWithAutoParam * getParamFromMIDIKnob(MIDIKnob &knob, ModelStackWithThreeMainThings *modelStack) override
Check that autoParam isn't NULL, after calling this.
Definition mod_controllable_audio.cpp:984
void displayOtherModKnobSettings(uint8_t whichModButton, bool on)
displays names of parameters assigned to gold knobs
Definition mod_controllable_audio.cpp:1665
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 rms_feedback.h:26
Definition storage_manager.h:119
Definition sidechain.h:27
Definition song.h:104
Definition param_set.h:98
Kind
Definition param.h:42
Definition delay.h:30
Definition stereo_sample.h:25
Definition stutterer.h:28