Deluge Firmware 1.3.0
Build date: 2025.09.12
Loading...
Searching...
No Matches
kit.h
1/*
2 * Copyright © 2014-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 "dsp_ng/core/types.hpp"
22#include "model/global_effectable/global_effectable_for_clip.h"
23#include "model/instrument/instrument.h"
24#include "modulation/arpeggiator.h"
25class InstrumentClip;
26class Drum;
27class Sound;
28class SoundDrum;
29class NoteRow;
30class GateDrum;
31class ModelStack;
33enum class MIDIMatchType;
34class Kit final : public Instrument, public GlobalEffectableForClip {
35public:
36 Kit();
37
38 ArpeggiatorForKit arpeggiator;
39 ArpeggiatorSettings defaultArpSettings;
40
41 Drum* getNextDrum(Drum* fromSoundSource);
42 Drum* getPrevDrum(Drum* fromSoundSource);
43 bool writeDataToFile(Serializer& writer, Clip* clipForSavingOutputOnly, Song* song) override;
44 void addDrum(Drum* newDrum);
45 Error readFromFile(Deserializer& reader, Song* song, Clip* clip, int32_t readAutomationUpToPos) override;
46 Drum* getFirstUnassignedDrum(InstrumentClip* clip);
47 ~Kit() override;
48 int32_t getDrumIndex(Drum* drum);
49 Drum* getDrumFromIndex(int32_t index);
50 Drum* getDrumFromIndexAllowNull(int32_t index);
51
52 Error loadAllAudioFiles(bool mayActuallyReadFiles) override;
53 void cutAllSound() override;
54 void renderOutput(ModelStack* modelStack, deluge::dsp::StereoBuffer<q31_t> buffer, int32_t* reverbBuffer,
55 int32_t reverbAmountAdjust, int32_t sideChainHitPending, bool shouldLimitDelayFeedback,
56 bool isClipActive) override;
57
58 void offerReceivedCC(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, MIDICable& cable,
59 uint8_t channel, uint8_t ccNumber, uint8_t value, bool* doingMidiThru) override;
60 void receivedCCForKit(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, MIDICable& cable,
61 MIDIMatchType match, uint8_t channel, uint8_t ccNumber, uint8_t value, bool* doingMidiThru,
62 Clip* clip);
63 void offerReceivedCCToModControllable(MIDICable& cable, uint8_t channel, uint8_t ccNumber, uint8_t value,
65 void offerReceivedCCToLearnedParams(MIDICable& cable, uint8_t channel, uint8_t ccNumber, uint8_t value,
66 ModelStackWithTimelineCounter* modelStack) override;
67
68 void offerReceivedPitchBend(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, MIDICable& cable,
69 uint8_t channel, uint8_t data1, uint8_t data2, bool* doingMidiThru) override;
70 void receivedPitchBendForDrum(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, Drum* thisDrum,
71 uint8_t data1, uint8_t data2, MIDIMatchType match, uint8_t channel,
72 bool* doingMidiThru);
73 void receivedPitchBendForKit(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, MIDICable& cable,
74 MIDIMatchType match, uint8_t channel, uint8_t data1, uint8_t data2,
75 bool* doingMidiThru);
76 bool offerReceivedPitchBendToLearnedParams(MIDICable& cable, uint8_t channel, uint8_t data1, uint8_t data2,
77 ModelStackWithTimelineCounter* modelStack) override;
78
79 // drums don't receive other CCs
80 void receivedMPEYForDrum(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, Drum* thisDrum,
81 MIDIMatchType match, uint8_t channel, uint8_t value);
82
83 void offerReceivedAftertouch(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, MIDICable& cable,
84 int32_t channel, int32_t value, int32_t noteCode, bool* doingMidiThru) override;
85
86 void receivedAftertouchForDrum(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, Drum* thisDrum,
87 MIDIMatchType match, uint8_t channel, uint8_t value);
88
89 void receivedAftertouchForKit(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, MIDICable& cable,
90 MIDIMatchType match, int32_t channel, int32_t value, int32_t noteCode,
91 bool* doingMidiThru);
92
93 void offerReceivedNote(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, MIDICable& cable, bool on,
94 int32_t channel, int32_t note, int32_t velocity, bool shouldRecordNotes,
95 bool* doingMidiThru) override;
96 void receivedNoteForDrum(ModelStackWithTimelineCounter* modelStack, MIDICable& cable, bool on, int32_t channel,
97 int32_t note, int32_t velocity, bool shouldRecordNotes, bool* doingMidiThru,
98 Drum* thisDrum);
99 void receivedNoteForKit(ModelStackWithTimelineCounter* modelStack, MIDICable& cable, bool on, int32_t channel,
100 int32_t note, int32_t velocity, bool shouldRecordNotes, bool* doingMidiThru,
101 InstrumentClip* clip);
102
103 void processParamFromInputMIDIChannel(int32_t cc, int32_t newValue,
104 ModelStackWithTimelineCounter* modelStack) override {}
105
106 void beenEdited(bool shouldMoveToEmptySlot = true) override;
107 void choke();
108 void resyncLFOs() override;
109 void removeDrumFromKitArpeggiator(int32_t drumIndex);
110 void removeDrum(Drum* drum);
111 ModControllable* toModControllable() override;
112 SoundDrum* getDrumFromName(char const* name, bool onlyIfNoNoteRow = false);
113 Error makeDrumNameUnique(String* name, int32_t startAtNumber);
114 bool setActiveClip(ModelStackWithTimelineCounter* modelStack, PgmChangeSend maySendMIDIPGMs) override;
115 void setupPatching(ModelStackWithTimelineCounter* modelStack) override;
116 void compensateInstrumentVolumeForResonance(ParamManagerForTimeline* paramManager, Song* song);
117 void deleteBackedUpParamManagers(Song* song) override;
118 void prepareForHibernationOrDeletion() override;
119 int32_t doTickForwardForArp(ModelStack* modelStack, int32_t currentPos) override;
120 void loadCrucialAudioFilesOnly() override;
121 GateDrum* getGateDrumForChannel(int32_t gateChannel);
122 void resetDrumTempValues();
123 void setupWithoutActiveClip(ModelStack* modelStack) override;
124 void getThingWithMostReverb(Sound** soundWithMostReverb, ParamManager** paramManagerWithMostReverb,
125 GlobalEffectableForClip** globalEffectableWithMostReverb,
126 int32_t* highestReverbAmountFound) override;
127 uint8_t* getModKnobMode() override { return &modKnobMode; }
128 Output* toOutput() override { return this; }
129
130 bool isNoteRowStillAuditioningAsLinearRecordingEnded(NoteRow* noteRow) override;
131 bool allowNoteTails(NoteRow* noteRow);
132 void stopAnyAuditioning(ModelStack* modelStack) override;
133 bool isAnyAuditioningHappening() override;
134 void beginAuditioningforDrum(ModelStackWithNoteRow* modelStack, Drum* drum, int32_t velocity,
135 int16_t const* mpeValues, int32_t fromMIDIChannel = MIDI_CHANNEL_NONE);
136 void endAuditioningForDrum(ModelStackWithNoteRow* modelStack, Drum* drum, int32_t velocity = kDefaultLiftValue);
137 void offerBendRangeUpdate(ModelStack* modelStack, MIDICable& cable, int32_t channelOrZone, int32_t whichBendRange,
138 int32_t bendSemitones) override;
139
140 bool renderGlobalEffectableForClip(ModelStackWithTimelineCounter* modelStack,
141 deluge::dsp::StereoBuffer<q31_t> globalEffectableBuffer,
142 int32_t* bufferToTransferTo, int32_t* reverbBuffer, int32_t reverbAmountAdjust,
143 int32_t sideChainHitPending, bool shouldLimitDelayFeedback, bool isClipActive,
144 int32_t pitchAdjust, int32_t amplitudeAtStart, int32_t amplitudeAtEnd) override;
145
146 char const* getXMLTag() override { return "kit"; }
147
148 Drum* firstDrum;
149 Drum* selectedDrum;
150
151 OrderedResizeableArrayWith32bitKey drumsWithRenderingActive;
152
154 int32_t paramID, deluge::modulation::params::Kind paramKind,
155 bool affectEntire, bool useMenuStack) override;
157 int32_t paramID, deluge::modulation::params::Kind paramKind,
158 bool useMenuStack);
160 int32_t paramID,
162 bool useMenuStack);
163
164 Drum* getDrumFromNoteCode(InstrumentClip* clip, int32_t noteCode);
165
166 void noteOnPreKitArp(ModelStackWithThreeMainThings* modelStack, Drum* drum, uint8_t velocity,
167 int16_t const* mpeValues, int32_t fromMIDIChannel = MIDI_CHANNEL_NONE,
168 uint32_t sampleSyncLength = 0, int32_t ticksLate = 0, uint32_t samplesLate = 0);
169 void noteOffPreKitArp(ModelStackWithThreeMainThings* modelStack, Drum* drum, int32_t velocity = kDefaultLiftValue);
170
171protected:
172 bool isKit() override { return true; }
173
174private:
175 Error readDrumFromFile(Deserializer& reader, Song* song, Clip* clip, DrumType drumType,
176 int32_t readAutomationUpToPos);
177 void writeDrumToFile(Serializer& writer, Drum* thisDrum, ParamManager* paramManagerForDrum, bool savingSong,
178 int32_t* selectedDrumIndex, int32_t* drumIndex, Song* song);
179 void removeDrumFromLinkedList(Drum* drum);
180 void drumRemoved(Drum* drum);
181 void possiblySetSelectedDrumAndRefreshUI(Drum* thisDrum);
182
183 // Kit Arp
184 void setupAndRenderArpPreOutput(ModelStackWithTimelineCounter* modelStackWithTimelineCounter,
185 ParamManager* paramManager, deluge::dsp::StereoBuffer<q31_t> output);
186 ArpeggiatorSettings* getArpSettings(InstrumentClip* clip = nullptr);
187 void renderNonAudioArpPostOutput(deluge::dsp::StereoBuffer<q31_t> output);
188};
Definition arpeggiator.h:354
Definition arpeggiator.h:46
Definition clip.h:46
Definition storage_manager.h:185
Definition drum.h:44
Definition gate_drum.h:28
Definition instrument_clip.h:47
ModelStackWithAutoParam * getModelStackWithParam(ModelStackWithTimelineCounter *modelStack, Clip *clip, int32_t paramID, deluge::modulation::params::Kind paramKind, bool affectEntire, bool useMenuStack) override
for a kit we have two types of automation: with Affect Entire and without Affect Entire
Definition kit.cpp:1993
ModelStackWithAutoParam * getModelStackWithParamForKitRow(ModelStackWithTimelineCounter *modelStack, Clip *clip, int32_t paramID, deluge::modulation::params::Kind paramKind, bool useMenuStack)
Definition kit.cpp:2030
ModelStackWithAutoParam * getModelStackWithParamForKit(ModelStackWithTimelineCounter *modelStack, Clip *clip, int32_t paramID, deluge::modulation::params::Kind paramKind, bool useMenuStack)
Definition kit.cpp:2006
void receivedPitchBendForKit(ModelStackWithTimelineCounter *modelStackWithTimelineCounter, MIDICable &cable, MIDIMatchType match, uint8_t channel, uint8_t data1, uint8_t data2, bool *doingMidiThru)
for pitch bend received on a channel learnt to a whole clip
Definition kit.cpp:1725
bool offerReceivedPitchBendToLearnedParams(MIDICable &cable, uint8_t channel, uint8_t data1, uint8_t data2, ModelStackWithTimelineCounter *modelStack) override
Pitch bend is available in the mod matrix as X and shouldn't be learned to params anymore (post 4....
Definition kit.cpp:872
Drum * getDrumFromNoteCode(InstrumentClip *clip, int32_t noteCode)
find the drum matching the noteCode, counting up from 0
Definition kit.cpp:1706
void receivedCCForKit(ModelStackWithTimelineCounter *modelStackWithTimelineCounter, MIDICable &cable, MIDIMatchType match, uint8_t channel, uint8_t ccNumber, uint8_t value, bool *doingMidiThru, Clip *clip)
for learning a whole kit to a single channel, offer cc to all drums
Definition kit.cpp:1748
void receivedNoteForKit(ModelStackWithTimelineCounter *modelStack, MIDICable &cable, bool on, int32_t channel, int32_t note, int32_t velocity, bool shouldRecordNotes, bool *doingMidiThru, InstrumentClip *clip)
maps a note received on kit input channel to a drum. Note is zero indexed to first drum
Definition kit.cpp:1735
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition midi_device.h:94
Definition mod_controllable.h:40
Definition model_stack.h:269
Definition model_stack.h:189
Definition model_stack.h:231
Definition model_stack.h:129
Definition model_stack.h:123
Definition note_row.h:98
Definition ordered_resizeable_array.h:72
Definition param_manager.h:174
Definition param_manager.h:45
Definition storage_manager.h:119
Definition song.h:104
Definition sound_drum.h:28
Definition sound.h:71
Definition d_string.h:41
Kind
Definition param.h:42