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 4.0k 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.
    • LindonL
      Lindon @trillbilly
      last edited by

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

      @d-healey If this is the correct way, what about my script is incorrect? I have also tried

      	SampleName1.setValue(s.get(Sampler1.Filename));
      

      But neither snippet has worked. They have both compiled, but not changed the label.

      @oskarsh This is what I was afraid of. How else could you view the name of the currently loaded sample if its a custom samplemap?

      if:

      SampleName1.setValue(s[value]);

      is attempting to set the text of a label called SampleName1, then try:

      SampleName1.set("text",s[value]);

      -- but in your code thats gonna happen a lot of times - once for each sample name in selection

      HISE Development for hire.
      www.channelrobot.com

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

        @d-healey I assume thats what something like this was doing:

        const selection = Sampler1.createSelection(".*");
        
        for (s in selection)
        
        	{
        	//Console.print(s.get(Sampler1.FileName));
        	s.set(Sampler1.Filename, s.get(Sampler1.Filename));
        	SampleName1.setValue(s.get(Sampler1.Filename));//label
        

        Since this changes the label text from a combobox/viewport samplemap:

        const var list = Sampler.getSampleMapList();
        
        inline function onSampleViewer1Control(component, value)//viewport
        {
        	Sampler1.loadSampleMap(list[value]);
        	SampleName1.setValue(list[value]);//label
        	
        };
        
        LindonL d.healeyD 2 Replies Last reply Reply Quote 0
        • LindonL
          Lindon @trillbilly
          last edited by

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

          @d-healey I assume thats what something like this was doing:

          const selection = Sampler1.createSelection(".*");
          
          for (s in selection)
          
          	{
          	//Console.print(s.get(Sampler1.FileName));
          	s.set(Sampler1.Filename, s.get(Sampler1.Filename));
          	SampleName1.setValue(s.get(Sampler1.Filename));//label
          

          Since this changes the label text from a combobox/viewport samplemap:

          const var list = Sampler.getSampleMapList();
          
          inline function onSampleViewer1Control(component, value)//viewport
          {
          	Sampler1.loadSampleMap(list[value]);
          	SampleName1.setValue(list[value]);//label
          	
          };
          

          look at those two pieces of code.... one is passing in something called value (the second piece of code) where as the first has no idea what "value" is....

          HISE Development for hire.
          www.channelrobot.com

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

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

            s.set(Sampler1.Filename, s.get(Sampler1.Filename));

            What do you think this does?

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

            SampleName1.setValue(s.get(Sampler1.Filename));//label

            Try changing the text instead of the value.

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

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

              ..also try this..

              const selection = Sampler1.createSelection(".*");
              
              Console.print(trace(selection));
              
              

              HISE Development for hire.
              www.channelrobot.com

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

                @d-healey said in Get Sample Filename from Sampler using custom Sample Maps.:

                s.set(Sampler1.Filename, s.get(Sampler1.Filename));

                What do you think this does?

                I thought it was setting s to be the filename of the loaded custom sample.

                @Lindon Ayaya (in my Mario voice). Call me Simpleton...

                I have ran the trace and it comes back empty. I have also change the setValue to set the text as you suggested.

                const selection = Sampler1.createSelection(".*");
                
                for (s in selection)
                
                	{
                	//Console.print(s.get(Sampler1.FileName));
                	s.set(Sampler1.Filename, s.get(Sampler1.Filename));
                	SampleName1.set("text",s[value]);
                	Console.print(trace(selection));
                	}
                

                Again, it compiles but the label does not change when using a custom samplemap.

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

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

                  I thought it was setting s to be the filename of the loaded custom sample.

                  Let's break it down.
                  s.get(Sampler1.Filename)

                  This will get the name of the sample s

                  s.set(Sampler1.Filename,

                  This will set the name of sample s

                  s.set(Sampler1.Filename, s.get(Sampler1.Filename));

                  So this will set the name of sample s to the name of sample s. In other words it doesn't do anything.

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

                  I have ran the trace and it comes back empty.

                  Are you running this code after you have loaded the sample map?

                  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 trillbilly

                    @d-healey In THIS post you referred me too, Christoph uses this case below:

                        sample.set(Sampler.RootKey, sample.get(Sampler.RootKey);
                    

                    This is where I thought he was setting & getting sample to be the RootKey. I took this and thought it would set s to be the Sampler1.FileName.

                    And yes, it just comes back with a number of commas like console like below

                    Interface: [
                      ,
                      ,
                      ,
                      ,
                      ,
                      ,
                      
                    ]
                    

                    Also, if I put the entirety of the code into the SampleLoadSave.js, below where the sample is loaded, it gives this error in regards too SampleName1.set("text",s[value]);

                    Uknown Function 'set'

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

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

                      Christoph uses this case below:

                      So he does, I have no idea why, it makes no sense... but you don't need to change your sample's name so there is no reason to set it to anything.

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

                      And yes, it just comes back with a number of commas like console like below

                      That means the array contains sample objects. Each one shows as a blank line. You can also open the script watch table to see what's going on in your variable.

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

                      Uknown Function 'set'

                      Whenever you see unknown function it means the thing on the left side of the . doesn't have a function with the name of whatever is on the right side of the .. This could be because the thing on the left side isn't available in the scope you are trying to use it.

                      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 Ok, thank you. Ive changed it to this and have now got it compiling within the SampleLoadSave.js after the sample load function.

                        const selection = Sampler1.createSelection(".*");
                        
                        for (s in selection)
                        
                        	{
                        	//Console.print(s.get(Sampler1.FileName));
                        	SampleName1.set("text", s.get(Sampler1.Filename));
                        	//Console.print(trace(selection));
                        	}
                        

                        It compiles, but again no change to the label.

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

                          @trillbilly You can only set the label to 1 sample name. So you don't need a loop. Just grab the first sample [0] from your selection and use that.

                          const 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 said in Get Sample Filename from Sampler using custom Sample Maps.:

                            const s = Sampler1.createSelection(".*")[0];
                            SampleName1.set("text", s.get(Sampler1.Filename));

                            Thanks. This should replace my entire code, correct? I replaced and receive this error in the console.

                            API Call with undefined parameter 0
                            
                            d.healeyD 1 Reply Last reply Reply Quote 0
                            • d.healeyD
                              d.healey @trillbilly
                              last edited by

                              @trillbilly

                              Show me your code

                              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 if I put it within the loadSample callback in the SampleLoadSave.js, it compiles but still not change of the label.

                                At this moment I have it like this in order for it to compile (changed s to sn):

                                inline function loadSample(file)
                                {
                                	local s = [Sampler1.parseSampleFile(file)];
                                	
                                	s[0]['LoKey'] = 60;
                                	s[0]['HiKey'] = 60;
                                	s[0]['Root'] = 60;
                                
                                	Sampler1.loadSampleMapFromJSON(s);
                                	
                                	const sn = Sampler1.createSelection(".*")[0];
                                	SampleName1.set("text", sn.get(Sampler1.Filename));
                                
                                }
                                
                                d.healeyD 1 Reply Last reply Reply Quote 0
                                • d.healeyD
                                  d.healey @trillbilly
                                  last edited by

                                  @trillbilly You need to wait until the sample is loaded. Use the loading callback. https://docs.hise.audio/scripting/scripting-api/scriptpanel/index.html#setloadingcallback

                                  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 Holy Moly. Ok, am I even close with this?

                                    samplepanel.setLoadingCallback(function(isPreloading)
                                    {
                                    	if(isPreloading)
                                    	{
                                    		const sn = Sampler1.createSelection(".*")[0];
                                    		SampleName1.set("text", sn.get(Sampler1.Filename));
                                    	}
                                       
                                    });
                                    
                                    d.healeyD 1 Reply Last reply Reply Quote 0
                                    • d.healeyD
                                      d.healey @trillbilly
                                      last edited by d.healey

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

                                      am I even close with this?

                                      Yes, but you want it to do the thing when it's not preloading.

                                      if(isPreloading) becomes if(!isPreloading)

                                      By the way, if you're using the audio waveform component that has a built in label that shows the sample name - assuming only one sample in the sample map.

                                      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 trillbilly

                                        @d-healey Samplemaps within the plugin itself have multiple samples (RRs) but the custom loaded samples are only one sample.

                                        I have this within the SampleLoadSave.js file just below the SampleDropper loading callback. It compiles but does not change label.

                                        const var samplepanel = Content.addPanel("SamplePanel", 0, 0);
                                        
                                        // This function will be executed whenever the preload state changes
                                        samplepanel.setLoadingCallback(function(isPreloading)
                                        {
                                        	if(!isPreloading)
                                        	{
                                        		const sn = Sampler1.createSelection(".*")[0];
                                        		SampleName1.set("text", sn.get(Sampler1.Filename));
                                        	}
                                           
                                        });
                                        

                                        Im using a button to load instead of the sample dropper. Would this have anything to do with it?

                                        EDIT: Sorry, I missed this, I see it is getting the same console error of "API call with undefined parameter 0" while within this LoadingCallback.

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

                                          @trillbilly which line? Also you probably should use var rather than const here

                                          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 trillbilly

                                            @d-healey Ok, I changed with VAR and it seems to have cleared the API issue. Now, it sets every name, including saved sample maps, as "0".

                                            //SAMPLE NAME LOADING CALLBACK
                                            const var samplepanel = Content.addPanel("SamplePanel", 0, 0);
                                            
                                            samplepanel.setLoadingCallback(function(isPreloading)
                                            {
                                            	if(!isPreloading)
                                            	{
                                            		var sn = Sampler1.createSelection(".*")[0];
                                            		SampleName1.set("text", sn.get(Sampler1.Filename));
                                            	}
                                               
                                            });
                                            

                                            It will initially set the saved samplemap name but immediately change to "0". Custom Samples dont seem to set then change at all so I think its still not reading the custom sample name at all.

                                            If I remove [0] from the var sn = Sampler1.createSelection(".*")[0]; script. It displays the saved samplemap names but still does not display the custom samples name.

                                            d.healeyD 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            14

                                            Online

                                            1.7k

                                            Users

                                            11.8k

                                            Topics

                                            103.0k

                                            Posts