Dynamically loading samples (Sampler, AudioLoopPlayer)
-
Hey there!
I'm trying to load some small generated samples over the network into different players. I've already got them loaded into the AudioLoopPlayer, but I'd love to have even more options for players. I'm thinking the sampler could be perfect for this, but I'm not sure if I can load .wav files on the fly.
So my questions are:
- Is it possible to have multiple AudioLoopPlayers, with each one being played by a different note?
- Can I dynamically load .wav files into the Sampler? I don't need fast disk streaming.
- Will I need to create a sample map to load into the sampler dynamically?
Thanks for any help you can give me!
-
I think you might find this useful - https://github.com/christophhart/hise_tutorial/tree/master/CustomSampleImport
-
Thanks for sharing your knowledge! I've gone through the code snippets and while it seems complex, it definitely gets the job done. I did want to mention that when loading the sample from the file path using
local s = [Sampler1.parseSampleFile(filePath)];
, it gives you a JSON sample map.To create the correct mapping, I used
s[0]['LoKey']
ands[0]['HiKey']
to alter the JSON sample map. You can also set other common sample map parameters here.
Since I'm able to predict that I'll always have the exact same mapping, this method works perfectly for me!Thanks again for your help!
-
@oskarsh This is good stuff. I've been trying to figure this out for a while. When your adding the
s[0]['LoKey']
&s[0]['HiKey']
methods, how are you altering the custom JSON file? Are you replacing thelocal s = [Sampler1.parseSampleFile(filePath)]
or adding to it?Your help and any snippets is greatly appreciated.
-
local s = [Sampler1.parseSampleFile(file)];
will give you a array with a json called s.simply add to the json
s[0]['LoKey']
ands[0]['HiKey']
like a normal json object. It then sets the json viaSampler1.loadSampleMapFromJSON(s);
-
@oskarsh Im not sure how to edit the JSON file I guess. Ive added the
s[0]['LoKey']
ands[0]['HiKey']
belowlocal s = [Sampler1.parseSampleFile(file)];
within theSampleLoadSave.js
script with no success. I assumed this was editing the .js which is the JSON file, yes?I'll keep plucking away. Any other info is appreciated. Thanks for getting back so quickly.
-
@trillbilly ah I see.
You will need to assign a value ...
Like s[0]['lowkey'] = 61;
I suggest you check out the basic programming section in the Hise docs.
-
@oskarsh ahhh, I was changing the "0" for the key. My mistake. I will try this again when I'm back in the studio. I appreciate your help.
Yes, I do need to get through all the docs. Definitely not where I'd like to be.
Goals...