Deluge Firmware 1.3.0
Build date: 2025.04.16
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 StereoSample;
27class ModControllable;
28class InstrumentClip;
30class Song;
32class Kit;
33class Sound;
34class TimelineCounter;
35class NoteRow;
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
45class Instrument : public Output {
46public:
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 existsOnCard = 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
93protected:
94 Clip* createNewClipForArrangementRecording(ModelStack* modelStack) final;
95 Error setupDefaultAudioFileDir();
96};
Definition arpeggiator.h:46
Definition clip.h:46
Definition storage_manager.h:185
Definition instrument_clip.h:48
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:46
Definition timeline_counter.h:28
Definition stereo_sample.h:25