HISE Logo Forum
    • Categories
    • Register
    • Login

    Samplemap 1 not loading - other load fine

    Scheduled Pinned Locked Moved General Questions
    sampelrsamplemapscustom samplessample import
    20 Posts 3 Posters 741 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.
    • trillbillyT
      trillbilly
      last edited by trillbilly

      Hey Gang,

      Im using a variation of the CustomSampleImport template. Im having a strange problem with my Samplers loading a particular sample map.

      I have this code:

      const var Sampler1 = Synth.getSampler("Sampler1"); //Sampler
      const var list = Sampler.getSampleMapList(); //Samplemap List
      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)
      {
      	if (value)
      	{
      	Sampler1.loadSampleMap(list[value]);
      	SampleName1.setValue(list[value]);
      	}
      };
      Content.getComponent("SampleViewer1").setControlCallback(onSampleViewer1Control);
      

      This works great except it will not load the first samplemap listed in my viewport. All others load fine including custom samples.

      If I remove the "IF" statement above, the samplemaps, including the finicky first one, all load fine BUT now custom samples will not save to presets.

      Where am I going wrong with this? Any help or direction would be appreciated.

      All the best.

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

        @trillbilly 'if (value)' means if the value is greater than or equal to 1

        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 Hi David, thanks for your reply.

          My original code did not have these IF statements but as I mentioned, it prevented me from saving presets with custom samples. Like this, custom samples work within saving presets.

          Is there another way to call an IF statement to keep the correct functionality?

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

            @trillbilly
            start with this:

            inline function onSampleViewer1Control(component, value)
            {
            	Console.print(value);
            };
            Content.getComponent("SampleViewer1").setControlCallback(onSampleViewer1Control);
            

            HISE Development for hire.
            www.channelrobot.com

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

              @Lindon I always forget to do this. Thanks. I'll be back in the studio later.

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

                @Lindon Ok, so I know the value of the viewport starts at 0.0. I think what I need to do in the "SampleViewer1" IF Statement is "If value equals 0 OR more".

                I know I can do "If value equals this AND that" but how do you do OR more? Is it possible?

                Now that I think about it, this would still be setting a value to the viewport, so, I fee like I would run into the same issue. Maybe I need to disable the viewport if a custom map is open? I'll test and see if this is possible.

                Best.

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

                  @trillbilly >=

                  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 Hi David, thanks for that. As I suspected, it gives the same behavior.

                    When I use if (value) it kills Samplemap 1 but works flawlessly otherwise.

                    If I use if (value >= 0 ) the Custom Imported Samples do not save in presets but everything else works correctly. Replace 0 with any number and get the same behavior.

                    Is it possible to "deselect" in the viewport? Or even disable until needed again?

                    Maybe I'm way off on how I should be tackling this.

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

                      @trillbilly I just had a look at your original post. You don't need the if (value) thing at all, because you just want to react whenever an item is selected, correct?

                      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. Thats how I had it originally, and I thought all was well but realized when I load a Custom Sample, it was not saving in the preset, it was still saving the state of the Viewport.

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

                          @trillbilly Where are you saving the custom 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 Below is some of the code I used from the Custom Sample Import Tutorial. Much of it is the same, some changed. It looks to me that the "SampleDropper" is saved to the preset while everything else should save state via the "SampleDropper". Is that correct?

                            namespace SampleLoadSave
                            {
                            
                            SampleDropper.set("saveInPreset", true);
                            
                            inline function storeSampleMapData()
                            {
                               local v =
                               {
                               	"isCustom": isCustomMap,
                               	"value": ""
                               };
                            
                               if(isCustomMap)
                               {
                               	if(isDefined(sound))
                               		v.value = Sampler1.getSampleMapAsBase64();
                               }
                               else
                               	v.value = Sampler1.getCurrentSampleMapId();
                               	
                               SampleDropper.setValue(v);
                            }
                            
                            inline function setAndStore(property, value)
                            {
                               // do not store anything in a non-custom map
                               if(!isCustomMap)
                               	return;
                            
                               sound.set(property, value);
                               storeSampleMapData();
                            }
                            
                            inline function onSampleDropperControl(component, value)
                            {
                               // Check if it's an object that has a `value` key
                               if(isDefined(value.value))
                               {
                               	if(!value.isCustom)
                               	{
                               		// if the string is empty, we'll clear the map
                               		// otherwise we load it as ID
                            
                               		if(value.value.length == 0)
                               			Sampler1.clearSampleMap();
                               		else
                               			Sampler1.loadSampleMap(value.value);
                               	}
                               	else
                               		Sampler1.loadSampleMapFromBase64(value.value);
                               }
                            };
                            
                            Content.getComponent("SampleDropper").setControlCallback(onSampleDropperControl);
                            
                            inline function initAfterSampleLoad()
                            {
                               local id = Sampler1.getCurrentSampleMapId();
                               
                               isCustomMap = id == "CustomJSON";
                               
                               if(isCustomMap || id.length == 0)
                               	SampleViewer1.setValue(0);
                               else
                               	SampleViewer1.setValue(Sampler1.getSampleMapList().indexOf(id) * 1);
                               	
                               // fetch the first sound
                               sound = Sampler1.createSelection(".*")[0];
                               totalSamples = 0;
                               
                               // if the sample map is empty, clear everything and abort.
                               if(!isDefined(sound))
                               {
                               	LoopPointDragger.updateLoopPoints();
                               	storeSampleMapData();
                               	return;
                               }
                               
                            }
                            
                            /** This function will load the given file as new samplemap. */
                            inline function loadSample(file)
                            {
                               // the parseSampleFile method will try to 
                               // read the metadata (loop points) from the audio file
                               // and create a relative reference if the sample's in
                               // the sample folder
                               local s = [Sampler1.parseSampleFile(file)];
                               
                               s[0]['LoKey'] = 0;
                               s[0]['HiKey'] = 127;
                               s[0]['Root'] = 60;
                               
                               Sampler1.loadSampleMapFromJSON(s);
                               
                            }
                            
                            SampleDropper.setLoadingCallback(function(isPreloading)
                            {
                                if(!isPreloading)
                                {
                            
                               	  // whenever this is executed, we'll store the current samplemap data 
                               	  // back into the sample dropper's value and update all non persistent
                               	  // controls
                               	  initAfterSampleLoad();
                                }
                            });
                            
                            d.healeyD 1 Reply Last reply Reply Quote 0
                            • d.healeyD
                              d.healey @trillbilly
                              last edited by

                              @trillbilly Yeah the sample dropper is set to save in preset, but are you overwriting it with the state of the viewport?

                              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 dont think so. I've been digging through the code to insure everything looks correct, and it does to me anyway. I've compared it side by side with the original code from the Custom Sample Import Template and do not see where the issue lies.

                                I will keep digging and see what I can come up with.

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

                                  @trillbilly Is your viewport set to saveInPreset? If so, does its callback trigger after the sample dropper's callback when changing presets?

                                  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, the viewport is set to saveInPreset.

                                    Taking the below code from onInit and placing below the SampleDroppers code in the SampleLoadSave.js does not solve the issue.

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

                                    Is this what you meant?

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

                                      @trillbilly said in Samplemap 1 not loading - other load fine:

                                      Is this what you meant?

                                      Nope. I meant do a control print in both of them and see which appears first in the console when changing presets.

                                      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 on mobile right now so I will do this when I get back.

                                        Is control print and console print different? I dont see documentation on either.

                                        Thanks again.

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

                                          @trillbilly said in Samplemap 1 not loading - other load fine:

                                          Is control print and console print different?

                                          Yes control print is a typo :p

                                          I meant Console.print.

                                          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 When I use Console.print it does seem the SampleDropper is performing BEFORE the Viewport.

                                            Interface: Object 0x8371f570 (SampleDropper)
                                            Interface: 50.0 (Samplemap)

                                            I've got the Viewport calling for samplemaps in oninit. I've got the SampleDropper contained to the SampleLoadSave.js.

                                            I guess I assumed that oninit was processed first and then the other .js files.

                                            How do I go about switching the order in which their callbacks trigger?

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

                                            23

                                            Online

                                            1.8k

                                            Users

                                            11.9k

                                            Topics

                                            104.0k

                                            Posts