AudioLoopPlayer load
-
@MikeB Take a break Mike
-
Here's a simple version that splits the audio files list into two arrays, one for folders, and one for files.
const audioFiles = Engine.loadAudioFilesIntoPool(); const folders = []; const files = []; inline function splitAudioFilesList() { for (x in audioFiles) { local folder = x.substring(x.indexOf("}") + 1, x.indexOf("/")); if (folders.indexOf(folder) == -1) // Prevents duplicate folder names folders.push(folder); files.push(x.substring(x.indexOf("/") + 1, x.length)); } } splitAudioFilesList(); Console.print(trace(folders)); Console.print(trace(files));
And here's another way (my preferred choice) which organises the samples into one array per folder. All of the arrays are stored in a single object so you can access them with
sorted.folderName[index]
.const audioFiles = Engine.loadAudioFilesIntoPool(); const sorted = {}; inline function sortAudioFilesList() { for (x in audioFiles) { local folder = x.substring(x.indexOf("}") + 1, x.indexOf("/")); local file = x.substring(x.indexOf("/") + 1, x.length); if (!isDefined(sorted[folder])) sorted[folder] = []; sorted[folder].push(file); } } sortAudioFilesList(); Console.print(trace(sorted));
-
@d-healey
Then, thanks to you, I have made a small step forward today. And the day was not completely in vain.
Thank you very much David.I will deal with this tomorrow
-
@d-healey
New day - new misfortuneJust kidding :-)
I have now implemented your scriptsnippet.
It works in principle - but unfortunately the samples are not
from the respective folder are loaded but always the first samples in the order.
So the bass samples appear in the Kick folder.
The bass samples appear in the HiHat folder.The array folders goes from 0-8
The array files goes from 0 -490
But in each folder there are only 55 samplesWith your 2nd method I don't know how to distribute them to the two knobs. The first one selects the folder and the second one selects the samples in the folder.
const audioFiles = Engine.loadAudioFilesIntoPool(); const folders = []; const files = []; var InstrumentID_S1; var VariationID_S1; inline function splitAudioFilesList() { for (x in audioFiles) { local folder = x.substring(x.indexOf("}") + 1, x.indexOf("/")); if (folders.indexOf(folder) == -1) // Prevents duplicate folder names folders.push(folder); files.push(x.substring(x.indexOf("/") + 1, x.length)); } } splitAudioFilesList(); Console.print(trace(folders)); //Console.print(trace(files)); //Knob-KitSelector---------------------------------------------------------------------- inline function onKitSelector_Knob_S1Control(component, value){ InstrumentID_S1 = parseInt(value); //Knobvalue 1-55 Console.print("{PROJECT_FOLDER}"+folders[InstrumentID_S1]+"/"+files[VariationID_S1]); }; Content.getComponent("KitSelector_Knob_S1").setControlCallback(onKitSelector_Knob_S1Control); //End -------------------------------------------------------------------------------------- //Knob-SampleSelector----------------------------------------------------------------- inline function onSampleSelector_Knob_S1Control(component, value){ VariationID_S1 = parseInt(value-1); //Knobvalue 1-55 Console.print("Variation_S1" + "{PROJECT_FOLDER}"+folders[InstrumentID_S1]+"/"+files[VariationID_S1]); }; Content.getComponent("SampleSelector_Knob_S1").setControlCallback(onSampleSelector_Knob_S1Control); //End ---------------------------------------------------------------------------------------------------
-
Here's a hybrid approach, a mix between my previous two versions. This one sorts the file paths into a 2D array. The first index is the folder, the second index is the file name.
So you can access them directly with the knob values.
sorted[knob value 1][knob value 2];
const audioFiles = Engine.loadAudioFilesIntoPool(); const folders = []; const sorted = []; inline function sortAudioFilesList() { for (x in audioFiles) { local folder = x.substring(x.indexOf("}") + 1, x.indexOf("/")); local file = x.substring(x.indexOf("/") + 1, x.length); if (folders.indexOf(folder) == -1) { folders.push(folder); sorted.push([]); } sorted[folders.indexOf(folder)].push(file); } } sortAudioFilesList(); Console.print(trace(sorted));
-
Unfortunately, absolutely nothing - nothing happens at all.
const audioFiles = Engine.loadAudioFilesIntoPool(); const folders = []; const sorted = []; var InstrumentID_S1; var VariationID_S1; inline function sortAudioFilesList() { for (x in audioFiles) { local folder = x.substring(x.indexOf("}") + 1, x.indexOf("/")); local file = x.substring(x.indexOf("/") + 1, x.length); if (folders.indexOf(folder) == -1) { folders.push(folder); sorted.push([]); } sorted[folders.indexOf(folder)].push(file); } } sortAudioFilesList(); //Console.print(trace(sorted)); //Knob-KitSelector---------------------------------------------------------------------------------------------------------------------- inline function onKitSelector_Knob_S1Control(component, value) { InstrumentID_S1 = parseInt(value); //Knobvalue 1-9 Console.print(sorted[InstrumentID_S1][VariationID_S1]); }; Content.getComponent("KitSelector_Knob_S1").setControlCallback(onKitSelector_Knob_S1Control); //Knob-SampleSelector---------------------------------------------------------------------------------------------------------------------- inline function onSampleSelector_Knob_S1Control(component, value) { VariationID_S1 = parseInt(value-1); //Knobvalue 1-55 Console.print(sorted[InstrumentID_S1][VariationID_S1]); }; Content.getComponent("SampleSelector_Knob_S1").setControlCallback(onSampleSelector_Knob_S1Control);
-
You have this in your onKitSelector_knob_S1Control callback
Console.print(sorted[InstrumentID_S1][VariationID_S1]);
VariationID_S1
doesn't exist in that callback (unless it's a scriptwide variable, but I'm not seeing it in your code). -
@d-healey
they were commented out - of course you can't work like that :-)Now I see in Console.print:
Interface: 41_EctoplasmKick_747.wav
Interface: 41_EctoplasmKick_747.wav
Interface: 45_SundayPerc_01_737.wav
Interface: 45_SundayPerc_01_737.wav
Interface: 47_ProvTom_809.wav
Interface: 47_ProvTom_809.wav2x the sample - no folder
correct would be:
02-Kick/41_EctoplasmKick_747.wavMaybe I should make a snippet - or?
-
@MikeB You get the folder name from the folders array.
-
@d-healey
Sorry but here is a snippet - it doesn't workHiseSnippet 1293.3ocyW0saiSDEdba8BwKfXk.o8xQ4pD0lzDX6xJUUQZSSPk9WTSYEqpJUSrmzLpimwxdbaiVEIdM16PhWDdK3EfG.dCfyX6Da25VZhDBFkKxb9a9N+M9L87k1zf.oOxnzoi8nHiOwr+XgZT6QDl.s2tHiWZ1hdoDuOS0mxo1JoOdaeexXzNi8HAATGjgwxemVZiRqfhV+42tCgSD1zTRHzakLa5ALWlJkZuV6y37tDG5oL2LR+pV6YKEskbYHfrkMaf7H1WQtjdDQK1RlHim0wgAXouhnnAfL6HcF2ej7FQr7ukEvFvo5MMQ8ACESF0dDi6zapWGfPFqzKMFrbbL3KLOj4vlQOMV74QLvoZjMFXrTdHsRNH07gfTWI2QafG.dFYf2Jwv6El8s8YdpTNZr8by8DJp+PBD1yBqXYQKc5GY1VBRHT0cIWQ65CaloQkW2nwZ3MZzn5lVVPnOPgul3mMoew9B4fK52DuEdpYtjpZKc8jBXSkxEHaYvZoFq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22PuWGY5CC7Ds4ufUByl58FILaNkITrY6KuvNtWU+DjONhBfIQzquJYdndOdVOooYi5MPtvKitv1VGJp0DgJVmuZAz4qW.cd0BnyFKfNudAz4aV.cdyipi9QoaGpjtwsI.gdchtazvnif.UYQUjn+1Uy+3n
-
@MikeB said in AudioLoopPlayer load:
it doesn't work
It does exactly what you've told it to do.
Array elements are accessed by their index. So if you want the string in the folders array at index 0 you need to write
folders[0]
. Replace0
with the knob's value. -
It works fantastic
Here is the complete working snippet for all those who want to load kits or instruments and samples into the AudioLoopPlayer.
From David (the complex part) and from MikeB (the simple stuff)for example:
{PROJECT_FOLDER}05-Cymbal/JitterCymbal.wavThe whole thing looks for which folders are in the AudioPool and which samples are in them. And gives you the possibility with 2 Knobs
a. to select the folder and
b. the sample.HiseSnippet 1797.3oc4X0saaaCEVJIpsVscXcqCnWRXLf4fz3X2lzVrff5zDmgrlzXDmFLfrf.FIZahHSpIQmePQvta2tWgd2dM1ivdT1av1gT+QknjZ600VrI3KLO7vy4iG9wCOjsB3NjvPdfgYocNymXXdGq1mwD8VoGlxLVeUCyuv5kTQahGwQvCVNH.elwKNyGGFRbMLMm76j5YVZJC02e97Wf8vLGRlHCic4TGxFz9TQlzVMdI0yaMrKYGZeMsmuw5Nb1JbO9..SSZUyvG6bDtK4UXoZSXYXdiltT.JsEXAIzvbpWvcOqcO9IrH82kFROziHaT2nMXnHwqw8bkHV9eiU5Q8bakL2CMLLsZkEIlLJRbeqMotzT4YQjOW0AJaD5wCyItN3UeLgmoF7lJBd2ypsS.0Wj0iDa21ZclfDzACKA5vJRWiI9rRVqvAMXhp8wGQVK.ZjNhJOoVsGhVnVsoWz1FVFBEniwAnkG3R4av49s7vmQBpiVBo3HU6RDJnpZUorROjTQTrlkACkYGMdzAujwO7f1RSk.Gow3884LnQkxEnadi0F222iLz1qX0KmMQwRvuF0iDB1nIqKkQp5wwtKmJGBS7VbtWkTbzQtnEHGvd6mHCVHDD2XQ1RjtNHNXPe.FquJ3yEU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