HISE Logo Forum
    • Categories
    • Register
    • Login

    Selecting sound layer via Combobox

    Scheduled Pinned Locked Moved Scripting
    8 Posts 2 Posters 297 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.
    • G
      Giuseppe
      last edited by

      Hello everyone,
      I'm attempting my first simple project, I want to create an instrument where I have a number of pads/textures and a menu to select just one of them from the batch. As I understand that using many samplers is bad practice, I thought to stack said sounds on different velocity levels in the same sampler, and then selecting only one via scripting (yes, very Kontakt but that's where I come from).

      A screenshot of my sampler: Screenshot 2024-03-20 at 18.02.51.png

      Here's what I have in the NoteOn CB:

      function onNoteOn()
      {
      	local menu_select = sample_vel_map[ComboBox1.getValue()-1];
      	Console.print(menu_select);
      
      	Message.ignoreEvent(1);
      	
      	Synth.playNote(Message.getNoteNumber(), menu_select+1);
      	
      
      }
      

      menu_select is a variable that reads the velocity values from a predefined array, according to the sound selection from a combobox.

      It works at isolating only one sound layer and muting the others, but I lose control of the volume envelope, which I guess is because of the ignoreEvent command. In other words, the sample keeps playing and ignores note off messages.

      I also understand that the NoteOff command is deprecated, but I can't find a way to set an event in the NoteOn callback so that I can use NoteOffByEventId in the NoteOff CB.
      Any idea?
      Also, is my approach valid or should I rethink it?

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

        @Giuseppe If you use a global modulator for velocity it should work. Place the global modulation container before (above) your sampler.

        You can use Synth.noteOffByEventId() however there's a better option in your case. Don't ignore the event, and don't use playNote. Just change the velocity of the Message.

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

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

          @d-healey Thanks. I managed to get it by simply using setVelocity with no global modulators.

          function onNoteOn()
          {
          	local menu_select = sample_vel_map[ComboBox1.getValue()-1];
          		Console.print(menu_select);
          		Message.setVelocity(menu_select);
          }
          

          Well, I actually tried with a Global Velocity Modulator first, but I couldn't see a differenct except that the voice count goes 4x:
          Screenshot 2024-03-21 at 14.43.33.png

          Here I'm just holding a single note:
          Screenshot 2024-03-21 at 14.47.22.png

          Why does the global modulator affects the voice count?

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

            @Giuseppe said in Selecting sound layer via Combobox:

            Why does the global modulator affects the voice count?

            No idea, I've not seen that before

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

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

              @d-healey I've noticed that for some reason some zones are highlighted more than others in my Sample Map. Does this mean anything?
              Screenshot 2024-03-21 at 15.12.08.png

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

                @Giuseppe That means you have multiple samples mapped to the same position.

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

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

                  @d-healey d'oh...:person_facepalming_light_skin_tone:

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

                    By the way, you could also use groups to separate your different sounds and have the menu set the active group.

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

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

                    24

                    Online

                    1.7k

                    Users

                    11.8k

                    Topics

                    102.8k

                    Posts