Deluge Firmware
1.3.0
Build date: 2026.08.29
Toggle main menu visibility
Loading...
Searching...
No Matches
instrument.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 "io/midi/learned_midi.h"
22
#include "model/clip/clip_instance_vector.h"
23
#include "model/output.h"
24
#include "storage/flash_storage.h"
25
26
class
StereoSample
;
27
class
ModControllable
;
28
class
InstrumentClip
;
29
class
ParamManagerForTimeline
;
30
class
Song
;
31
class
ArpeggiatorSettings
;
32
class
Kit
;
33
class
Sound
;
34
class
TimelineCounter
;
35
class
NoteRow
;
36
class
ModelStackWithTimelineCounter
;
37
class
ModelStackWithThreeMainThings
;
38
39
/*
40
* An Instrument is the “Output” of a Clip - the thing which turns the sequence or notes into sound (or MIDI or CV
41
* output). Instruments include Kit, MIDIInstrument, and CVInsttrument. And then there’s SoundInstrument, which is
42
* basically a synth.
43
*/
44
45
class
Instrument :
public
Output {
46
public
:
47
Instrument(OutputType newType) : Output(newType) {}
48
// This needs to be initialized / defaulted to "SYNTHS" or "KITS" (for those Instrument types). The constructor does
49
// not do this, partly because I don't want it doing memory allocation, and also because in many cases, the function
50
// creating the object hard-sets this anyway.
51
String
dirPath;
52
53
bool
editedByUser =
false
;
54
bool
mightExistOnCard =
false
;
55
bool
shouldHibernate{
true
};
56
bool
matchesPreset(OutputType otherType, int32_t channel, int32_t channelSuffix,
char
const
* otherName,
57
char
const
* otherPath)
override
{
58
bool
match{
false
};
59
if
(type == otherType) {
60
61
if
(otherType == OutputType::SYNTH || otherType == OutputType::KIT) {
62
match = !strcasecmp(otherName, name.get()) && !strcasecmp(otherPath, dirPath.get());
63
}
64
}
65
return
match;
66
}
67
virtual
bool
doAnySoundsUseCC(uint8_t channel, uint8_t ccNumber, uint8_t value) {
return
false
; }
68
virtual
void
beenEdited(
bool
shouldMoveToEmptySlot =
true
);
69
virtual
void
setupPatching(
ModelStackWithTimelineCounter
* modelStack) {
70
}
// You must call this when an Instrument comes into existence or something... for every Clip, not just for the
71
// activeClip
72
void
deleteAnyInstancesOfClip(
InstrumentClip
* clip);
73
74
// virtual void writeInstrumentDataToFile(bool savingSong, char const* slotName = "presetSlot", char const*
75
// subSlotName = "presetSubSlot");
76
bool
writeDataToFile(
Serializer
& writer,
Clip
* clipForSavingOutputOnly,
Song
* song)
override
;
77
bool
readTagFromFile(
Deserializer
& reader,
char
const
* tagName)
override
;
78
79
virtual
void
compensateInstrumentVolumeForResonance(
ModelStackWithThreeMainThings
* modelStack) {}
80
virtual
bool
isNoteRowStillAuditioningAsLinearRecordingEnded(
NoteRow
* noteRow) = 0;
81
virtual
void
processParamFromInputMIDIChannel(int32_t cc, int32_t newValue,
82
ModelStackWithTimelineCounter
* modelStack) = 0;
83
84
char
const
* getNameXMLTag()
override
{
return
"presetName"
; }
85
virtual
char
const
* getSlotXMLTag() {
return
"presetSlot"
; }
86
virtual
char
const
* getSubSlotXMLTag() {
return
"presetSubSlot"
; }
87
88
virtual
bool
isAnyAuditioningHappening() = 0;
89
90
uint8_t defaultVelocity = FlashStorage::defaultVelocity;
91
LearnedMIDI
midiInput;
92
93
protected
:
94
Clip
* createNewClipForArrangementRecording(
ModelStack
* modelStack)
final
;
95
Error setupDefaultAudioFileDir();
96
};
ArpeggiatorSettings
Definition
arpeggiator.h:48
Clip
Definition
clip.h:46
Deserializer
Definition
storage_manager.h:185
InstrumentClip
Definition
instrument_clip.h:48
Kit
Definition
kit.h:34
LearnedMIDI
Definition
learned_midi.h:30
ModControllable
Definition
mod_controllable.h:40
ModelStackWithThreeMainThings
Definition
model_stack.h:231
ModelStackWithTimelineCounter
Definition
model_stack.h:129
ModelStack
Definition
model_stack.h:123
NoteRow
Definition
note_row.h:99
ParamManagerForTimeline
Definition
param_manager.h:174
Serializer
Definition
storage_manager.h:119
Song
Definition
song.h:103
Sound
Definition
sound.h:71
String
Definition
d_string.h:41
TimelineCounter
Definition
timeline_counter.h:28
StereoSample
Definition
stereo_sample.h:25