HISE Logo Forum
    • Categories
    • Register
    • Login

    Populate samplemaps based on folder choice(almost working)

    Scheduled Pinned Locked Moved Scripting
    25 Posts 5 Posters 1.3k 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.
    • ten7kurT
      ten7kur
      last edited by ten7kur

      Hi all,

      Im trying to populate a samplemap list to a viewport. (the samplemaps are located in folders) and displayed based on a category(viewport) selection. I cant get this working for over a day.

      The folder structure inside the Samplemaps directory is as follows:

      Folder1 > Sub-folderA;
      Folder1 > Sub-folderB;
      
      Inside the Sub-folders the .XMLs are as follows:
      0.xml ---------------------dummy file
      samplemap1.xml
      samplemap2.xml
      zzz.xml -------------------dummy file
      

      On Init(compile) it lists the selected category samplemaps BUT if i click the other category (A, B), it does not re-list!
      Also im trying to clear the samplemap list on each IF statement (SamplemapList.set("items", ""); but its not clearing..

      Ive tried so many IFs and ELSEs! got it to populate, but then it was populating the samplemaps to infinity on each click of the category.. so i came back to this example.

      What am i overlooking??!
      Why wont it populate on category click(select)??

      Content.makeFrontInterface(600, 500);
      
      // =================== [ SamplemapList ] ================== //
      const var SamplemapList = Content.getComponent("SamplemapList");
      const var Sampler = Synth.getSampler("Sampler");
      const var sampleMapList = Sampler.getSampleMapList();
      
      //populates the Directory path
      global SMLdir_select;
      
      //SMLdir_start, SMLdir_end point to the directory
      // /0 is the first file in a directory, and /zzz is the last file
      global SMLdir_start = sampleMapList.indexOf(SMLdir_select + "/0");
      global SMLdir_end = sampleMapList.indexOf(SMLdir_select + "/zzz");
      
      global formattedSamplemaps = [];
      
          for (i = SMLdir_start+1; i < SMLdir_end; i++){
          var newName = sampleMapList[i];
          newName = newName.substring(10, 100);
          formattedSamplemaps.push(newName);
      }
      
      
      // =================== [ Category ] ================== //
      
      const var CAT = Content.getComponent("CAT");
      
      
      inline function onCATControl(component, value)
      {
          local items = component.get("items").split("\n");
      	
      	//CAT
      	if(items[value] == "A"){	    
      	    SamplemapList.set("items", "");
              SMLdir_select = "Folder1/Sub-folderA";
      	    SamplemapList.set("items", formattedSamplemaps.join("\n"));
      	    Console.print(items[value] +"- "+SMLdir_select);
          }
         
          if(items[value] == "B"){        
              SamplemapList.set("items", "");
              SMLdir_select = "Folder1/Sub-folderB";
      	    SamplemapList.set("items", formattedSamplemaps.join("\n"));
              Console.print(items[value] +"- "+SMLdir_select);
          }
      };
      Content.getComponent("CAT").setControlCallback(onCATControl);
      

      Many thanks!!

      1 Reply Last reply Reply Quote 0
      • ten7kurT
        ten7kur
        last edited by ten7kur

        Do i need some sleep?
        Im sure its something stupid

        Would really appreciate if someone could pitchIn

        HiseSnippet 2752.3oc6Zs0aaiiEVJopSs25YmYv7v9xBPXLOXijFeoMYtjcvl3jzIEaRaPbZmAHaPfrLsMSkEEjnRpaQ.leR6Og4mz979xtGRQJQIeIttIEc1ccaQMIO7b93gGd34SxGEPcvggz.CyBmLxGaX9Pq1i7XC1YfMwy3Y6ZXVzpS.8pPbvFFsF4aGFh6ZXZt7OwG2rv8LDe9m+0V1t1dN3ztLLdEk3fOfLjvR68ns9aDW2mZ2EeBYnlzOYqm4P81g5Ri.rrrUcCeamWa2G+batXKYYXd+85RXzf1LaFNzv7dsncG0d.8JuX4eEIjzwEyazvnMnn3teJ0sKGw7dM1Y.ws6Qp0bnggo0Qodfki8.es0gjtjj9S8DegX.T5Lz8GlKMK30PGd0me3YpAu6ECuuzpsS.wmkNBGa+Aqm4wvA8rgs.cXEKqwR+q6asCEjvis1P6WieZ.zHYFU1nd8UQqWud0MKUrTwZ0P+33ePmhZaOz2EOz1+.RHCc1DjBUqVohvFIL7k1A4lvOhTPnOlsCcnO0CZTobFoJywPdMD.yUDVxmorK07BxMiPQuGlXSoToyTNTE0h0m5G4x2zPrAXztj.rCrONB4ayFTpXeWZGaWT6COnKI37PrKLpbhp9X1ArUURf85h7oDOFhQEJrqRgBGas5HRrg5QB.70i3hQDOjcpbqhrAcT6su8s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NplEMSCkayXPzKuy00UhK1NTbbrgltO.td0NPcD48XoNKu6exJFBHdB.zmNYkq+IPV4Yg9OWdDB0l+Zot68VOzRbhFwyU+AXsioQ7B+UonrfrXwWnqmKqogrUc4SeDnNTm6.eTC0HMjOzaXjFxQLbTp.rr76w0LrLPSDxCIus0Exm5laOMDt7fiGdkF2kPbnsS.8bm3Bf3.8Ahd.I8DOz3BVGxaiZj7b04nzXHjZ6bGmLZYr4zbAlyiWf47jEXNqu.yYiEXNe6BLmualygeqx1QL5v3TDPGGsmrRz8RippmTfKDs6iCXD96qwbW7kPgGwmpJ.4zCeMi5KdCKRBBP2yw6X4MouZjC1ZTRie8zsthzkMHoieqyVCvj9CR+Yq7q1aIe9MpWQCiRcYDekpEjZ3M1tXK9ZHAWO385E3ngvKt0P384Hr4sw8zlKqkiJ8m9ycxO8kaiqeLWZB3k+xvtiw67d20czuZnOLFIK7OsK+49m1UFBHJw9sszodn58erUFRGo1ZB7MReum4HajtTxwzHcfDZFoqww3XjNjhfQZOorKR6KC0h3CkiQtHU5OoXVTxp0t0Zs64uHhUq9Xu.8Oa9dA5ftNxFV8ZR1hzOwNw8nGJm3wEnR621mwcFolOBGAuaS1t77AWi6HVTlKqygR+7PBApTrOwEjh5jpmudqDdSpt9lsz4LsP9hFyuu3Cjl0u6tjb4+m+RxEhf3mh6ySgc4GUnNG79rLWhe+ZByOKwO5II2OKy+M7Ik7W7EmR5ewCNOTTMWRRPMMj98jc5GLJ++rT+uQVplKa7e.YMvthB
        
        1 Reply Last reply Reply Quote 0
        • ten7kurT
          ten7kur
          last edited by ten7kur

          Perhaps my question is....

          1. Why samplemaps(Array) wont populate on click. Only populates on INIT

          2. Why wont "SamplemapList.set("items", ""); is not emptying a viewport.

          THanks!
          @d-healey @Christoph-Hart @Lindon @-anyone?

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

            @ten7kur

            Q1: becuase your code doesnt have a click event that is asking to do this

            look at these two line sand see if you cna work out where you are going wrong:

            const var SamplemapList = Content.getComponent("SamplemapList");

            SamplemapList.set("items", "");

            1 Reply Last reply Reply Quote 0
            • ten7kurT
              ten7kur
              last edited by

              just loking at this now.. Thanks for the response!!
              I dont quite understand what you mean to look at "SamplemapList"
              Could you elaborate more?
              I tried:

              CAT.setMouseCallback(function(event)
                  {
                  	if(event.clicked){    
                  	
                  for (i = SMLdir_start+1; i < SMLdir_end; i++){
                  var newName = sampleMapList[i];
                  newName = newName.substring(10, 100);
                  formattedSamplemaps.push(newName);
              }
               Console.print("excuted"); 
                  	} ;
              

              I cant compile...

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

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • ten7kurT
                  ten7kur
                  last edited by

                  wiget does no appear in API,. im at a loss..

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

                    @ten7kur yes, you are starting to confuse me now too... this might not be for you. :-)

                    1 Reply Last reply Reply Quote 0
                    • ten7kurT
                      ten7kur
                      last edited by

                      @ten7kur said in Populate samplemaps based on folder choice(almost working):

                      setMouseCallback

                      I cant manage to find any example with viewports and clickEvents.
                      Can you point to an example?

                      LindonL ustkU 2 Replies Last reply Reply Quote 0
                      • LindonL
                        Lindon @ten7kur
                        last edited by

                        @ten7kur viewports dont have mouse call backs - only panels do - read the documentation:

                        Link Preview Image
                        HISE | Docs

                        favicon

                        (docs.hise.audio)

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

                          This post is deleted!
                          1 Reply Last reply Reply Quote 0
                          • ten7kurT
                            ten7kur
                            last edited by

                            So how come the SamplemapList viewport is not populating on Category viewport selection?
                            Only populates on INIT.

                            Im doing this in onCATControl

                            if(items[value] == "A"){	    
                            	    SamplemapList.set("items", "");
                                    SMLdir_select = "Folder1/Sub-folderA";
                            	    SamplemapList.set("items", formattedSamplemaps.join("\n"));
                            
                            ustkU 1 Reply Last reply Reply Quote 0
                            • ustkU
                              ustk @ten7kur
                              last edited by

                              @ten7kur Have a look at the watchtable, the samplemaps names and start/end are looking weird...

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

                                @ustk said in Populate samplemaps based on folder choice(almost working):

                                @ten7kur Have a look at the watchtable, the samplemaps names and start/end are looking weird...

                                Yea oops messed up along the way somewhere.
                                This works, but still only populates on INIT.

                                Im trying to send the SMLdir_select from onCATControl back through the script to show the new formatedSamplemaps.

                                global SamplemapList = Content.getComponent("SamplemapList");
                                
                                const var Sampler = Synth.getSampler("Sampler");
                                const var sampleMapList = Sampler.getSampleMapList();
                                
                                global SMLdir_select = "Folder1/Sub-folderA";;
                                global formattedSamplemaps = [];
                                
                                global SMLdir_start = sampleMapList.indexOf(SMLdir_select + "/0");
                                global SMLdir_end = sampleMapList.indexOf(SMLdir_select + "/zzz");
                                
                                
                                    for (i = SMLdir_start+1; i < SMLdir_end; i++){
                                    var newName = sampleMapList[i];
                                    newName = newName.substring(10, 100);
                                    formattedSamplemaps.push(newName);
                                }
                                SamplemapList.set("items", formattedSamplemaps.join("\n"));
                                

                                Would this solely have to be inside the onCATControl?


                                I did this before. It works half way. It populates Samplemaplist based on CAT Item selected but its not clearing the SamplemapList viewport. So everytime i select a CAT Item it just adds and adds to the SampemapList.

                                inline function onCATControl(component, value)
                                {
                                    var items = component.get("items").split("\n");
                                	
                                	if(items[value] == "A"){
                                	    SMLdir_select = "Folder1/Sub-folderA";
                                	    
                                	    global SMLdir_start = sampleMapList.indexOf(SMLdir_select + "/0");
                                            global SMLdir_end = sampleMapList.indexOf(SMLdir_select + "/zzz");
                                
                                    
                                    for (i = SMLdir_start+1; i < SMLdir_end; i++){
                                    global newName = sampleMapList[i];
                                    newName = newName.substring(10, 100);
                                    formattedSamplemaps.push(newName);
                                }
                                    }
                                    else
                                    if(items[value] == "B"){
                                	    SMLdir_select = "Folder1/Sub-folderB";
                                	    
                                	    global SMLdir_start = sampleMapList.indexOf(SMLdir_select + "/0");
                                            global SMLdir_end = sampleMapList.indexOf(SMLdir_select + "/zzz");
                                
                                    
                                    for (i = SMLdir_start+1; i < SMLdir_end; i++){
                                    global newName = sampleMapList[i];
                                    newName = newName.substring(10, 100);
                                    formattedSamplemaps.push(newName);
                                }
                                    }
                                    //else
                                            
                                	//SamplemapList.set("items", "");	    
                                	SamplemapList.set("items", formattedSamplemaps.join("\n"));
                                      
                                };
                                Content.getComponent("CAT").setControlCallback(onCATControl);
                                
                                
                                
                                1 Reply Last reply Reply Quote 0
                                • ten7kurT
                                  ten7kur
                                  last edited by

                                  bump.
                                  Anyone?

                                  At least the simplest of question;
                                  Why wont a viewport clear its items with:

                                  Viewport.set("items", "");
                                  

                                  ??
                                  Thanks

                                  d.healeyD C 2 Replies Last reply Reply Quote 0
                                  • d.healeyD
                                    d.healey @ten7kur
                                    last edited by

                                    @ten7kur said in Populate samplemaps based on folder choice(almost working):

                                    bump.
                                    Anyone?

                                    At least the simplest of question;
                                    Why wont a viewport clear its items with:

                                    Viewport.set("items", "");
                                    

                                    ??
                                    Thanks

                                    I think it's a bug. i just did a simple test and you're right, it doesn't work.

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

                                    ustkU ten7kurT 2 Replies Last reply Reply Quote 0
                                    • C
                                      coreyu21 @ten7kur
                                      last edited by

                                      @ten7kur possibly try to insert viewport.changed somewhere in the code to tell the component to initiate the callback and update item list. I believe I had the viewport updating not to long ago, just not in an if statement. Might not work, just trying to help🙂

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

                                        @d-healey Apparently, you need to have at least something as a workaround,
                                        like Viewport.set("items", "-"); or Viewport.set("items", "Select a category");

                                        I think .isNotEmpty() is the cause:

                                        void ScriptingApi::Content::ScriptedViewport::setScriptObjectPropertyWithChangeMessage(const Identifier &id, var newValue, NotificationType notifyEditor /* = sendNotification */)
                                        {
                                        	if (id == getIdFor(Items))
                                        	{
                                        		jassert(isCorrectlyInitialised(Items));
                                        
                                        		if (newValue.toString().isNotEmpty())
                                        		{
                                        			currentItems = StringArray::fromLines(newValue.toString());
                                        		}
                                        	}
                                        
                                        	ScriptComponent::setScriptObjectPropertyWithChangeMessage(id, newValue, notifyEditor);
                                        }
                                        

                                        I'll try to remove it...

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

                                          @coreyu21 said in Populate samplemaps based on folder choice(almost working):

                                          possibly try to insert viewport.changed somewhere in the code to tell the component to initiate the callback and update item list

                                          Tried it but no luck..
                                          I looked in the API, found "changed()" but it seems like it exists for all components Besides the Viewport..

                                          @ustk said in Populate samplemaps based on folder choice(almost working):

                                          I'll try to remove it...

                                          🙏 🙏

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

                                            It works by commenting out the .isNotEmpty() condition
                                            @d-healey I'll make a pull request to your fork in a moment if you want this fix of course...
                                            The fact is that I don't know if it can involve a wrong behavior somewhere else in Hise, so, be warned if you use it!

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

                                            26

                                            Online

                                            1.7k

                                            Users

                                            11.8k

                                            Topics

                                            102.5k

                                            Posts