![]() |
Deluge Firmware 1.3.0
Build date: 2026.11.28
|
#include <note_regrouper.h>

Public Member Functions | |
| NoteRegrouper (InstrumentClip &clip, ModelStackWithTimelineCounter *modelStack) | |
| The song's key (modelStack->song->key) must still be the one from before the change. | |
| bool | regroup (const ScaleChange &change, deluge::accidentals::AccidentalHandling handling, int32_t pendingTranspose=0) |
Private Types | |
| using | RowFlags = deluge::vector<uint8_t> |
| One flag per NoteRow: whether its pitch was in the key before the change. | |
Private Member Functions | |
| bool | moveWholeRows (const ScaleChange &change, const MusicalKey &oldKey, const MusicalKey &finalKey, int32_t pendingTranspose) |
| bool | sortAndMergeRows (RowFlags &wasInScale) |
| void | moveRow (NoteRow *row, int32_t rowIndex, int32_t newY) |
Private Attributes | |
| InstrumentClip & | clip_ |
| ModelStackWithTimelineCounter * | modelStack_ |
Moves the notes of a scale-mode clip for a scale change which shifts or remaps scale degrees.
Notes are moved one at a time (see model/scale/accidentals.h), so that notes which an earlier scale change put in the same NoteRow split back out again. In-key notes go where their scale degree goes; accidentals (notes outside the scale, or carrying an AnchorMarker) go where their anchor takes them. Rows can then land on or cross each other, so the rows are sorted again and rows with the same pitch merged.
None of this is undoable.
|
private |
The cheap way, for a clip with no accidentals: every row moves as a whole by its scale degree's shift, with no memory allocated and no note touched. Returns false, having changed nothing, unless that is exactly what the per-note way would do, which is when:
|
nodiscard |
Applies the change, whose target is the scale after it. Doesn't touch the clip's yScroll.
pendingTranspose is a uniform shift in semitones which the caller is still to apply to every row and to the key's root afterwards (in-key transposition does this): markers are chosen for the key as it will be then.
Returns whether rows were restructured: notes changed NoteRow, or rows merged. Undo history made before that finds its notes by row, so it is stale and must not be reverted (see ActionLogger::invalidateLogs()).
|
private |
Restores ascending y order of the rows (which are binary-searched) after they have been moved, and merges rows which ended up with the same y. The survivor of a merge is the row that was in scale, else the one with more notes. Returns whether any rows were merged.