load next, previous, random sample from folder of currently loaded sample
-
so i think im finally ready to finish this project ive been working on but i want to add the ability to click next, previous and random sample from the currently loaded sample folder.
i figured out how to do it through a little customization of a snippet in the forum but that was only to load a static file from a static location simply using numbers..
its like the redrum module in reason, when a kit is loaded any of the slots your can click next or previous to go thru say the different cymbals, hats etc. it would cycle thru whatever was in the current folder that the previous sample was loaded from. i know it would have something to do with arrays etc but its beyond my scope of hise to write something like that honestly.
so how would i do that for multiple loop players say 2 to start
thanks im almost done finally! lol
-
@mwplugs
This is how you load samples into the loop player using variables :const var AudioLoopPlayer0 = Synth.getAudioSampleProcessor("Audio Loop Player0"); const var AudioLoopPlayer1 = Synth.getAudioSampleProcessor("Audio Loop Player1"); // Declare 3 samples const s0 = "{PROJECT_FOLDER}sample0.wav"; const s1 = "{PROJECT_FOLDER}sample1.wav"; const s2 = "{PROJECT_FOLDER}sample2.wav"; // And load some into the loop players AudioLoopPlayer0.setFile(s2); AudioLoopPlayer1.setFile(s1);
This is how you do the same with an array of sample :
// Declare an array of samples const grpS = ["{PROJECT_FOLDER}sample0.wav", "{PROJECT_FOLDER}sample1.wav", "{PROJECT_FOLDER}sample2.wav"]; // Load the same samples into the loop players using the array indexes : AudioLoopPlayer1.setFile(grpS[2]); AudioLoopPlayer2.setFile(grpS[1]);
Then loading a random sample from an array is simple, just use
Math.randInt(var low, var high)
to grab a random integer and use this number as an array index.For what you want to do, you have to group your different samples into categories (arrays). Each of your loop players will load samples from their own category. Then write a function to load random samples into each loop players when a button is pressed.
Array manipulation is one of the scripting basics, you should definetely learn how to use them.
Check @d-healey 's video on his youtube channel https://www.youtube.com/watch?v=Y8sraa5ig-M and subscribe to his patreon page. He made some tutorials on the subject and his videos in general will definetely help you. -
@Matt_SF well i figured it out for the most part created somewhat of a custom solution but it works good
so what i need to know now is...
how to send the file folder location of the currently loaded sample to a variable and have it used in the setfile command
and secondly how would make a button randomly select an item in a combo box
-
and secondly how would make a button randomly select an item in a combo box
const var ComboBox1 = Content.getComponent("ComboBox1"); const numItems = 4 ; inline function onButton1Control(component, value) { if(!value) return; local rand = Math.randInt(1, numItems + 1); ComboBox1.setValue(rand); ComboBox1.changed(); }; Content.getComponent("Button1").setControlCallback(onButton1Control);
To load files into an array, do the same you've done for your Irs
-
Adding snippet
HiseSnippet 897.3ocsV01SaCCD1osAsD1Pfz9AjwmBZLTCvXSBMMVKvT0FP0JCs8IjwwkZgicjiCipI9Ou+AamSRaRYADqRKenp2KOWdty2cN8URBMIQpPVNmNNlhrdp8fwB8ntivLAp29HqkrOBmnoJubUcFGiSRngHKqleznvxoEJ64WuuCliEDZoJD5LIiP+LKhoK01euOw37CwgzSYQU7d685QjhtRtLE3SS61nXL4J7kziwF2ZXirV3fPlVpFnwZZBxpUGY33Aij+Pj6+YrD1EbpQH.M.BTt5Ck7PCiM+G0cDiG1eRdmffnzurJzLuJ7b6iXgro5KqFKmYvqDQ05gUiYoWyYnWv8QuZnjUEJ0JmRqXOfnXw5RKF9rncOAb3LDCk8pTI2WTiEZX2UBdHzaDguhdnBDlhvem1sW2C9YscccgReh16ZLbPKitP1QdSf267l.9RpFTGKEff+pS8XU.YNPQZTOMMJAvrs2tdttLAmIndCSEDMSJ7jhNoZsTDXBoRx8ISh25vakmRWy8mtNrg9unPxwQQ0oJwttNtNbIAy8TXQH7BNBqGsg4+Pl3Grd469kdA.gblRuMRn5yLQy238rlHivhKog9f1agzu9DsfxqtlIREDuKlyu.ZL8uaFs1tUR1ikZ5IB+rjx8VWu6ZZ3vZsUDJNUUqYy.i5g.5C0hKnppkTiiPWzrslK73ZMI4UkJNJE8DL8IwzB4xYqfZZjQEkUnktQACAW0YMzKUzPmWDQLHHN1EUTTF8qtHAcW3KW.exIZV.Vzd5A7jPXa0z.+q81GqwlQqBJAzLlpzLS0vZe50vdp7AMG68oIWokwYbtnU.hyif02Tx3uu23pBrjijQPbvJPsUCTk.uviLeJC9dwyF7H7Ml7zHyLyAFJE3to6VtaCaa+qMIvNLYXJGqmcwlYadgAnkZl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