Mindbullets
Oh weird! I didn't realize it didn't save in the project file. Here's the script. It's all the same logic as Olivier's, I think I just renamed a few vars while debugging so it made more sense (to me) what was going on.
desc: Reaper Script to enable silent key for VSL Pianos and disable VSL Sustain samples for use with Pianoteq
desc: 12/3/2023 - Olivier W. Frappier
@init
sustainVal = 0; // current sustain value from the original MIDI
overrideActive = 0; // are we currently overriding sustainVal?
minVelocity = 2; // minimum velocity (anything lower will silent-key)
controlChange = 176; // status byte 176 = control change
sustainPedal = 64; // cc 64 = sustain
noteOnCmd = $x90; // command 0x90 = note on
@slider
@block
overrideActive == 1 ? (
// clear sustain pedal override
midisend(ts, controlChange, sustainPedal, sustainVal);
noteOnState = 0;
);
// intercept MIDI messages
while (midirecv(offset, msg1, msg2, msg3)) (
((msg2 == sustainPedal) && (msg1 == controlChange)) ? (
sustainVal = msg3;
);
// is it a note-on?
msg1 == noteOnCmd ? (
// override sustain pedal value to 0 to trigger pedal-up (dampers-down) sample
midisend(ts, controlChange, sustainPedal, 0);
overrideActive = 1;
// if the note velocity is below the minimum, drop it to 0 so VSL will silent-key
msg3 < minVelocity ? msg3 = 0; (
midisend(offset, msg1, msg2, msg3);
)
) : (
// pass through other events
midisend(offset, msg1, msg2, msg3);
)
);