HISE Logo Forum
    • Categories
    • Register
    • Login

    Drum Mapping- user defined

    Scheduled Pinned Locked Moved General Questions
    drum mapping
    40 Posts 5 Posters 2.6k 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.
    • d.healeyD
      d.healey @gorangrooves
      last edited by

      @gorangrooves

      Line 1217, column 13:

      This implies you haven't posted all of the code... I have no idea what that error is referring to because I don't know what's on Line 1217.

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

      1 Reply Last reply Reply Quote 0
      • gorangroovesG
        gorangrooves
        last edited by

        @d-healey The line in question is this one:

        map.setValue(KickNumber, 36); //Set kick value
        

        When removed, all other lines compile OK.

        Goran Rista
        https://gorangrooves.com

        Handy Drums and Handy Grooves
        https://library.gorangrooves.com

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

          @gorangrooves What is KickNumber?

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

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

            @d-healey If you look at the OnNoteOn section, I introduced it there. It is supposed to be a numerical value that is calculated from a note that user selects (ex. User selects C0, it gets turned into midi note 36).

            Goran Rista
            https://gorangrooves.com

            Handy Drums and Handy Grooves
            https://library.gorangrooves.com

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

              @gorangrooves said in Drum Mapping- user defined:

              local KickNumber = Message.getNoteNumber() + 1;

              I'm currently making a video on this exact subject!

              A local variable only exists between the {} where it's declared. It is local to the code block. So you can't access that variable anywhere else. You need to declare your script-wide variables in on init.

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

              1 Reply Last reply Reply Quote 0
              • gorangroovesG
                gorangrooves
                last edited by

                @d-healey I understand. Thank you. So, I would use this in OnInit?

                var KickNumber = Message.getNoteNumber() + 1;
                

                Goran Rista
                https://gorangrooves.com

                Handy Drums and Handy Grooves
                https://library.gorangrooves.com

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

                  @gorangrooves Message.getNoteNumber(); only works in on note on and on note off.

                  You need to create a variable in on init. Something like this

                  reg kickNumber

                  You should use a reg variable because it is more efficient for variables that will be accessed in real-time callbacks such as on note.

                  Then inside on note you will save the note number in that variable.

                  function onNoteOn()
                  {
                      kickNumber = Message.getNoteNumber() + 1;
                  }
                  

                  This - map.setValue(KickNumber, 36); - won't work in on init though because kickNumber will be undefined.
                  So you'd probably need to set it in on note. But if you're doing that then there's probably no point in using the map variable at all. You might as well just use Message.setNoteNumber(36); I would think.

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

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

                    @d-healey Thank you for the explanation. I will play with and report back.

                    Goran Rista
                    https://gorangrooves.com

                    Handy Drums and Handy Grooves
                    https://library.gorangrooves.com

                    1 Reply Last reply Reply Quote 1
                    • gorangroovesG
                      gorangrooves
                      last edited by

                      @d-healey So, I managed to get this working, to my great surprise :) It is all thanks to you! I have another challenge to solve with this.

                      Here is the code I currently have:

                      OnInit

                      const var map = Engine.createMidiList();
                      reg KickNumber;
                      const var KickKey = Content.getComponent("ComboBoxKickMidi"); // Declare combobox
                      
                      reg SnareNumber;
                      const var SnareKey = Content.getComponent("ComboBoxSnareMidi"); // Declare combobox
                      

                      OnNoteOn

                      function onNoteOn()
                      {
                         //----kick mapping----------
                         KickNumber = Message.getNoteNumber() + 1;
                          
                      	if(KickNumber == KickKey.getValue())
                          {
                              Message.setNoteNumber(36);
                          }
                          
                          //----snare mapping----------
                         SnareNumber = Message.getNoteNumber() + 1;
                          
                      	if(SnareNumber == SnareKey.getValue())
                          {
                              Message.setNoteNumber(38);
                          }
                      }
                      

                      Here is what is happening now...
                      By default, the Kick is C1 and snare D1. If I set the Kick to B0, the kick will sound when pressing either B0 or C1.
                      However, if I now set the snare to C1 (kick's default note), then all 3 notes (B0, C1, D1) will now trigger the snare!

                      The ideal scenario would be that once a note is set for an instrument, it would only play on that set note and the default note would now be freely available for another instrument to use. In the above example, B0 should trigger kick, C1 should trigger snare and no note will sound on D1.

                      Is this achievable and if so, any idea of how I would go about it?

                      Thank you!

                      Goran Rista
                      https://gorangrooves.com

                      Handy Drums and Handy Grooves
                      https://library.gorangrooves.com

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

                        @gorangrooves this is pretty simple isnt it?

                        on init:

                        reg KickLocation = 36;  //where the kick actually is
                        reg KickTrigger = 54;   //the note that triggers a kick
                        
                        reg SnareLocation = 38;  //where the snare actually is
                        reg SnareTrigger = 56;   // the note that triggers a snare
                        

                        on note on:

                        	if (Message.getNoteNumber() == KickTrigger)
                                  {
                        	      Message.setNoteNumber(KickLocation);  
                        	  };
                        	
                        	
                        	if (Message.getNoteNumber() == SnareTrigger)
                                   {
                        	      Message.setNoteNumber(SnareLocation);  
                        	   };
                        

                        Or did I mis-understand your requirement?

                        HISE Development for hire.
                        www.channelrobot.com

                        gorangroovesG 1 Reply Last reply Reply Quote 0
                        • gorangroovesG
                          gorangrooves @Lindon
                          last edited by

                          @Lindon Thanks. I think your solution will achieve the same result that I currently have, but without the ability for a user to pick a note. What I am trying to do is use a combobox within the interface to pick a note that should trigger a particular instrument (kick, snare etc.). I got the basic function for that working.

                          The challenge now is to refine it to do this:

                          By default, the Kick is C1 and snare D1. If I set the Kick to B0, the kick will sound when pressing either B0 or C1.
                          However, if I now set the snare to C1 (kick's default note), then all 3 notes (B0, C1, D1) will now trigger the snare!

                          The ideal scenario would be that once a note is set for an instrument, it would only play on that set note and the default note would now be freely available for another instrument to use. In the above example, B0 should trigger kick, C1 should trigger snare and no note will sound on D1.

                          Goran Rista
                          https://gorangrooves.com

                          Handy Drums and Handy Grooves
                          https://library.gorangrooves.com

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

                            @gorangrooves then just add a call back for the combobox that sets the trigger value..

                            inline function onmyKickComboBoxControl(component, value)
                            {
                            	KickTrigger = value;
                            };
                            
                            Content.getComponent("myKickComboBox").setControlCallback(onmyKickComboBoxControl);
                            

                            HISE Development for hire.
                            www.channelrobot.com

                            gorangroovesG 1 Reply Last reply Reply Quote 0
                            • gorangroovesG
                              gorangrooves @Lindon
                              last edited by

                              @Lindon Thank you!

                              I tried it, but unfortunately, it still produces exactly the same results. The issue still remains that a user-selected note is in addition to the default note for a particular instrument. So, if default note for kick is C1 and user select E0, now we have the kick sounding when pressing either E0 or C1. It doesn't free up the original kick default note to used by another instrument.

                              The issue gets more complicated when we introduce a second note. Lets say we have the snare by default at D1. If a user selects snare note now to be C1 (default note of the kick), now there is no kick sound! Snare is heard when pressing either E0, C1 or D1.

                              How do we go about having a user select a note for each instrument and that note being the sole note which triggers a particular instrument?

                              Goran Rista
                              https://gorangrooves.com

                              Handy Drums and Handy Grooves
                              https://library.gorangrooves.com

                              1 Reply Last reply Reply Quote 0
                              • gorangroovesG
                                gorangrooves
                                last edited by

                                Updated code:

                                On Init

                                Engine.createMidiList();
                                
                                //kick    
                                inline function onComboBoxKickMidiControl(component, value)
                                {
                                	reg KickTrigger = value;
                                };
                                
                                Content.getComponent("ComboBoxKickMidi").setControlCallback(onComboBoxKickMidiControl);
                                
                                //snare
                                
                                inline function onComboBoxSnareMidiControl(component, value)
                                {
                                	reg SnareTrigger = value;
                                };
                                
                                Content.getComponent("ComboBoxSnareMidi").setControlCallback(onComboBoxSnareMidiControl);
                                

                                On Note On

                                //----kick mapping----------
                                   if (Message.getNoteNumber() +1 == KickTrigger)
                                          {
                                	      Message.setNoteNumber(36);  
                                	  };
                                    
                                    //----snare mapping----------
                                    if (Message.getNoteNumber() +1 == SnareTrigger)
                                    {
                                        Message.setNoteNumber(38);
                                    }
                                

                                Goran Rista
                                https://gorangrooves.com

                                Handy Drums and Handy Grooves
                                https://library.gorangrooves.com

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

                                  @gorangrooves why are you adding 1 to the Message.getNoteNumber()??

                                  Actually thinking a bit about it a combo box is probably not a good way to select a midi note number, try a knob instead...

                                  HISE Development for hire.
                                  www.channelrobot.com

                                  gorangroovesG 1 Reply Last reply Reply Quote 0
                                  • gorangroovesG
                                    gorangrooves @Lindon
                                    last edited by

                                    @Lindon Adding +1 is necessary for the values to present a correct note. Without it, the resulting note is a semitone lower. C gets played as B, so with +1, it becomes C. Not sure why it is. Maybe a 0 gets counted, but it doesn't have any note...

                                    I don't think a knob would be a better option, to be honest. How would you display 127 notes in a circle? Selection of a note is not an issue, but rather how to properly process it later.

                                    Goran Rista
                                    https://gorangrooves.com

                                    Handy Drums and Handy Grooves
                                    https://library.gorangrooves.com

                                    LindonL 1 Reply Last reply Reply Quote 0
                                    • gorangroovesG
                                      gorangrooves
                                      last edited by

                                      @Christoph-Hart Any idea of how I can get this to work properly? User-selected note to be assigned to a single instrument, freeing up the default note to be used by another user-assigned instrument.

                                      Goran Rista
                                      https://gorangrooves.com

                                      Handy Drums and Handy Grooves
                                      https://library.gorangrooves.com

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

                                        @gorangrooves well the reason you are having to add the 1 is that a combo box returns 1 as the first index so a combo box with this in it:

                                        • zero
                                        • one
                                        • two

                                        When you select "zero" the combo box will return a value of 1, when you select "one" the combo box will return 2 etc. etc.

                                        So you should either map the returned values to meaningful note ranges or use a knob

                                        If you use a comboBox I assume you dont want to map ANY note number you might want to map notes 60 -80 in that case you will need to set up your comboBox to contain the following:

                                        60
                                        61
                                        62
                                        63
                                        64
                                        65
                                        66
                                        67
                                        68
                                        69
                                        etc..

                                        and in your call back say:

                                        //kick    
                                        inline function onComboBoxKickMidiControl(component, value)
                                        {
                                        	reg KickTrigger = value + 59;
                                        };
                                        

                                        So a knob returns its value : so define a knob (a slider in the UI) values 0 to 127 and set showValuePopup = "Above" and the knob will display the numbers 0 to 127 above itself whenever the user moves the knob, and will remove this pop up after a few seconds

                                        HISE Development for hire.
                                        www.channelrobot.com

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

                                          with luck this will give you a clue how to proceed.

                                          HiseSnippet 1605.3oc6YE0aaaCDVJNJsNqYXsnOrG1CBEc.1Xso1oIoMKnn1wNoMnIMFVoA6ACTvHS6PDIRAJJ250EreO6s8Sn+j5+fsiTRQTINYVAccEcUAvP73c79tiGu6DSGNyEGFx3Flk2eb.1v7FVNiohiZcDhPM1tsg42X0mG4yw9n.iMFGfBCw8MLMK8LIClkm0P87gmtAxCQcwYjLLNfQbw6P7IhLpcZ7Bhm2Vn938I9ZbubiscYzVLOVD.lRV0LBPtGiFheIRx1LVFlysYehfwcDHANzvb1MX8G6bD6MzX9OfDRNzCKGT2vAVnXxaw75KQr7ciVGQ752I0nCMLLs5j4BJE6Bts0tj9jSom4J9N0D1YRn6OLm4xfW8qH7L0f2rwv6lVNtbRfHal3sosoBLe.B1BzgULuFy7GkrZw.NnhE8QGi2hCCNUhJqVq18rWoVspquv7KLOGOz9Xh6wNvdgK19IvLqGSMjh33LxOJG66yICGh4mieM5OVIf7OB0iPw1ChntBBiZynuHaIjHky7p3x7CXT.y2ydDxKBWcg4e2ByW9AOHDKrEGgsEIKMkIvvD4QgRDPgmnTZp0ODKZktrUtilRuS0ECkyoTcKjm2gP.XkIgqpqeQ1fil8N0FgxIkZJvLmwoMMlgtduH6XBXK1Pzv+KA+3dzJUkHb9xjAU1EhvfCgR0Im6kQ9Gh4Up9jmnuiWUZO1vSJ2g43NKTp55yW9DrWHVJ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7bh1fcXGHW3XT+bRxfeWZ6wcfkB5sHdI2V96rZ8y8f1f3g8fTY8YzdMCBjPt2NLWjWu8w9A85h32scWTsEW4wq06.B7EhCw1s4Q9g1HZea.Ag8Z5gCIg1Ncue8U6o90F5j0tV8dGBa1x+w.g06soGbfhyntK9FzHi1QAdDWXKVFHXbNacMcacMcacsqls9aExVqUe4haqpKWLwXa54wFa6P4SvX+TDK9oPG9HWN60twWfmLp+5JJP7NU4xKasqbrc8zqrSdN0G5440ttxDp2GNoNYIVpvR7vBKwxEVhUJrDqVXIdTgk3wWhDxFLaFIX9wkWABc1LNkj4lmlRpjweyiIwWZ
                                          

                                          HISE Development for hire.
                                          www.channelrobot.com

                                          1 Reply Last reply Reply Quote 0
                                          • gorangroovesG
                                            gorangrooves @Lindon
                                            last edited by

                                            @Lindon said in Drum Mapping- user defined:

                                            So a knob returns its value : so define a knob (a slider in the UI) values 0 to 127 and set showValuePopup = "Above" and the knob will display the numbers 0 to 127 above itself whenever the user moves the knob, and will remove this pop up after a few seconds

                                            This is not very user-friendly, I am afraid. I am certain that 99.99% of my users will have no clue which note pertains to which midi id#, so numerical values would be of no use. My combobox displays note names (C0, C#0 etc.) which a user will know to select. They are then turned into numerical values to be used internally.

                                            I will check the snippet you provided. Thank you!

                                            Goran Rista
                                            https://gorangrooves.com

                                            Handy Drums and Handy Grooves
                                            https://library.gorangrooves.com

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

                                            59

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            101.7k

                                            Posts