Forum

    • Register
    • Login
    • Search
    • Categories

    Piano sustain pedal behaviour

    Scripting Forum
    2
    7
    181
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tomekslesicki last edited by

      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!

      d.healey 1 Reply Last reply Reply Quote 1
      • d.healey
        d.healey @tomekslesicki last edited by

        @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); 
        

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        1 Reply Last reply Reply Quote 1
        • T
          tomekslesicki last edited by

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

          d.healey 1 Reply Last reply Reply Quote 0
          • d.healey
            d.healey @tomekslesicki last edited by

            @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.

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            1 Reply Last reply Reply Quote 0
            • T
              tomekslesicki last edited by

              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?

              d.healey 1 Reply Last reply Reply Quote 0
              • d.healey
                d.healey @tomekslesicki last edited by

                @tomekslesicki

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

                Libre Wave - Freedom respecting instruments and effects
                My Patreon - HISE tutorials
                YouTube Channel - Public HISE tutorials

                1 Reply Last reply Reply Quote 0
                • T
                  tomekslesicki last edited by

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

                  1 Reply Last reply Reply Quote 1
                  • First post
                    Last post

                  9
                  Online

                  732
                  Users

                  5.4k
                  Topics

                  50.2k
                  Posts