HISE Logo Forum
    • Categories
    • Register
    • Login

    Trouble with index variable for loop inside loop

    Scheduled Pinned Locked Moved Scripting
    16 Posts 4 Posters 364 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.
    • VirtualVirginV
      VirtualVirgin
      last edited by VirtualVirgin

      I am trying to generate all 128 MIDI notes on all 16 channels using a loop inside a loop.
      I thought this would we phrased correctly to do the job, but apparently not:

      Screenshot 2024-11-11 at 12.43.25 PM.png

      HISE doesn't like my "j" variable for the inside for loop.
      The "j" here is the parameter for the note number of the
      Synth.addNoteOn()
      and I have "j" defined in the loop as being between 0 and 127,
      but it comes up as out an error for being out of that range.
      Is there some special method for the the index variable of the inside loop?

      How do I fix this to work properly?

      HiseSnippet 1294.3oc6X0sSabDEdVCaZ1sT0DodUuZTTuvzXA65.XboUk.1PrRL3F6P5MUQi2cr8.qmY0tigXEgTUewZeX5CPeCnmY101qMFBxJ8hFgkP1m+ly27y46LCMhDdz3XQDxvt0vPJxXEylC4xd62iv3nZUPFemYKZrDeHkSiHRJ1s31XtPRiwBN1cKrWOBGs2vPRbL0GYXrzgpHMrVFo+7O+7dj.B2iNQEBchf4QeEqOSNQaiceIKH3.hOsEqeFu2X2ZdB99h.w..kKY5fBIdmQ5ROhnbKmI5Ej3dHiu2zyaixzs6TrjSwxzM82ncQWGRQmxkKQIa530tLkTrSaOGjwCp5yjhnlRXBEiLVdOg+vl8DWvSRvIrXV6.pRvE0Dxbh5CDA9ponRKZ+dr.+FiV9hQHCyFSVLWJYw7aLqy7Yi0OYQ8QZC3IQjcAzH2zvaoofmaV34jAdyARFYfzxIP5wlM8hXgxIVT34KMqwkznNDXeJKTR7EY7ml6K.G3x05SNidPDHLNf7a43T.9a0c5Lf6IYvwBA+H3Dxw77qZ+AaK6KswyZpSm4ZSkkHQP.MZtlUmLhts.yyGzuMMp.9bRv.5XGgY+zKol27RZ1cbujIc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bqEMvRKZfa+wCTQ1+7ARQ+DZADpdipZZSCipbBTUoq.Q+KhUpRa.
      
      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @VirtualVirgin
        last edited by

        @VirtualVirgin Might be a HISE bug, change the loop to for (j = 0; j < 127; j++) and it works.

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

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

          @d-healey said in Trouble with index variable for loop inside loop:

          @VirtualVirgin Might be a HISE bug, change the loop to for (j = 0; j < 127; j++) and it works.

          Oh right!
          I did come across this before where I couldn't generate that top note (127)!

          ustkU 2 Replies Last reply Reply Quote 0
          • ustkU
            ustk @VirtualVirgin
            last edited by

            @VirtualVirgin @d-healey Yeah this bug is here since the premises of Hise, I reckon I pushed a fix one day but it has never been merged

            int ScriptingApi::Synth::internalAddNoteOn(int channel, int noteNumber, int velocity, int timeStampSamples, int startOffset)
            {
            	if (channel > 0 && channel <= 16)
            	{
            		if (noteNumber >= 0 && noteNumber < 127) // should be noteNumber <= 127
            		{
            

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

            1 Reply Last reply Reply Quote 2
            • ustkU
              ustk @VirtualVirgin
              last edited by

              @VirtualVirgin @d-healey Alright I fixed it and made a pull request

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

              1 Reply Last reply Reply Quote 0
              • ustkU
                ustk
                last edited by

                Wowww... It appears this error is repeated in many places!

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

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

                  @d-healey shouldn't a MIDI CC start from 0 to 127?

                  When clicking on a slider to assign CC it goes from 1 to 126...

                  Something is telling me Chris put a 1 for a reason...

                  if (!isOnHiseModuleUI && getMacroIndex() == -1)
                  	{
                  		auto addNumbersToMenu = [&](PopupMenu& mToUse)
                  		{
                  			auto value = handler->getMidiControllerNumber(processor, parameterToUse);
                  
                  			for (int i = 1; i < 127; i++) // <= 1?
                  			{
                  				if (handler->shouldAddControllerToPopup(i))
                  					mToUse.addItem(i + MidiOffset, handler->getControllerName(i), handler->isMappable(i), i == value);
                  			}
                  		};
                  

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

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

                    @ustk said in Trouble with index variable for loop inside loop:

                    shouldn't a MIDI CC start from 0 to 127?

                    Yes

                    From the MIDI spec

                    a6643dba-f473-4f39-abad-d902f5cd0c76-image.png

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

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

                      @d-healey Alright I pushed all the changes, hoping I didn't introduced any mistake...

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

                      VirtualVirginV 1 Reply Last reply Reply Quote 1
                      • VirtualVirginV
                        VirtualVirgin @ustk
                        last edited by VirtualVirgin

                        @ustk Does that mean I can build from the newest version to get these changes to take effect?

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

                          @VirtualVirgin You'll need to wait for Christoph to check and merge the changes, or you'll need to make a fork and pull in Ustk's changes to your fork.

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

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

                            @d-healey said in Trouble with index variable for loop inside loop:

                            @VirtualVirgin You'll need to wait for Christoph to check and merge the changes, or you'll need to make a fork and pull in Ustk's changes to your fork.

                            I don't have any forking experience so I'll wait on that, thanks :)

                            Christoph HartC 1 Reply Last reply Reply Quote 0
                            • Christoph HartC
                              Christoph Hart @VirtualVirgin
                              last edited by

                              @ustk pull request looks OK, I guess I never bothered about that upper number too much, the only thing I'm not sure is whether to show CC#0 in the learn popup. Usually you start with CC #1 (the mod wheel) and this will affect all plugins. Does anyone else have an opinion on that?

                              d.healeyD ustkU VirtualVirginV 3 Replies Last reply Reply Quote 0
                              • d.healeyD
                                d.healey @Christoph Hart
                                last edited by d.healey

                                @Christoph-Hart CC0 is bank select isn't it? If so I wouldn't show it in MIDI learn.

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

                                1 Reply Last reply Reply Quote 0
                                • ustkU
                                  ustk @Christoph Hart
                                  last edited by

                                  @Christoph-Hart yeah the cc0 learn was my concern too

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

                                  1 Reply Last reply Reply Quote 0
                                  • VirtualVirginV
                                    VirtualVirgin @Christoph Hart
                                    last edited by VirtualVirgin

                                    @Christoph-Hart
                                    I would think it's best just to let the user decide if they want to use it, like any other CC.

                                    Now, upon testing the CC learn (I was curious to make sure it is blocking the consumed CCs at the output for use with MIDI plugins, and it does), but I must say that the CC learn being channel agnostic is not a good idea. This is not how most VST instruments will handle this.

                                    Here in this simple MIDI utility I made, I just ran a test to check the channel filter operation in conjunction with the MIDI learn.

                                    Screenshot 2024-11-12 at 11.28.22 AM.png

                                    The MIDI learned control to CC#1 (Velocity Transpose Amount) is not affected by the channel filter, so even if my notes aren't going through, my CC values are.

                                    The MIDI learns need to be channel selectable somehow in order to work in multitimbral settings where the VSTi endpoint is only meant to receive from one channel, otherwise you will have lots of unwanted CC messages going to the other channels/instruments.

                                    Is there a way currently to make sure the CC learn can be filtered by channel?

                                    I am not seeing channel selection in the MidiLearnPanel:
                                    Screenshot 2024-11-12 at 11.59.53 AM.png

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

                                    6

                                    Online

                                    1.7k

                                    Users

                                    11.8k

                                    Topics

                                    102.3k

                                    Posts