HISE Logo Forum
    • Categories
    • Register
    • Login

    Get Sample Filename from Sampler using custom Sample Maps.

    Scheduled Pinned Locked Moved General Questions
    samplerfilenameattribute
    72 Posts 4 Posters 3.9k 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 @trillbilly
      last edited by

      @trillbilly Oh I see. You can just put a reg variable at the top of your script called currentSampleMapName and when you load the sample map you set the variable to its name, and when you are importing a sample you set the name to "custom". Then in the loading callback you can check the variable and if it's not custom you can just exit the function.

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

      trillbillyT 2 Replies Last reply Reply Quote 0
      • trillbillyT
        trillbilly @d.healey
        last edited by

        @d-healey OK thanks. I'll try this when I'm back in studio tomorrow. I'm sure I will f*ck something up and be back.

        Thanks again, David.

        trillbillyT 1 Reply Last reply Reply Quote 0
        • trillbillyT
          trillbilly @trillbilly
          last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • trillbillyT
            trillbilly @d.healey
            last edited by

            @d-healey Hi David, I've got it to work like this:

            //SAMPLE NAME LOADING CALLBACK
            const var samplepanel = Content.addPanel("SamplePanel", 0, 0);
            
            samplepanel.setLoadingCallback(function(isPreloading)
            {
            	if (!isPreloading)
            	{
            	     var s = Sampler1.createSelection(".*")[0];
            	}
            	
            	if (isDefined(list))
            	{
            	     SampleViewer1.set("items", list.join("\n"));	
            	}
            	
            	if (isCustomMap)
            	{
            	     SampleName1.set("text", s.get(Sampler1.FileName));	
            	}
            
            });
            

            Does this look solid?

            If so, I am on to trying to decipher the issue of showing only the filename rather than the file location for custom loaded samples.

            Thanks again.

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

              @trillbilly I think it could be improved. You don't need to do anything in the preload callback to display the name of sample maps, since you already have that working. All you need to do is check that it's not a sample map before you display the sample name.

              Something like this:

              if (!isPreloading && isCustomMap)
              {
                  var s = Sampler1.createSelection(".*")[0];
                  SampleName1.set("text", s.get(Sampler1.FileName));
              }
              

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

              trillbillyT 1 Reply Last reply Reply Quote 0
              • trillbillyT
                trillbilly @d.healey
                last edited by

                @d-healey Cool, thank you! If you've got it handy, could you point me to where the sting options for filenames are? Thanks.

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

                  @trillbilly Just search string in the API browser and you'll see all the string functions. They apply to all strings regardless of if they are file names. To get the name of a file object as a string you can use the toString() function https://docs.hise.audio/scripting/scripting-api/file/index.html#tostring

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

                  trillbillyT 1 Reply Last reply Reply Quote 1
                  • trillbillyT
                    trillbilly @d.healey
                    last edited by

                    @d-healey Hi David, I had to rebuild my plugin and now am having issues with this again. Could you take a look at this?

                    I have this in my onInit:

                    const var Sampler1 = Synth.getSampler("Sampler1");
                    const var list = Sampler.getSampleMapList();
                    const var SampleViewer1 = Content.getComponent("SampleViewer1");//viewport
                    const var SampleName1 = Content.getComponent("SampleName1");//label
                    
                    SampleViewer1.set("useList", true);
                    SampleViewer1.set("items", list.join("\n"));
                    
                    inline function onSampleViewer1Control(component, value)
                    {
                    	Sampler1.loadSampleMap(list[value]);
                    	SampleName1.setValue(list[value]);
                    };
                    Content.getComponent("SampleViewer1").setControlCallback(onSampleViewer1Control);
                    

                    This is loading Samplemaps via the Viewport. It is supposed to update the label with the name of the Samplemap as well but fails to do so upon clicking the Samplemap in the Viewport.

                    I have this in the SampleLoadSave.js:

                    const var samplepanel = Content.addPanel("SamplePanel", 0, 0);
                    
                    samplepanel.setLoadingCallback(function(isPreloading)
                    {
                    	if (!isPreloading && isCustomMap)
                    	{
                        var s = Sampler1.createSelection(".*")[0];
                        SampleName1.set("text", s.get(Sampler1.FileName));
                    	}
                    });
                    

                    This is the code you kindly provided me above. It sets the name of the label to the Custom Sample Filename/Path.

                    Everything works as it should except the Label not updating upon clicking the Samplemap in the Viewport.

                    Can you spot an issue?

                    All the best!

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

                      @trillbilly said in Get Sample Filename from Sampler using custom Sample Maps.:

                      you are going to have to start to debug your own code I think, so start like this:

                      const var Sampler1 = Synth.getSampler("Sampler1");
                      const var list = Sampler.getSampleMapList();
                      const var SampleViewer1 = Content.getComponent("SampleViewer1");//viewport
                      const var SampleName1 = Content.getComponent("SampleName1");//label
                      
                      SampleViewer1.set("useList", true);
                      SampleViewer1.set("items", list.join("\n"));
                      
                      inline function onSampleViewer1Control(component, value)
                      {
                      	Sampler1.loadSampleMap(list[value]);
                      	SampleName1.setValue(list[value]);
                          
                             Console.print("I think Im loading:" + list[value]);
                      
                      };
                      Content.getComponent("SampleViewer1").setControlCallback(onSampleViewer1Control);
                      

                      and

                      samplepanel.setLoadingCallback(function(isPreloading)
                      {
                      	if (!isPreloading && isCustomMap)
                      	{
                                      var s = Sampler1.createSelection(".*")[0];
                                       SampleName1.set("text", s.get(Sampler1.FileName));
                      
                                      Console.print("I think Im setting the label to:" + s.get(Sampler1.FileName));
                      
                      	}
                      });
                      

                      So all I'm doing there is checking its working, and working with values i expect... try that and see what you get..

                      HISE Development for hire.
                      www.channelrobot.com

                      trillbillyT 1 Reply Last reply Reply Quote 0
                      • trillbillyT
                        trillbilly @Lindon
                        last edited by

                        @Lindon Hi Lindon, thanks for the help! You're right, I should be doing this long before I come to the forum. I will for items like this going forward.

                        As for the issue, the Dynamic Sample loading seems to be working perfect, it just calling the samplemap name from the viewport that isnt correct,

                        When I use the console.print command, it does print a value that I know but it always just prints the first Samplemap name, no matter which I have selected in the viewport. Its just catching me off guard because we had it working previously with this exact code structure. I quadruple checked to insure I didnt change anything, and it all looks correct.

                        I'll keep looking over it again and try a few different things to see what the results are.

                        Again, I appreciate the help and time!

                        Best.

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

                          @trillbilly well you cant do this for a start:

                          SampleName1.setValue(list[value]);

                          HISE Development for hire.
                          www.channelrobot.com

                          trillbillyT 1 Reply Last reply Reply Quote 0
                          • trillbillyT
                            trillbilly @Lindon
                            last edited by

                            @Lindon Hi Lindon. I used this now and its working as expected.

                            inline function onSampleViewer1Control(component, value)
                            {
                            	if (value > 0)
                            	{
                            		local id = Sampler1.getSampleMapList()[value - 1];
                            
                            		Sampler1.loadSampleMap(list[value]);
                            		SampleName1.setValue(list[value]);
                            		
                            		Sampler1.loadSampleMap(id);
                            	}
                            	
                            };
                            
                            Content.getComponent("SampleViewer1").setControlCallback(onSampleViewer1Control);
                            

                            If I take out the part you said was incorrect, then it stops working again.

                            Is there a different way I should go about this now?

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

                            13

                            Online

                            1.7k

                            Users

                            11.8k

                            Topics

                            102.6k

                            Posts