HISE Logo Forum
    • Categories
    • Register
    • Login

    Piano sustain pedal behaviour

    Scheduled Pinned Locked Moved Scripting
    11 Posts 3 Posters 748 Views
    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.healeyD 1 Reply Last reply Reply Quote 1
      • d.healeyD
        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.healeyD 1 Reply Last reply Reply Quote 0
          • d.healeyD
            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.healeyD 1 Reply Last reply Reply Quote 0
              • d.healeyD
                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!

                  virtuscapeaudioV 1 Reply Last reply Reply Quote 1
                  • virtuscapeaudioV
                    virtuscapeaudio @tomekslesicki
                    last edited by

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

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

                      @virtuscapeaudio

                      Synth.playNote() returns the event id

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

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

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

                        @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);	 
                         }
                        
                        d.healeyD 1 Reply Last reply Reply Quote 0
                        • d.healeyD
                          d.healey @virtuscapeaudio
                          last edited by

                          @virtuscapeaudio

                          You don't need to play the note twice, just play it once and store the ID.

                          Your if statements are missing curly braces.

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

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

                          57

                          Online

                          1.7k

                          Users

                          11.7k

                          Topics

                          102.1k

                          Posts