HISE Logo Forum
    • Categories
    • Register
    • Login

    Piano Pedal Behavior

    Scheduled Pinned Locked Moved Scripting
    9 Posts 4 Posters 574 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.
    • nouslouN
      nouslou
      last edited by

      Hi everyone! Have a samplers in my piano project which have pedal down and up samples. I use midimuters and my script looks like (I put it into my pedal up and down samplers):

      function onController()
      {
      
      	if (Synth.isSustainPedalDown() == true) {
      		muteup.setAttribute(0, 1);
      	}
      	if (Synth.isSustainPedalDown() == false) {	
      		muteup.setAttribute(0, 1);
      		Synth.playNote(0, 100);	
      	}
      	
      }
      

      Pedal up and down samples are working just fine with my sustain pedal. But the problem is now this script reacts to all others midi controller knobs :) For example I can touch my Pitch Bend - and while I use it - pedal down and up samples are sounds too etc. How can I change this script to react only on sustain pedal? Thank you!

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

        Add an if statement to check if the cc number is 64

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

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

          @d-healey should it looks like this?

          if (CCNumber == 64)
          {
                  if "my code"
          }
          
          ustkU d.healeyD 2 Replies Last reply Reply Quote 0
          • ustkU
            ustk @nouslou
            last edited by ustk

            @nouslou Yes

            and just for better coding style,

            This:

            if (Synth.isSustainPedalDown() == true) {
            	// blabla
            }
            if (Synth.isSustainPedalDown() == false) {	
            	// blabla
            }
            

            is equal to this:

            if (Synth.isSustainPedalDown())
            {
            
            }
            else
            {
            
            }
            

            In fact, it's not even equal because in your case both statements or evaluated when it is necessary to do it only once

            Can't help pressing F5 in the forum...

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

              @nouslou Yup

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

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

                @d-healey Somehow it doesn't work:

                Screen Shot 2022-01-27 at 5.28.09 PM.png

                I mean if I write

                if (CCNumber == 64)
                

                Even pedal samples stop to work. Am I blind somewhere? :)

                LindonL 1 Reply Last reply Reply Quote 0
                • LindonL
                  Lindon @nouslou
                  last edited by Lindon

                  @nouslou

                  if (CCNumber == 64)
                  

                  Where is CCNumber coming from?

                  to "read" a CCNumber you need to use:

                  Message.getControllerNumber()
                  

                  -- its in the API documentation, you may also need:

                  Message.getControllerValue()
                  

                  at some point....

                  so your code should read

                  if (Message.getControllerNumber() == 64)
                  
                  

                  HISE Development for hire.
                  www.channelrobot.com

                  nouslouN 2 Replies Last reply Reply Quote 1
                  • nouslouN
                    nouslou @Lindon
                    last edited by

                    @lindon now I got it!

                    1 Reply Last reply Reply Quote 0
                    • nouslouN
                      nouslou @Lindon
                      last edited by

                      @lindon @d-healey @ustk Guys, you are all brilliant! Thank you very much as always!

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

                      26

                      Online

                      1.8k

                      Users

                      12.0k

                      Topics

                      104.2k

                      Posts