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.
    • 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
            • d.healeyD
              d.healey @trillbilly
              last edited by

              @trillbilly Sampler1.Filename should be Sampler.FileName

              Here's a working example, just drop a sample into the sampler and you'll see the name in the label

              HiseSnippet 1303.3ocyX0sSabDEdVLKE6lD0DkK5E8hsV8B6JpwFHjphZiwFHBULXgIQUppxZX2w1iX2YVMyrN3VwaQeP5iPejxaP6Ylcs8tFKhwMIMnnn872LeybNmuy.sEbWhTxEHq7WLJjfrdfcmQL0flCvTF53CPVOxtEVpHBmXUMFEhkRhGxxJ2K0JrxuJx7yaeQCrOl4RlpBgdMm5RNgFPUS01t9OS88OB6QtfFjx6cperKm0j6yi.7jytJJD6dEtO4Tr1sUrQVqcnGUwEcTXEQB9zf6Mpy.9aXw9+ZpjdoOQKTC0AVnX0nlCn9dsGeVkHjkc6om7bwm7mZ2h5Qmne5MvWXL3LMhz2AVqbWPp18.RVofzpwP5w1cbEzP0TKZ7741GyfDROLbUmFJw9hV46VwtIG7fopDfuhbj.DlDQocqVcCG3+JuWgBv0sT4LDKb5fCB8IhZN+niI+WoOQknqTwwFKlMlSvWR70QLd2fXZxCB4LPnTwXyyDSaL6thI1rIl3OqHIpS3XOJqeSru+kPAQodQLWEkyJQksED+XqkK7GExS64T5qypMOnNudmk5iVxAohqf.oqNDeR7JUrx2Vr7uV821CbF9mdcnxCH8nLhWIYYXYLqS93yjFTkJpHWqJtgiTeDJMY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0gSJFyg9W.bilFGA
              

              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 Great. This did work. Thank you!

                Now I have another issue.

                It is replacing the saved samplemap names with the sample file name instead.

                This isnt a huge issue except for

                1. it shows the entire file path
                2. It doesnt change the name of the sample being played within the saved sample map (RRs)

                Can I have it display both saved samplemaps + custom import samples?

                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.:

                  it shows the entire file path

                  Use the various string functions to get what you want from the full path.

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

                  It doesnt change the name of the sample being played within the saved sample map (RRs)

                  I don't think you asked for that :)

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

                  Can I have it display both saved samplemaps + custom import samples?

                  It can only ever display one thing, what do you want it to show when a factory sample map is loaded?

                  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 you're right, I didnt ask for each sample loaded from an internal samplmemap. I'd rather it show the internal sample map name and then the custom sample name.

                    So internal samplemap is loaded, you see the samplemap name.

                    Custom sample loaded, you see the sample name.

                    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.:

                      So internal samplemap is loaded, you see the samplemap name.

                      Ok so how are you selecting the sample map to load?

                      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 like this

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

                          @trillbilly Oh yeah I remember you posted that before. So you're already setting the label to the sample map name. What's missing?

                          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 I'm not sure because it's changing it from the internal samplemap name to the only the loaded sample name/location.

                            It displays the samplename quickly at first, then changes to the folder name/location.

                            I assume I need to add this to the loader callback we made for the sample name?

                            Sorry, I'm on mobile now so I seem a bit choppy.

                            d.healeyD 1 Reply Last reply Reply Quote 0
                            • 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
                                            • First post
                                              Last post

                                            38

                                            Online

                                            1.7k

                                            Users

                                            11.8k

                                            Topics

                                            103.0k

                                            Posts