feat: humanize MIDI timing and dynamics with reproducible seeded edits

This commit is contained in:
Johannes Findeisen 2026-11-06 00:39:19 +01:00
commit d034417c8c
9 changed files with 51 additions and 7 deletions

View file

@ -46,7 +46,7 @@ xtc_result xtc_project_merge_midi(xtc_project *project,const uint64_t *ids,size_
* Swing durations stay fixed. LEGATO ends at the next strictly later onset in
* the same clip/channel (chords stay together), or source end for the last onset.
* Out-of-source results reject the complete operation. */
typedef enum { XTC_MIDI_TRANSFORM_SWING, XTC_MIDI_TRANSFORM_GATE, XTC_MIDI_TRANSFORM_LEGATO, XTC_MIDI_TRANSFORM_SCALE, XTC_MIDI_TRANSFORM_VELOCITY } xtc_midi_transform_type;
typedef enum { XTC_MIDI_TRANSFORM_SWING, XTC_MIDI_TRANSFORM_GATE, XTC_MIDI_TRANSFORM_LEGATO, XTC_MIDI_TRANSFORM_SCALE, XTC_MIDI_TRANSFORM_VELOCITY, XTC_MIDI_TRANSFORM_HUMANIZE } xtc_midi_transform_type;
typedef struct {
xtc_midi_transform_type type;
uint64_t grid;
@ -54,6 +54,8 @@ typedef struct {
unsigned int velocity_percent; /* VELOCITY: 0..400, rounded scaling then offset, clamp to 1..127. */
int velocity_offset; /* -127..127 */
unsigned int root,scale; /* SCALE: root 0..11 (C..B), scale 0 chromatic, 1 major, 2 natural minor; nearest ties lower. */
unsigned int seed; /* HUMANIZE: stable note-ID keyed 32-bit PRNG seed. */
unsigned int timing_variation,velocity_variation; /* 0..960 ticks, 0..127 velocity; source overflow rejects, velocity clamps. */
unsigned int gate_percent; /* GATE: 1..400, rounded length, minimum 1 tick. */
} xtc_midi_transform;
xtc_result xtc_project_transform_midi(xtc_project *project,const uint64_t *ids,size_t count,const xtc_midi_transform *edit);