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