Samplemap 1 not loading - other load fine
-
@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.
-
@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?
-
@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.
-
@trillbilly Where are you saving the custom sample map?
-
@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(); } });
-
@trillbilly Yeah the sample dropper is set to save in preset, but are you overwriting it with the state of the viewport?
-
@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.
-
@trillbilly Is your viewport set to saveInPreset? If so, does its callback trigger after the sample dropper's callback when changing presets?
-
@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?
-
@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.
-
@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.
-
@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.
-
@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?