Phase 21: add filtered MIDI composition edits and triplet piano-roll grids

This commit is contained in:
Johannes Findeisen 2026-10-27 15:34:54 +01:00
commit 73fc5eea8d
12 changed files with 796 additions and 39 deletions

View file

@ -16,6 +16,31 @@ typedef struct {
unsigned int pitch, velocity, channel; /* 0..127, 1..127, 0..15. */
} xtc_note_info;
/* Control-thread batch edits. UINT64_MAX selects all notes in the clip;
* channel -1 selects all channels. Pitch bounds are inclusive. */
typedef struct {
uint64_t clip_id, note_id;
int channel;
unsigned int pitch_min, pitch_max;
} xtc_note_filter;
typedef enum { XTC_NOTES_EDIT, XTC_NOTES_REPEAT, XTC_NOTES_DELETE } xtc_note_action;
typedef struct {
xtc_note_action action;
uint64_t grid_tick; /* 0 preserves start; nearest grid, ties round later. */
int transpose; /* -127..127; out-of-range pitches reject the entire edit. */
int velocity, channel; /* -1 preserves, otherwise 1..127 / 0..15. */
unsigned int copies; /* REPEAT only: 1..4096 additional copies. */
uint64_t interval_tick; /* REPEAT only: positive spacing between copies. */
} xtc_note_edit;
/* Atomic validation then mutation; no partial edits or consumed IDs on failure.
* EDIT keeps IDs/durations. REPEAT leaves originals untouched and gives copies
* fresh IDs, transformed then offset by k*interval. DELETE uses only action.
* No matches returns NOT_FOUND. All notes must fit the existing source length;
* nothing is clamped, extended or merged. out_count is unchanged on failure,
* and reports original matched notes on success. No callback-thread use. */
xtc_result xtc_project_edit_notes(xtc_project *project, const xtc_note_filter *filter,
const xtc_note_edit *edit, size_t *out_count);
typedef enum {
XTC_MIDI_NOTE_ON = 1,
XTC_MIDI_NOTE_OFF,
@ -99,9 +124,9 @@ xtc_result xtc_project_edit_note(xtc_project *project, uint64_t id, uint64_t sta
* @return XTC_OK on success, or an error code describing the failure.
*/
xtc_result xtc_project_remove_note(xtc_project *project, uint64_t id);
/* Complete 3-byte note on/off and CC120/123 only. Velocity-zero on -> off.
/* Complete 3-byte note on/off and CC7/10/64/120/123. Velocity-zero on -> off.
* Unsupported messages return UNSUPPORTED; malformed supported messages INVALID.
* Output unchanged on error. No running-status/SysEx/pedal/program/bend support. */
* Output unchanged on error. No running-status/SysEx/program/bend support. */
/**
* @brief Decodes a complete note or all-notes-off MIDI message into a block event.
*