Piano sustain pedal behaviour



  • Hi guys! I'm trying to program some sustain pedal behaviour for my piano instrument. I'm still learning Hise, the instrument is mostly done but I thought I'd ask for some help here.

    So, the way I'd like it to behave is:

    • On sustain pedal, sustain all samplers except one that's called ReleaseTriggers (these are - as the name suggests - key release samples that I would like to play when the key is no longer pressed, despite the sustain pedal being on)

    • When the sustain pedal is pressed, play note C-1 (pedal down noise sample)

    • When the sustain pedal is no longer pressed, do not trigger samples from the ReleaseTriggers sampler

    Any help appreciated!



  • @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!



  • @tomekslesicki

    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?



  • @tomekslesicki

    if (Synth.getNumPressedKeys() > 0)
        Do stuff
    


  • Thanks! Tried that, worked but I ended up using var parameter instead 🙂 Thanks so much for your help!


Log in to reply
 

12
Online

544
Users

2.1k
Topics

16.2k
Posts