music/daw/reaper/ MidiHoldNoteScript1
This only works if input is on channel 1 (i.e. note on is status 0x90
).
desc: JDA MIDI Note Hold
// only works properly for notes with channel 0.
// else we'd need to have one held-note per channel
in_pin:none
out_pin:none
@init
held_note = -1;
@block
while (
midirecv(mpos, msg1, msg23) ? (
status = msg1;
statusHi = (msg1/16)|0;
statusLo = msg1-(statusHi*16);
msg3 = (msg23/256)|0;
msg2 = msg23-(msg3*256);
(statusHi == 0x8 || statusHi == 0x9 ) ? (
statusHi == 0x9 && msg3 != 0 && (
held_note != -1 ? (
held_note == msg2 ? (
midisend(mpos, 0x80, held_note | (0x6000));
held_note = -1;
) : (
midisend(mpos, 0x90, msg23);
midisend(mpos, 0x80, held_note | (0x6000));
held_note = msg2;
)
) : (
midisend(mpos, 0x90, msg23);
held_note = msg2;
);
)
) : (
midisend(mpos, msg1, msg23); // passthru non notes
);
);
);