Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
non_audio_instrument.h
1/*
2 * Copyright © 2017-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 "model/instrument/melodic_instrument.h"
21#include "model/mod_controllable/mod_controllable.h"
22#include "storage/flash_storage.h"
23
24class ModelStack;
26
27class NonAudioInstrument : public MelodicInstrument, public ModControllable {
28public:
29 NonAudioInstrument(OutputType newType) : MelodicInstrument(newType) {
30 cachedBendRanges[BEND_RANGE_MAIN] = FlashStorage::defaultBendRange[BEND_RANGE_MAIN];
31 cachedBendRanges[BEND_RANGE_FINGER_LEVEL] = FlashStorage::defaultBendRange[BEND_RANGE_FINGER_LEVEL];
32 }
33
34 void renderOutput(ModelStack* modelStack, std::span<StereoSample> buffer, int32_t* reverbBuffer,
35 int32_t reverbAmountAdjust, int32_t sideChainHitPending, bool shouldLimitDelayFeedback,
36 bool isClipActive) override;
37 void sendNote(ModelStackWithThreeMainThings* modelStack, bool isOn, int32_t noteCode, int16_t const* mpeValues,
38 int32_t fromMIDIChannel = 16, uint8_t velocity = 64, uint32_t sampleSyncLength = 0,
39 int32_t ticksLate = 0, uint32_t samplesLate = 0) override;
40 int32_t doTickForwardForArp(ModelStack* modelStack, int32_t currentPos) final;
41 ParamManager* getParamManager(Song* song) final;
42
43 void polyphonicExpressionEventOnChannelOrNote(int32_t newValue, int32_t expressionDimension, int32_t channelOrNote,
44 MIDICharacteristic whichCharacteristic) final;
45
46 void beenEdited(bool shouldMoveToEmptySlot) override {} // Probably don't need this anymore...
47
48 char const* getSlotXMLTag() override { return "channel"; }
49 char const* getSubSlotXMLTag() override { return NULL; }
50
51 virtual void noteOnPostArp(int32_t noteCodePostArp, ArpNote* arpNote, int32_t noteIndex) = 0;
52 virtual void noteOffPostArp(int32_t noteCodePostArp, int32_t oldMIDIChannel, int32_t velocity,
53 int32_t noteIndex) = 0;
54
55 bool readTagFromFile(Deserializer& reader, char const* tagName) override;
56
57 ModControllable* toModControllable() override { return this; }
58 virtual void setChannel(int newChannel) { channel = newChannel; }
59 inline int32_t getChannel() const { return channel; }
60 // Cache these here just in case there's no ParamManager - because CVInstruments don't do backedUpParamManagers.
61 uint8_t cachedBendRanges[2];
62 bool needsEarlyPlayback() const override;
63
64protected:
65 virtual void polyphonicExpressionEventPostArpeggiator(int32_t newValue, int32_t noteCodeAfterArpeggiation,
66 int32_t expressionDimension, ArpNote* arpNote,
67 int32_t noteIndex) = 0;
68 // for tracking mono expression output
69 int32_t lastMonoExpression[3]{0};
70 int32_t lastCombinedPolyExpression[3]{0};
71 // could be int8 for aftertouch/Y but Midi 2 will allow those to be 14 bit too
72 int16_t lastOutputMonoExpression[3]{0};
73
74private:
75 int32_t channel = 0;
76};
Definition storage_manager.h:185
Definition model_stack.h:287
Definition model_stack.h:231
Definition model_stack.h:123
Definition param_manager.h:45
Definition song.h:104
Definition arpeggiator.h:142