Deluge Firmware 1.3.0
Build date: 2025.04.16
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/stereo_sample.h"
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, std::span<StereoSample> 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 ArpeggiatorSettings* getArpSettings(InstrumentClip* clip = nullptr);
107 void beenEdited(bool shouldMoveToEmptySlot = true) override;
108 void choke();
109 void resyncLFOs() override;
110 void removeDrumFromKitArpeggiator(int32_t drumIndex);
111 void removeDrum(Drum* drum);
112 ModControllable* toModControllable() override;
113 SoundDrum* getDrumFromName(char const* name, bool onlyIfNoNoteRow = false);
114 Error makeDrumNameUnique(String* name, int32_t startAtNumber);
115 bool setActiveClip(ModelStackWithTimelineCounter* modelStack, PgmChangeSend maySendMIDIPGMs) override;
116 void setupPatching(ModelStackWithTimelineCounter* modelStack) override;
117 void compensateInstrumentVolumeForResonance(ParamManagerForTimeline* paramManager, Song* song);
118 void deleteBackedUpParamManagers(Song* song) override;
119 void prepareForHibernationOrDeletion() override;
120 int32_t doTickForwardForArp(ModelStack* modelStack, int32_t currentPos) override;
121 void loadCrucialAudioFilesOnly() override;
122 GateDrum* getGateDrumForChannel(int32_t gateChannel);
123 void resetDrumTempValues();
124 void setupWithoutActiveClip(ModelStack* modelStack) override;
125 void getThingWithMostReverb(Sound** soundWithMostReverb, ParamManager** paramManagerWithMostReverb,
126 GlobalEffectableForClip** globalEffectableWithMostReverb,
127 int32_t* highestReverbAmountFound) override;
128 uint8_t* getModKnobMode() override { return &modKnobMode; }
129 Output* toOutput() override { return this; }
130
131 bool isNoteRowStillAuditioningAsLinearRecordingEnded(NoteRow* noteRow) override;
132 bool allowNoteTails(NoteRow* noteRow);
133 void stopAnyAuditioning(ModelStack* modelStack) override;
134 bool isAnyAuditioningHappening() override;
135 void beginAuditioningforDrum(ModelStackWithNoteRow* modelStack, Drum* drum, int32_t velocity,
136 int16_t const* mpeValues, int32_t fromMIDIChannel = MIDI_CHANNEL_NONE);
137 void endAuditioningForDrum(ModelStackWithNoteRow* modelStack, Drum* drum, int32_t velocity = kDefaultLiftValue);
138 void offerBendRangeUpdate(ModelStack* modelStack, MIDICable& cable, int32_t channelOrZone, int32_t whichBendRange,
139 int32_t bendSemitones) override;
140
141 bool renderGlobalEffectableForClip(ModelStackWithTimelineCounter* modelStack,
142 std::span<StereoSample> globalEffectableBuffer, int32_t* bufferToTransferTo,
143 int32_t* reverbBuffer, int32_t reverbAmountAdjust, int32_t sideChainHitPending,
144 bool shouldLimitDelayFeedback, bool isClipActive, int32_t pitchAdjust,
145 int32_t amplitudeAtStart, int32_t amplitudeAtEnd) override;
146
147 char const* getXMLTag() override { return "kit"; }
148
149 Drum* firstDrum;
150 Drum* selectedDrum;
151
152 OrderedResizeableArrayWith32bitKey drumsWithRenderingActive;
153
155 int32_t paramID, deluge::modulation::params::Kind paramKind,
156 bool affectEntire, bool useMenuStack) override;
158 int32_t paramID, deluge::modulation::params::Kind paramKind,
159 bool useMenuStack);
161 int32_t paramID,
163 bool useMenuStack);
164
165 Drum* getDrumFromNoteCode(InstrumentClip* clip, int32_t noteCode);
166
167 void noteOnPreKitArp(ModelStackWithThreeMainThings* modelStack, Drum* drum, uint8_t velocity,
168 int16_t const* mpeValues, int32_t fromMIDIChannel = MIDI_CHANNEL_NONE,
169 uint32_t sampleSyncLength = 0, int32_t ticksLate = 0, uint32_t samplesLate = 0);
170 void noteOffPreKitArp(ModelStackWithThreeMainThings* modelStack, Drum* drum, int32_t velocity = kDefaultLiftValue);
171
172protected:
173 bool isKit() override { return true; }
174
175private:
176 Error readDrumFromFile(Deserializer& reader, Song* song, Clip* clip, DrumType drumType,
177 int32_t readAutomationUpToPos);
178 void writeDrumToFile(Serializer& writer, Drum* thisDrum, ParamManager* paramManagerForDrum, bool savingSong,
179 int32_t* selectedDrumIndex, int32_t* drumIndex, Song* song);
180 void removeDrumFromLinkedList(Drum* drum);
181 void drumRemoved(Drum* drum);
182 void possiblySetSelectedDrumAndRefreshUI(Drum* thisDrum);
183};
Definition arpeggiator.h:334
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:48
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:1914
ModelStackWithAutoParam * getModelStackWithParamForKitRow(ModelStackWithTimelineCounter *modelStack, Clip *clip, int32_t paramID, deluge::modulation::params::Kind paramKind, bool useMenuStack)
Definition kit.cpp:1951
ModelStackWithAutoParam * getModelStackWithParamForKit(ModelStackWithTimelineCounter *modelStack, Clip *clip, int32_t paramID, deluge::modulation::params::Kind paramKind, bool useMenuStack)
Definition kit.cpp:1927
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:1646
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:820
Drum * getDrumFromNoteCode(InstrumentClip *clip, int32_t noteCode)
find the drum matching the noteCode, counting up from 0
Definition kit.cpp:1627
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:1669
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:1656
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:46
Kind
Definition param.h:42