Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
melodic_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 "io/midi/learned_midi.h"
21#include "model/instrument/instrument.h"
22#include "modulation/arpeggiator.h"
23#include "util/containers.h"
24
25class PostArpTriggerable;
26class NoteRow;
29
30class MelodicInstrument : public Instrument {
31public:
32 explicit MelodicInstrument(OutputType newType) : Instrument(newType) {}
33
34 // Check activeClip before you call!
35 // mpeValues must be provided for a note-on (can be 0s). Otherwise, can be NULL pointer
36 virtual void sendNote(ModelStackWithThreeMainThings* modelStack, bool isOn, int32_t noteCode,
37 int16_t const* mpeValues, int32_t fromMIDIChannel = MIDI_CHANNEL_NONE, uint8_t velocity = 64,
38 uint32_t sampleSyncLength = 0, int32_t ticksLate = 0, uint32_t samplesLate = 0) = 0;
39
40 virtual void ccReceivedFromInputMIDIChannel(int32_t cc, int32_t value, ModelStackWithTimelineCounter* modelStack) {}
41
42 bool writeMelodicInstrumentAttributesToFile(Serializer& writer, Clip* clipForSavingOutputOnly, Song* song);
43 void writeMelodicInstrumentTagsToFile(Serializer& writer, Clip* clipForSavingOutputOnly, Song* song);
44 bool readTagFromFile(Deserializer& reader, char const* tagName) override;
45
46 void offerReceivedNote(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, MIDICable& cable, bool on,
47 int32_t channel, int32_t note, int32_t velocity, bool shouldRecordNotes,
48 bool* doingMidiThru) override;
49 void receivedNote(ModelStackWithTimelineCounter* modelStack, MIDICable& cable, bool on, int32_t midiChannel,
50 MIDIMatchType match, int32_t note, int32_t velocity, bool shouldRecordNotes, bool* doingMidiThru);
51 void offerReceivedPitchBend(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, MIDICable& cable,
52 uint8_t channel, uint8_t data1, uint8_t data2, bool* doingMidiThru) override;
53 void receivedPitchBend(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, MIDICable& cable,
54 MIDIMatchType match, uint8_t channel, uint8_t data1, uint8_t data2, bool* doingMidiThru);
55 void offerReceivedCC(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, MIDICable& cable,
56 uint8_t channel, uint8_t ccNumber, uint8_t value, bool* doingMidiThru) override;
57 void receivedCC(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, MIDICable& cable, MIDIMatchType match,
58 uint8_t channel, uint8_t ccNumber, uint8_t value, bool* doingMidiThru);
59 void offerReceivedAftertouch(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, MIDICable& cable,
60 int32_t channel, int32_t value, int32_t noteCode, bool* doingMidiThru) override;
61 void receivedAftertouch(ModelStackWithTimelineCounter* modelStackWithTimelineCounter, MIDICable& cable,
62 MIDIMatchType match, int32_t channel, int32_t value, int32_t noteCode, bool* doingMidiThru);
63 bool setActiveClip(ModelStackWithTimelineCounter* modelStack, PgmChangeSend maySendMIDIPGMs) override;
64 bool isNoteRowStillAuditioningAsLinearRecordingEnded(NoteRow* noteRow) final;
65 void stopAnyAuditioning(ModelStack* modelStack) final;
66 bool isNoteAuditioning(int32_t noteCode);
67 bool isAnyAuditioningHappening() final;
68 void beginAuditioningForNote(ModelStack* modelStack, int32_t note, int32_t velocity, int16_t const* mpeValues,
69 int32_t fromMIDIChannel = MIDI_CHANNEL_NONE, uint32_t sampleSyncLength = 0);
70 void endAuditioningForNote(ModelStack* modelStack, int32_t note, int32_t velocity = kDefaultLiftValue);
71 virtual ModelStackWithAutoParam* getParamToControlFromInputMIDIChannel(int32_t cc,
73 void processParamFromInputMIDIChannel(int32_t cc, int32_t newValue,
74 ModelStackWithTimelineCounter* modelStack) override;
75
76 void polyphonicExpressionEventPossiblyToRecord(ModelStackWithTimelineCounter* modelStack, int32_t newValue,
77 int32_t expressionDimension, int32_t channelOrNoteNumber,
78 MIDICharacteristic whichCharacteristic);
79 ArpeggiatorSettings* getArpSettings(InstrumentClip* clip = nullptr);
80
81 virtual void polyphonicExpressionEventOnChannelOrNote(int32_t newValue, int32_t expressionDimension,
82 int32_t channelOrNoteNumber,
83 MIDICharacteristic whichCharacteristic) = 0;
84
85 void offerBendRangeUpdate(ModelStack* modelStack, MIDICable& cable, int32_t channelOrZone, int32_t whichBendRange,
86 int32_t bendSemitones) override;
87
88 Arpeggiator arpeggiator;
89
91 uint8_t velocity;
92 bool still_active = false;
93 };
94
95 deluge::fast_map<int16_t, EarlyNoteInfo> earlyNotes; // note value, velocity, still_active
96 deluge::fast_map<int16_t, EarlyNoteInfo> notesAuditioned;
97
98 ModelStackWithAutoParam* getModelStackWithParam(ModelStackWithTimelineCounter* modelStack, Clip* clip,
99 int32_t paramID, deluge::modulation::params::Kind paramKind,
100 bool affectEntire, bool useMenuStack) override;
101
102private:
103 void possiblyRefreshAutomationEditorGrid(int32_t ccNumber);
104};
Definition arpeggiator.h:46
Definition arpeggiator.h:310
Definition clip.h:46
Definition storage_manager.h:185
Definition instrument_clip.h:48
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition midi_device.h:94
Definition model_stack.h:269
Definition model_stack.h:231
Definition model_stack.h:129
Definition model_stack.h:123
Definition note_row.h:98
Definition storage_manager.h:119
Definition song.h:104
Kind
Definition param.h:42
Definition melodic_instrument.h:90