HISE Logo Forum
    • Categories
    • Register
    • Login

    Load specific samplemap via combobox and search bar

    Scheduled Pinned Locked Moved General Questions
    10 Posts 2 Posters 381 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.
    • DabDabD
      DabDab
      last edited by

      How can I load specific samplemap via viewport and ComboBox?

      I can do it via Switch Case but when I am adding https://forum.hise.audio/topic/7898/for-you-searching-a-viewport search bar things, it doesn't load specific sample maps.

      Bollywood Music Producer and Trance Producer.

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

        @DabDab post a snippet of what you're working with

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

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

          @d-healey

          Content.makeFrontInterface(200, 330);
          const var lblSearch = Content.getComponent("lblSearch");
          const var vptResults = Content.getComponent("vptResults");
          
          	//Pre-Set Values
          lblSearch.set("text", "Search");
          const var defaultEntries = ["Drum", "Piano", "Guitar", "Viola"]; //Change these values to change viewport entries
          vptResults.set("items", defaultEntries.join("\n"));
          
          	//Search Bar Callback
          inline function onlblSearchControl(component, value)
          {
          	local searchResults = [];
          	local regexKey = [];
          	
          	vptResults.set("items", defaultEntries.join("\n"));
          	
          	if(Engine.matchesRegex(value, "^\\s*$")) //If search is empty, then reset entries
          	{
          		vptResults.set("items", defaultEntries.join("\n"));
          	}
          	else
          	{	
          		for(character in value.toLowerCase().split("")) //Makes regex key to find case-insensitive matches
          		{
          			regexKey.push("[" + character + character.toUpperCase() + "]");
          		};
          			
          		for(item in vptResults.get("items").split("\n")) //Puts matching values into new array
          		{
          			if(Engine.matchesRegex(item, regexKey.join("")))
          			{
          				searchResults.push(item);
          			}
          		};
          		
          		searchResults.sortNatural(); 
          		vptResults.set("items", searchResults.join("\n"));
          	};
          };
          
          Content.getComponent("lblSearch").setControlCallback(onlblSearchControl);
          
          // Samplemaps
          Console.stop(true); const var Sampler1 = Synth.getSampler("Sampler1");
          const var list = Sampler.getSampleMapList();
          
          
          
          
          inline function onvptResultsControl(component, value)
          {
          	Sampler1.loadSampleMap(list[value]);
          };
          
          Content.getComponent("vptResults").setControlCallback(onvptResultsControl);
          

          Bollywood Music Producer and Trance Producer.

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

            Your snippet isn't loading for me

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

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

              @d-healey

              Content.makeFrontInterface(200, 330);
              const var lblSearch = Content.getComponent("lblSearch");
              const var vptResults = Content.getComponent("vptResults");
              
              	//Pre-Set Values
              lblSearch.set("text", "Search");
              const var defaultEntries = ["Drum", "Piano", "Guitar", "Viola"]; //Change these values to change viewport entries
              vptResults.set("items", defaultEntries.join("\n"));
              
              	//Search Bar Callback
              inline function onlblSearchControl(component, value)
              {
              	local searchResults = [];
              	local regexKey = [];
              	
              	vptResults.set("items", defaultEntries.join("\n"));
              	
              	if(Engine.matchesRegex(value, "^\\s*$")) //If search is empty, then reset entries
              	{
              		vptResults.set("items", defaultEntries.join("\n"));
              	}
              	else
              	{	
              		for(character in value.toLowerCase().split("")) //Makes regex key to find case-insensitive matches
              		{
              			regexKey.push("[" + character + character.toUpperCase() + "]");
              		};
              			
              		for(item in vptResults.get("items").split("\n")) //Puts matching values into new array
              		{
              			if(Engine.matchesRegex(item, regexKey.join("")))
              			{
              				searchResults.push(item);
              			}
              		};
              		
              		searchResults.sortNatural(); 
              		vptResults.set("items", searchResults.join("\n"));
              	};
              };
              
              Content.getComponent("lblSearch").setControlCallback(onlblSearchControl);
              
              // Samplemaps
              Console.stop(true); const var Sampler1 = Synth.getSampler("Sampler1");
              const var list = Sampler.getSampleMapList();
              
              
              
              
              inline function onvptResultsControl(component, value)
              {
              	Sampler1.loadSampleMap(list[value]);
              };
              
              Content.getComponent("vptResults").setControlCallback(onvptResultsControl);
              

              My problem is Label is isolating the samplemaps name. but it doesn't load specific samplemaps.

              Bollywood Music Producer and Trance Producer.

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

                @DabDab Your list variable contains all of the sample maps but your viewport only contains the filtered ones. You need to put the filtered results into an array and use that instead of list to load the sample maps.

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

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

                  @d-healey Hmmm... can I get a minimal snippet ? I tried it with Switch case. But didn't work. A simple example will be helpful.

                  //Sampler1.loadSampleMap(list[value]);
                  Sampler1.loadSampleMap(defaultEntries[value]);
                  

                  ??

                  Bollywood Music Producer and Trance Producer.

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

                    @DabDab You already have the code. Instead of using the searchResults array to store your results, put them in an array outside of the function, then you can access it in the same way as you are currently accessing list.

                    You're probably going to run into problems though when it comes to presets because presumably the filter will reset and then the indexes won't match.

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

                    DabDabD 2 Replies Last reply Reply Quote 0
                    • DabDabD
                      DabDab @d.healey
                      last edited by DabDab

                      @d-healey

                      //Sampler1.loadSampleMap(list[value]);
                      Sampler1.loadSampleMap(defaultEntries[value]);
                      

                      ??

                      Bollywood Music Producer and Trance Producer.

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

                        @d-healey I will make a snippet.

                        Bollywood Music Producer and Trance Producer.

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

                        20

                        Online

                        1.7k

                        Users

                        11.8k

                        Topics

                        102.4k

                        Posts