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

      @oskarsh Did you ever find a solution for this? Im still just slamming my head against the wall.

      Are you wanting the name of the currently loaded sample map or of a single sample?

      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've got both. Ive got internal sounds that are samplemaps but would also want to show the name of the custom loaded sample.

        I've gotten the name of a samplemap to work before but for the life of me cannot get the name of the current loaded sample as well.

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

          @trillbilly local selection = Sampler1.createSelection(".*");

          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 Would this go within the code I use to see the samplemap or does this handle both the internal samplemap and the custom loaded sample?

            It says to "String regex" but I guess im confused how to create an array for the custom loaded 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.:

              Would this go within the code I use to see the samplemap

              It goes where ever you want to get an array of all the samples in the currently loaded 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

                @d-healey I've done this with label. It compiles but does not display names.

                inline function onSampleName1Control(component, value)
                {
                	local selection = Sampler1.createSelection("^.*");
                };
                
                Content.getComponent("SampleName1").setControlCallback(onSampleName1Control);
                

                I take it this is not the correct use case. I am looking in docs now for this function as well.

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

                  ("^.*");

                  What's with the ^?

                  All the code does it gets the samples into an array called selection. It doesn't do anything else, no display, no processing, no filtering.

                  There's some older (partially outdated) info about it here - https://forum.hise.audio/topic/64/fun-with-regex

                  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 Am i on the right track at all by calling it within the Calback of the Label?

                    Then I need to create a function that pulls the name of the current sample, correct?

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

                      Calback of the Label?

                      Probably not, but I don't know exactly what you want to do. The callback is triggered when the label is changed.

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

                      Then I need to create a function that pulls the name of the current sample, correct?

                      What is the "current sample"? If there is only 1 sample in the sample map then the line I gave you already gets the sample, so you just need to get the name from it using the get function.

                      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 What about samplemaps contains multiple samples, like RRs?

                        I guess maybe I didnt explain my case very clearly.

                        I have CustomSampleImport. I have internal samplemaps that include RRs. I also have the ability to load a custom sample via a button. I want to be able to display the name of either 1. the samplemap loaded or 2. the custom sample name that is loaded.

                        I hope I cleared myself up.

                        Thanks for all the input and help.

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

                          What about samplemaps contains multiple samples, like RRs?

                          The line I gave will get all samples in the current sample map. But start with 1 sample before you get more complicated.

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

                          I want to be able to display the name of either 1. the samplemap loaded or 2. the custom sample name that is loaded.

                          These are completely separate things. How do you load the factory 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

                            @d-healey Yes, 2 different things but was hoping to share a label to display the name of the loaded item. Instead of displaying samplemap name, I would be ok with displaying the sample name. Do you think there is an easier solution?

                            Samplemaps are loaded via a viewport.

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

                              Samplemaps are loaded via a viewport.

                              Presumably you already have the name of the sample map in the viewport? So you can just assign that to the label when the viewport item is selected.

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

                              was hoping to share a label to display the name of the loaded item

                              Not a problem

                              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 Here is how I am getting the samplemaps into the viewport.

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

                                If I do this, the compile works but does not pass the name to the label.

                                const var Sampler1 = Synth.getSampler("Sampler1"); //sampler
                                const var SampleViewer1 = Content.getComponent("SampleViewer1"); //viewport
                                const var list = Sampler.getSampleMapList(); //samplemaps
                                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(value);
                                };
                                
                                Content.getComponent("SampleViewer1").setControlCallback(onSampleViewer1Control);
                                
                                d.healeyD 1 Reply Last reply Reply Quote 0
                                • d.healeyD
                                  d.healey @trillbilly
                                  last edited by

                                  @trillbilly What is value?

                                  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 Ive got it working with this minor change. Does this look better?

                                    inline function onSampleViewer1Control(component, value)
                                    {
                                    	Sampler1.loadSampleMap(list[value]);
                                    	SampleName1.setValue(list[value]);
                                    };
                                    
                                    Content.getComponent("SampleViewer1").setControlCallback(onSampleViewer1Control);
                                    

                                    This works when using the viewport to change sample. Now the issue is if I use my randomize samplemap button, which does change the sample selected in the viewport, it doesnt update the label.

                                    I'll dive into the button code and see if I cant figure that out as well.

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

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

                                      Does this look better?

                                      Looking good

                                      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 Great. I think I figured out the random button issue too. Does this look solid or am I being hacky somewhere?

                                        const sampleMapsRAN = Sampler.getSampleMapList();
                                        
                                        inline function onShuffleSamplebtn1Control(component, value)
                                        {
                                        	if (value)
                                        	{
                                        		local index = Math.randInt(0, sampleMapsRAN.length);
                                        		local sampleMap = sampleMapsRAN[index];
                                        
                                        		Sampler1.loadSampleMap(sampleMap);
                                        		
                                        		SampleViewer1.setValue(index);
                                        		SampleName1.setValue(list[index]);
                                        
                                        	}
                                        };
                                        
                                        d.healeyD 1 Reply Last reply Reply Quote 0
                                        • d.healeyD
                                          d.healey @trillbilly
                                          last edited by

                                          @trillbilly Looks good, you could also remove the nest by returning early (doesn't change the logic, just improves readability).

                                          	if (!value)
                                                      return;
                                          	
                                          	local index = Math.randInt(0, sampleMapsRAN.length);
                                          	local sampleMap = sampleMapsRAN[index];
                                          
                                          	Sampler1.loadSampleMap(sampleMap);
                                          		
                                          	SampleViewer1.setValue(index);
                                          	SampleName1.setValue(list[index]);
                                          

                                          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 Got it, thank you. Now to figure out how to get the label to change with the sample import. Iv tried adding the bit of code you gave me to the SampleLoadSave.js but this did not work either. Here is what I used and where i added.

                                            inline function loadSample(file)
                                            {
                                            	local s = [Sampler1.parseSampleFile(file)];
                                            
                                            	local selection = [Sampler1.createSelection(".*")];
                                            	SampleName1.get(selection);
                                            	
                                            	s[0]['LoKey'] = 60;
                                            	s[0]['HiKey'] = 60;
                                            	s[0]['Root'] = 60;
                                            	
                                            	Sampler1.loadSampleMapFromJSON(s);
                                            }
                                            

                                            This compiles but 1. does not change the label and 2. does not allow sample to change. So i think im pretty far off or in the wrong location.

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

                                            34

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            102.1k

                                            Posts