Deluge Firmware 1.3.0
Build date: 2026.11.28
Loading...
Searching...
No Matches
note_lock_editor.h
1/*
2 * Copyright © 2026 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/note/note_locks.h"
21#include <cstdint>
22#include <optional>
23#include <utility>
24
27class NoteRow;
28class Sound;
30struct LiveEdit;
31}
32
34enum class HeldNoteLock : uint8_t {
35 NONE, // Not a lockable param of this clip, or no pads held: edit the param as usual
36 LOCK, // Lock it on the held notes that play this param's Sound
37 NO_NOTE, // A lockable param, but no held note plays its Sound (kit rows of other drums): leave it alone
38};
39
47class NoteLockEditor {
48public:
49 explicit NoteLockEditor(InstrumentClipView& clipView) : clipView_(clipView) {}
50
51 // Knob turns. While note pads are held, a turn of a lockable (local patched) param of this clip only ever sets
52 // parameter locks, never step automation - from the mod knobs, MIDI follow and MIDI-learned knobs alike.
53
56 HeldNoteLock getHeldValue(ModelStackWithAutoParam* modelStack, int32_t* value);
59 bool setHeldValue(ModelStackWithAutoParam* modelStack, int32_t value);
62 [[nodiscard]] bool automatesHeldNotes(ModelStackWithAutoParam const* modelStack);
64 bool takeNotLockableNotice() { return std::exchange(notLockableNoticeDue_, false); }
65
66 // Edit pad presses
67
70 void arm(int32_t i, bool samePress = false);
71 void rearmAll();
74 void commit(int32_t i);
75 void commitAll();
76
78 struct HeldNote {
79 uint16_t lockSet{0};
80 const deluge::note_locks::LiveEdit* live{nullptr};
81 };
82 [[nodiscard]] HeldNote getHeldNote(int32_t yDisplay);
84 [[nodiscard]] bool heldNoteLocksSustain(int32_t yDisplay);
85
86 // The note editor's "Param locks" menu. Edits apply to every note the note editor is targeting (held or remembered
87 // pads), like the editor's other note parameters, each as its own undo step.
88
91 bool setMenuLock(int32_t param, int32_t value);
92 bool removeMenuLock(int32_t param);
93 bool clearMenuLocks();
94
95private:
96 struct PressedRow {
97 Sound* sound;
98 NoteRow* row;
99 int32_t noteRowId;
100 };
101
102 [[nodiscard]] std::optional<PressedRow> getRowOfPress(int32_t i);
103 [[nodiscard]] uint16_t getCommittedLockSet(int32_t i);
105 [[nodiscard]] bool editsHeldNotes(ModelStackWithAutoParam const* modelStack);
106 [[nodiscard]] int32_t findPressesFor(ModelStackWithAutoParam const* modelStack, bool* matches);
107 template <typename Change>
108 bool changeMenuLocks(Change change);
109
110 InstrumentClipView& clipView_;
111 bool notLockableNoticeDue_{false};
112};
Definition instrument_clip_view.h:84
Definition model_stack.h:264
bool setHeldValue(ModelStackWithAutoParam *modelStack, int32_t value)
Definition note_lock_editor.cpp:305
deluge::note_locks::LockSet getMenuLocks()
The left-most targeted note's locks, with any pending edits.
Definition note_lock_editor.cpp:345
bool editsHeldNotes(ModelStackWithAutoParam const *modelStack)
Pads are held in the clip view, and this is one of its params a held-pad knob turn edits.
Definition note_lock_editor.cpp:245
bool heldNoteLocksSustain(int32_t yDisplay)
The note held in this row locks a sustain (committed or still live), so it has a tail even on a sound...
Definition note_lock_editor.cpp:219
bool takeNotLockableNotice()
True once per pad press: show the "not lockable" notice before the automated value.
Definition note_lock_editor.h:64
HeldNoteLock getHeldValue(ModelStackWithAutoParam *modelStack, int32_t *value)
Definition note_lock_editor.cpp:284
bool automatesHeldNotes(ModelStackWithAutoParam const *modelStack)
Definition note_lock_editor.cpp:254
void arm(int32_t i, bool samePress=false)
Definition note_lock_editor.cpp:152
void commit(int32_t i)
Definition note_lock_editor.cpp:167
std::optional< PressedRow > getRowOfPress(int32_t i)
The row press i is in, if it plays a Sound (a synth, or a kit's sound drum).
Definition note_lock_editor.cpp:136
Definition note_row.h:106
Definition sound.h:78
Definition note_locks.h:63
How a note's parameter locks (note_locks.h) get from the sequencer to the Voice that plays the note.
Definition note_lock_editor.h:29
What the audition of a held note in this row plays with: the note's committed set,...
Definition note_lock_editor.h:78
Definition note_lock_editor.h:96
Definition note_lock_playback.h:46