i try it with pseudo code
Code: Select all
for each note:
old_start = note.start
quantize(note.start)
note.saved_distance = note.start - old_start
for each note:
if note.saved_distance != nil:
previous_note = find_previous_note(note)
previous_note.length += note.saved_distance - previous_note.saved_distance
previous_note.length = max(MIN_NOTE_LENGTH, previous_note.length)
it might take a key/beat ratio as another argument so it can know what note (what angle) to prefer
before quantizing there could have been placed the times into two 2d arrays
note_starts[key][start]
note_ends[key][end]
start and end being in low resolution
and it would look for the shortest path from the note_start to a note_end that satisfies that key/beat ratio
and it would look around (left and right, up/down in any case) in case it was gaps *or overlappings,
or it goes just left when you know you played staccato,
or just right when you know you played legato
or it doesn't do that search at all, it just cheaply walks a linked list of notes and does merely not what you'd expect at all
it's kinda complicated, maybe not existing in a daw at all