Get Sample Filename from Sampler using custom Sample Maps.
-
@trillbilly said in Get Sample Filename from Sampler using custom Sample Maps.:
Christoph uses this case below:
So he does, I have no idea why, it makes no sense... but you don't need to change your sample's name so there is no reason to set it to anything.
@trillbilly said in Get Sample Filename from Sampler using custom Sample Maps.:
And yes, it just comes back with a number of commas like console like below
That means the array contains sample objects. Each one shows as a blank line. You can also open the script watch table to see what's going on in your variable.
@trillbilly said in Get Sample Filename from Sampler using custom Sample Maps.:
Uknown Function 'set'
Whenever you see unknown function it means the thing on the left side of the
.
doesn't have a function with the name of whatever is on the right side of the.
. This could be because the thing on the left side isn't available in the scope you are trying to use it. -
@d-healey Ok, thank you. Ive changed it to this and have now got it compiling within the SampleLoadSave.js after the sample load function.
const selection = Sampler1.createSelection(".*"); for (s in selection) { //Console.print(s.get(Sampler1.FileName)); SampleName1.set("text", s.get(Sampler1.Filename)); //Console.print(trace(selection)); }
It compiles, but again no change to the label.
-
@trillbilly You can only set the label to 1 sample name. So you don't need a loop. Just grab the first sample
[0]
from your selection and use that.const s = Sampler1.createSelection(".*")[0]; SampleName1.set("text", s.get(Sampler1.Filename));
-
@d-healey said in Get Sample Filename from Sampler using custom Sample Maps.:
const s = Sampler1.createSelection(".*")[0];
SampleName1.set("text", s.get(Sampler1.Filename));Thanks. This should replace my entire code, correct? I replaced and receive this error in the console.
API Call with undefined parameter 0
-
Show me your code
-
@d-healey if I put it within the loadSample callback in the SampleLoadSave.js, it compiles but still not change of the label.
At this moment I have it like this in order for it to compile (changed s to sn):
inline function loadSample(file) { local s = [Sampler1.parseSampleFile(file)]; s[0]['LoKey'] = 60; s[0]['HiKey'] = 60; s[0]['Root'] = 60; Sampler1.loadSampleMapFromJSON(s); const sn = Sampler1.createSelection(".*")[0]; SampleName1.set("text", sn.get(Sampler1.Filename)); }
-
@trillbilly You need to wait until the sample is loaded. Use the loading callback. https://docs.hise.audio/scripting/scripting-api/scriptpanel/index.html#setloadingcallback
-
@d-healey Holy Moly. Ok, am I even close with this?
samplepanel.setLoadingCallback(function(isPreloading) { if(isPreloading) { const sn = Sampler1.createSelection(".*")[0]; SampleName1.set("text", sn.get(Sampler1.Filename)); } });
-
@trillbilly said in Get Sample Filename from Sampler using custom Sample Maps.:
am I even close with this?
Yes, but you want it to do the thing when it's not preloading.
if(isPreloading)
becomesif(!isPreloading)
By the way, if you're using the audio waveform component that has a built in label that shows the sample name - assuming only one sample in the sample map.
-
@d-healey Samplemaps within the plugin itself have multiple samples (RRs) but the custom loaded samples are only one sample.
I have this within the SampleLoadSave.js file just below the SampleDropper loading callback. It compiles but does not change label.
const var samplepanel = Content.addPanel("SamplePanel", 0, 0); // This function will be executed whenever the preload state changes samplepanel.setLoadingCallback(function(isPreloading) { if(!isPreloading) { const sn = Sampler1.createSelection(".*")[0]; SampleName1.set("text", sn.get(Sampler1.Filename)); } });
Im using a button to load instead of the sample dropper. Would this have anything to do with it?
EDIT: Sorry, I missed this, I see it is getting the same console error of "API call with undefined parameter 0" while within this LoadingCallback.
-
@trillbilly which line? Also you probably should use var rather than const here
-
@d-healey Ok, I changed with VAR and it seems to have cleared the API issue. Now, it sets every name, including saved sample maps, as "0".
//SAMPLE NAME LOADING CALLBACK const var samplepanel = Content.addPanel("SamplePanel", 0, 0); samplepanel.setLoadingCallback(function(isPreloading) { if(!isPreloading) { var sn = Sampler1.createSelection(".*")[0]; SampleName1.set("text", sn.get(Sampler1.Filename)); } });
It will initially set the saved samplemap name but immediately change to "0". Custom Samples dont seem to set then change at all so I think its still not reading the custom sample name at all.
If I remove
[0]
from thevar sn = Sampler1.createSelection(".*")[0];
script. It displays the saved samplemap names but still does not display the custom samples name. -
@trillbilly
Sampler1.Filename
should beSampler.FileName
Here's a working example, just drop a sample into the sampler and you'll see the name in the label
HiseSnippet 1303.3ocyX0sSabDEdVLKE6lD0DkK5E8hsV8B6JpwFHjphZiwFHBULXgIQUppxZX2w1iX2YVMyrN3VwaQeP5iPejxaP6Ylcs8tFKhwMIMnnn872LeybNmuy.sEbWhTx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y4jgDgLqtSiBf7MCZ1j5NLKMOijnyuT2VXkfdcZuM6R0KvlbL7RCibsYj2ZF4smQdmYje1Lx6Ni7ymJaYms96yVLR3V3PCeRJOaPSpx.awZxRWjx0I2wFbj5cTy40Iq8g5ASqtXcZuigIe5ycl48c4GiwNTcp5P1PnmDznw3SfYb8vQ9pwZyxOzhy3gC3Lpa1N.nhteehHM1m6AZekBZ.mp4o0OGdFDVlpE9apeB7vGrHai885t39+V24lu9R6X35nI0b9uj29nVlcmy+xsPy+dui2keV3G0qtGkLUzA1cg5S777CrM73N5wt+eA0y4QJXb53QZ1vbuNvrdWR5oeqnmnFKWUKqATGByyH7OvOIFqMdTo1XswFQtiWJ3rk7s4E6V4HL8nCyy57ggv9oKokvKJzPBFugjljZ.LR5iChCvtBdW23eyGMtW2nAPLy7GSHucKsrSMj42FJMrCfYWcccytT2JvsV1.2dYCbmkMvmsrAt6xF3yW1.+92cf5mVrejhGDSrhPsZeXbwn0gSJFyg9W.bilFGA
-
@d-healey Great. This did work. Thank you!
Now I have another issue.
It is replacing the saved samplemap names with the sample file name instead.
This isnt a huge issue except for
- it shows the entire file path
- It doesnt change the name of the sample being played within the saved sample map (RRs)
Can I have it display both saved samplemaps + custom import samples?
-
@trillbilly said in Get Sample Filename from Sampler using custom Sample Maps.:
it shows the entire file path
Use the various string functions to get what you want from the full path.
@trillbilly said in Get Sample Filename from Sampler using custom Sample Maps.:
It doesnt change the name of the sample being played within the saved sample map (RRs)
I don't think you asked for that :)
@trillbilly said in Get Sample Filename from Sampler using custom Sample Maps.:
Can I have it display both saved samplemaps + custom import samples?
It can only ever display one thing, what do you want it to show when a factory sample map is loaded?
-
@d-healey you're right, I didnt ask for each sample loaded from an internal samplmemap. I'd rather it show the internal sample map name and then the custom sample name.
So internal samplemap is loaded, you see the samplemap name.
Custom sample loaded, you see the sample name.
-
@trillbilly said in Get Sample Filename from Sampler using custom Sample Maps.:
So internal samplemap is loaded, you see the samplemap name.
Ok so how are you selecting the sample map to load?
-
@d-healey like this
const var list = Sampler.getSampleMapList(); inline function onSampleViewer1Control(component, value)//viewport { Sampler1.loadSampleMap(list[value]); SampleName1.setValue(list[value]);//label };
-
@trillbilly Oh yeah I remember you posted that before. So you're already setting the label to the sample map name. What's missing?
-
@d-healey I'm not sure because it's changing it from the internal samplemap name to the only the loaded sample name/location.
It displays the samplename quickly at first, then changes to the folder name/location.
I assume I need to add this to the loader callback we made for the sample name?
Sorry, I'm on mobile now so I seem a bit choppy.