Forum

    • Register
    • Login
    • Search
    • Categories

    Midi Script Processor Help

    General Questions
    3
    6
    20
    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.
    • DanH
      DanH last edited by

      I'd like my c3 and c4 octaves to play the c2 octave (if that makes sense, so you get the same notes in those 3 octaves).

      Is there an easier way than writing out multiple if statements like the below?

      function onNoteOn()
      {
      	if (Message.getNoteNumber() == 60)
      	 {
      		 Message.setNoteNumber(48);
      	 }
      }
      
      d.healey ustk 2 Replies Last reply Reply Quote 0
      • d.healey
        d.healey @DanH last edited by d.healey

        @danh

        Is there an easier way than writing out multiple if statements like the below?

        There's always an easier way than multiple if statements - a switch statement 😛 But in this case I don't think you need to do that.

        Why not just put something like

        local n = Message.getNoteNumber();
        
        if (n >= 60)
        {
           Message.setNoteNumber(n - 24);
        }
        

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

        1 Reply Last reply Reply Quote 1
        • ustk
          ustk @DanH last edited by ustk

          @danh Something like this might be a good begining

          function onNoteOn()
          {
          	if (Message.getNoteNumber() >= 60)
          	{
          		if (Message.getNoteNumber() < 72)
          			Message.setNoteNumber(Message.getNoteNumber()-12);
          		else
          			Message.setNoteNumber(Message.getNoteNumber()-24);
          	}
          }
          

          As @d-healey said, instead of multiple if, a function that recognizes the octave and applies a down factor would be much better

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

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

            @ustk Are you crazy... this is Dan, don't give him examples without curly braces, he's not ready for that! 😛

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

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

              @d-healey 🤣 poor Dan!

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

              DanH 1 Reply Last reply Reply Quote 0
              • DanH
                DanH @ustk last edited by

                @ustk @d-healey thanks both {}

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

                19
                Online

                740
                Users

                5.4k
                Topics

                50.3k
                Posts