20#include "model/note/note_locks.h"
34 bool operator==(
const NoteRef&)
const =
default;
50 [[nodiscard]]
bool armed()
const {
return song !=
nullptr; }
51 [[nodiscard]]
bool isFor(
const void* song_,
const void* clip_)
const {
return song == song_ && clip == clip_; }
53 [[nodiscard]]
bool matches(
const void* clip_, int32_t noteRowId_, uint32_t pos_)
const {
54 if (clip != clip_ || noteRowId != noteRowId_) {
58 uint32_t base = pos % wrapLevel;
59 uint32_t offset = pos_ % wrapLevel;
60 return (offset >= base ? offset - base : offset + wrapLevel - base) < length;
65 const void* song{
nullptr};
66 const void* clip{
nullptr};
70 uint32_t wrapLevel{1u << 31};
76 static constexpr int32_t kNumSlots = 8;
78 [[nodiscard]]
LiveEdit& operator[](int32_t slot) {
return slots_[slot]; }
84 void arm(int32_t slot,
const void* song,
const void* clip, int32_t noteRowId, uint32_t pos, uint32_t length,
85 uint32_t wrapLevel,
bool samePress =
false);
92 [[nodiscard]]
const LiveEdit*
find(
const void* clip, int32_t noteRowId, uint32_t pos)
const {
93 if (numArmed_ == 0) [[likely]] {
96 return findArmed(clip, noteRowId, pos);
102 [[nodiscard]]
const LiveEdit* findArmed(
const void* clip, int32_t noteRowId, uint32_t pos)
const;
104 std::array<LiveEdit, kNumSlots> slots_;
105 int32_t numArmed_{0};
106 uint16_t nextTag_{0};
132 if (live !=
nullptr ||
NoteRef{lockSet, 0} != pending.ref) [[unlikely]] {
133 open(pool, lockSet, live);
141 if (note != pending.ref) [[unlikely]] {
142 open(pool, note.lockSet, liveEdits.findByTag(note.liveTag));
149 if (opened_) [[unlikely]] {
150 pending = opened_->outer;
157 void open(
const Pool& pool, uint16_t lockSet,
const LiveEdit* live);
158 void openWith(
const LockSet& locks, NoteRef note);
164 std::optional<Opened> opened_;
The live-edit slots: one per clip-view edit pad press (kEditPadPressBufferSize), indexed like editPad...
Definition note_lock_playback.h:74
void disarm(int32_t slot)
Drops the slot's edits. Its tag stays, so re-arming the same press keeps reaching the voices it start...
Definition note_lock_playback.cpp:46
const LiveEdit * findByTag(uint16_t tag) const
The armed slot with this tag, or nullptr (also for tag 0).
Definition note_lock_playback.cpp:64
const LiveEdit * find(const void *clip, int32_t noteRowId, uint32_t pos) const
The armed slot covering this note, or nullptr. Cheap when no pad is held, which is how the sequencer ...
Definition note_lock_playback.h:92
void disarmAllOf(const void *owner)
Disarms every slot whose song or clip is owner (called as a Song / InstrumentClip is destroyed).
Definition note_lock_playback.cpp:56
void arm(int32_t slot, const void *song, const void *clip, int32_t noteRowId, uint32_t pos, uint32_t length, uint32_t wrapLevel, bool samePress=false)
Definition note_lock_playback.cpp:25
Definition note_locks.h:63
Makes one note's locks pending for as long as it's in scope, then puts back what was pending before.
Definition note_lock_playback.h:127
PendingScope(const Pool &pool, NoteRef note)
Definition note_lock_playback.h:140
PendingScope(const LockSet &locks, NoteRef note)
Definition note_lock_playback.h:147
PendingScope(const Pool &pool, uint16_t lockSet, const LiveEdit *live)
Definition note_lock_playback.h:131
The lock sets of every Note in one Song (or of the notes on the clipboard). Sets are only ever added.
Definition note_locks.h:113
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
LockSet currentLocks(const Pool &pool, NoteRef note)
Definition note_lock_playback.cpp:95
Definition note_lock_playback.h:46
bool matches(const void *clip_, int32_t noteRowId_, uint32_t pos_) const
Whether this slot's edits apply to the note at pos_ of that row.
Definition note_lock_playback.h:53
What something that plays a note later (an arpeggiator) remembers of its locks.
Definition note_lock_playback.h:30
Definition note_lock_playback.h:160
Definition note_lock_playback.h:116