Forum

    • Register
    • Login
    • Search
    • Categories

    Piano Pedal Behavior

    Scripting Forum
    4
    9
    48
    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.
    • nouslou
      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.healey
        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

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

          @d-healey should it looks like this?

          if (CCNumber == 64)
          {
                  if "my code"
          }
          
          ustk d.healey 2 Replies Last reply Reply Quote 0
          • ustk
            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

            Tired to press F5 in the forum...
            Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

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

              @nouslou Yup

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

              nouslou 1 Reply Last reply Reply Quote 1
              • nouslou
                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? 🙂

                Lindon 1 Reply Last reply Reply Quote 0
                • Lindon
                  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

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

                    @lindon now I got it!

                    1 Reply Last reply Reply Quote 0
                    • nouslou
                      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

                      6
                      Online

                      740
                      Users

                      5.4k
                      Topics

                      50.4k
                      Posts