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

                        25

                        Online

                        1.8k

                        Users

                        12.0k

                        Topics

                        104.0k

                        Posts