Piano sustain pedal behaviour
-
@tomekslesicki This would be best as separate scripts.
Create a script that checks if the sustain pedal is pressed in the note on callback and if it is it ignores the note and also check for the sustain pedal in the note off callback and if it is pressed play a release sample. This script will go in your release sampler's MIDI processor section.
The script will be something like this (you'll need to fill in the blanks).
Note On:
if (Synth.isSustainPedalDown()) Message.ignoreEvent(true);
Note Off:
if (Synth.isSustainPedalDown()) Synth.playNote();
Then in whichever sampler you want to contain the C-1 pedal noise you'll need another script.
Something like this in the on controller callback (you'll need to fill in the function parameters with the correct values).
if (Synth.isSustainPedalDown()) Synth.playNote(C-1, velocity);
-
@d-healey said in Piano sustain pedal behaviour:
if (Synth.isSustainPedalDown())
Synth.playNote(C-1, velocity);Awesome, thank you very much, I managed to get it to work! Well, almost - just two more things.
-
How can I play another note (13, 100) when the pedal is released?
-
When I stop the sequence when the sustain is down, the pedal noise gets triggered. This is just a little annoying, I don't think it will be a show stopper but if there's an easy way to fix it - I'm all ears!
-
-
1:
if (!Synth.isSustainPedalDown()) Synth.playNote();
2: Check how many keys are held down, if there are no keys held then don't play the release note. Or you can check if there are any voices still sounding, if they are then you play the note.
-
Thanks! I understand I should use Synth.getNumPressedKeys() but I'm a little lost on how to implement it. I've searched the forum but couldn't find anything. Could you please expand on that 2nd hint?
-
if (Synth.getNumPressedKeys() > 0) Do stuff
-
Thanks! Tried that, worked but I ended up using var parameter instead :-) Thanks so much for your help!
-
@tomekslesicki Reviving this thread here (if it's ok)
I have a sampler with the 2 samples: Ped Down noise and Ped up Noise
I have CC64 triggering the two samples on press and release using:
if (Synth.isSustainPedalDown())
Synth.playNote(12, 127);if (!Synth.isSustainPedalDown()) Synth.playNote(13, 127);
How would I kill note12 when pedal is released..would this be a case for choke group?
All the best!
-
Synth.playNote()
returns the event idconst eventId = Synth.playNote()
You can use that event ID with
Synth.noteOffByEventId(eventId);
to turn off the note.This is monophonic of course. If you want it to be polyphonic you'll need to store one ID per note using a midi list or array.
-
@d-healey and
@d-healey said in Piano sustain pedal behaviour:
Synth.noteOffByEventId(eventId);
Sorry, confused as I learn the language...
This is what i have...what did i miss?
{ if (Synth.isSustainPedalDown()) Synth.playNote(12, 127); const eventId = Synth.playNote(12, 127) if (!Synth.isSustainPedalDown()) Synth.playNote(13, 127); Synth.noteOffByEventId(12); }
-
You don't need to play the note twice, just play it once and store the ID.
Your if statements are missing curly braces.