Unknown Functions 'set' & 'getRange'
-
Hey Gang,
Im using a version of the Custom Sample Import. Everything was working great until I opened my project tonight and all the Samplers 'sound.set' and 'sound.getRange' all throw an UKNOWN FUNCTION error. It seems these are both for the Loop Range & Loop Xfade.
If I open any presets with the Loop Range or Loop Xfade saved within a preset, HISE crashes.
What are best practices for figuring out the issue? Has anyone had something like this happen before?
-
@trillbilly show us the code....
-
@Lindon Yes, of course. Here is Sampler 1. Its in the
onLoopControl&onXfadeControlFunctions.I have ran my projects XMLBackup through an XML Validator and it returned no issues. I have also removed all other coding/functions to see if something was interfering, but, it still didnt work. I also went back through and checked that I had the correct included scripts and that they were up to date.
It kind of seemed out of nowhere (of course it was, I wasnt expecting it).
//SAMPLER 1 const var Sampler1 = Synth.getSampler("Sampler1"); reg sound; reg totalSamples = 0; reg isCustomMap = false; //! "Page" Logic // Nothing special, it just shows / hides certain elements... const var editButtons = [Content.getComponent("EditLoop"), Content.getComponent("EditRange"), Content.getComponent("ShowDropper")]; const var EDIT_LOOP = 0; const var EDIT_RANGE = 1; const var SHOW_DROPPER = 2; const var AudioWaveform1 = Content.getComponent("AudioWaveform1"); const var SampleDropper = Content.getComponent("SampleDropper"); const var LoopPanel = Content.getComponent("LoopPanel"); const var Reverse = Content.getComponent("Reverse"); inline function setEditMode(editMode) { AudioWaveform1.set("enableRange", editMode == EDIT_RANGE); LoopPanel.set("visible", editMode == EDIT_LOOP); SampleDropper.set("visible", editMode == SHOW_DROPPER); } inline function setEditModeCallback(component, value) { if(value) setEditMode(editButtons.indexOf(component)); } for(b in editButtons) b.setControlCallback(setEditModeCallback); inline function onSampleMapLoaderControl(component, value) { if(value > 0) { local id = Sampler1.getSampleMapList()[value - 1]; Sampler1.loadSampleMap(id); } }; Content.getComponent("SampleMapLoader").setControlCallback(onSampleMapLoaderControl); const var SampleMapLoader = Content.getComponent("SampleMapLoader"); SampleMapLoader.set("items", Sampler1.getSampleMapList().join("\n")); setEditMode(EDIT_RANGE); //! Non persistent UI elements // These UI controls do not store any data, but will read / write // to the sample map directly. inline function onLoopControl(component, value) { sound.set(Sampler1.LoopEnabled, value); // Make sure the loop end is set to the sample end when you // enable the loop the first time if(sound.get(Sampler1.LoopEnd) == 0) sound.set(Sampler1.LoopEnd, sound.getRange(Sampler1.LoopEnd)[1]); // update the loop point panel LoopPointDragger.updateLoopPoints(); // write the loop points back into the base64 string SampleLoadSave.storeSampleMapData(); }; Content.getComponent("Loop").setControlCallback(onLoopControl); inline function onXFadeControl(component, value) { // the slider is 0...1 so we can use the available crossfade range length // to figure out how big of a crossfade we want local newValue = parseInt(sound.getRange(Sampler1.LoopXFade)[1] * value); sound.set(Sampler1.LoopXFade, newValue); LoopPointDragger.updateLoopPoints(); SampleLoadSave.storeSampleMapData(); }; Content.getComponent("XFade").setControlCallback(onXFadeControl); -
@trillbilly An unknown function error means the thing on the left side of the
.does not have the function you are trying to call.This could be because you've used the wrong variable type or because it's undefined.
-
@d-healey Ahhh ok. So now I need to figure out what was changed, and how, because those functions were working just hours earlier.
-
@trillbilly Is it because the sample map is not loaded?
-
@d-healey You're right, when I load an internal sample map, it works. But it wont work anymore with Drag-And-Drop samples.
I would rather use the sample maps from internal samples, but, you cant edit the loop range. I've made a post about it HERE.
Also, obiviously Im using custom sample import so users can use their own samples. Im confused why it doesnt recognize them as sample maps anymore?
-
@d-healey Ok, scratch that. its working ONLY if there is a sample loaded. If the sampler is cleared, it throws the error.
If you save a preset without a sample/samplemap loaded, it will save but crash upon opening it again.
-
@trillbilly So before you try to call a function on the
soundobject you need to check if the object is populated.if (!isDefined(sound)) return; -
@d-healey That will work better than my idea of populating an empty samplemap when a sampler is not in use. Thank you.
-
@d-healey It solved the
sound.setissue but not thesound.getRangeissue. -
@trillbilly This line?
local newValue = parseInt(sound.getRange(Sampler1.LoopXFade)[1] * value); -
@d-healey Yes, that is correct
-
@trillbilly And you tried placing the check before it?
-
@d-healey No, Im an idiot, I only put it in 1 callback.
Worked like a charm. Much appreciated.