Help with loading 4x file_players from Ui button/Knob
-
@Rognvald the same idea as here should work I think
Fill all audio loop players?
Hi all, does anyone know of a way to drag and drop a sound onto a panel, but it imports the sample into x4 audio loop players? I'm looking for a way to do th...
Forum (forum.hise.audio)
-
@d-healey This is great for setting one sample to all players.
I am looking for separate controls to swap samples in a folder for each file_player in Scriptnode.
I can only get it functioning with one file_player, as I dont know how to reference the other 3 file_players in the Script FX1..Thanks for your time*
-
const slot = ScriptFX1.getAudioFile(0);
The number you pass in here
0
is for the first slot,1
is for the second, etc. -
@d-healey Ahh ok I was trying this before.. let me give it another go.
I am using the demo snippet code for the buttons to swap samples.
const var ScriptFX1 = Synth.getAudioSampleProcessor("Script FX1"); const slot = ScriptFX1.getAudioFile(0); // Load Audiofiles into pool ---------------------------------------------------------------------------------------------- Engine.loadAudioFilesIntoPool(); //-------------------------------------------------------------------------------------------------------- // const vars---------------------------------------------------------------------------------------------- //const var AudioLoopPlayer1 = Synth.getChildSynth("Audio Loop Player1"); const var Random = Content.getComponent("Random1"); const var KnS1 = Content.getComponent("KnS1"); const var Next = Content.getComponent("Next1"); const var Prev = Content.getComponent("Prev1"); //-------------------------------------------------------------------------------------------------------- // Array Samples in AudioFiles-Folder---------------------------------------------------------------------- const var inst = ["Wi_Kick-1.wav","Wi_Kick-2.wav","Wi_Kick-3.wav","Wi_Kick-4.wav","Wi_Kick-5.wav","Wi_Kick-6.wav"]; //-------------------------------------------------------------------------------------------------------- //Knob1 Sample selection--------------------------------------------------------------------------------- inline function onKnS1Control(component, value) { Synth.getAudioSampleProcessor("Script FX1").setFile("{PROJECT_FOLDER}"+inst[value]); }; Content.getComponent("KnS1").setControlCallback(onKnS1Control); //-------------------------------------------------------------------------------------------------------- // Random Button------------------------------------------------------------------------------------------ Random.setControlCallback(onRandom_Control); inline function onRandom_Control(component, value) { if (value) { KnS1.setValue((Math.randInt(0, 5))); KnS1.changed(); } }; //-------------------------------------------------------------------------------------------------------- // Prev-Button---------------------------------------------------------------------------------------------- inline function onPrevControl(component, value) { if (value) { KnS1.getValue() > KnS1.get("min") ? KnS1.setValue(KnS1.getValue() - 1) : KnS1.setValue(KnS1.get("max")); KnS1.changed(); } }; Content.getComponent("Prev1").setControlCallback(onPrevControl); //-------------------------------------------------------------------------------------------------------- // Next-Button ---------------------------------------------------------------------------------------------- inline function onNextControl(component, value) { if (value) { KnS1.getValue() < KnS1.get("max") ? KnS1.setValue(KnS1.getValue() + 1) : KnS1.setValue(KnS1.get("min")); KnS1.changed(); } }; Content.getComponent("Next1").setControlCallback(onNextControl); //--------------------------------------------------------------------------------------------------------
-
@Rognvald said in Help with loading 4x file_players from Ui button/Knob:
const slot = ScriptFX1.getAudioFile(0);
You need 4 of these, one for each of your node external audio files.
-
@d-healey Ok I get that part, but how to set different files for each 4 knobs through Script FX1 is where I am confused.
//Knob1 Sample selection--------------------------------------------------------------------------------- inline function onKnS1Control(component, value) { Synth.getAudioSampleProcessor("Script FX1").setFile("{PROJECT_FOLDER}"+inst[value]); }; Content.getComponent("KnS1").setControlCallback(onKnS1Control);
-
Each slot is separate.
const var ScriptFX1 = Synth.getAudioSampleProcessor("Script FX1"); const slots = []; for (i = 0; i < 4; i++) { slots[i] = ScriptFX1.getAudioFile(i); }
-
@d-healey Thats the one, is it similar for the sample array?
// Array Samples in AudioFiles-Folder---------------------------------------------------------------------- const var inst = ["Wi_Kick-1.wav","Wi_Kick-2.wav","Wi_Kick-3.wav","Wi_Kick-4.wav","Wi_Kick-5.wav","Wi_Kick-6.wav"];
-
@Rognvald I'm not familiar with that project
-
@d-healey its the interface I am trying to link to scriptFX.
Can I reference the separate slots in the knob function?inline function onKnS1Control(component, value) { Synth.getAudioSampleProcessor("Script FX1").setFile("{PROJECT_FOLDER}"+inst[value]); }; Content.getComponent("KnS1").setControlCallback(onKnS1Control);
-
@Rognvald said in Help with loading 4x file_players from Ui button/Knob:
Can I reference the separate slots in the knob function?
You create the references in
on init
using the code I posted above.You can use these within the callback.
slot[0].setFile()...
slot[1].setFile()...
etc.
-
@d-healey said in Help with loading 4x file_players from Ui button/Knob:
slot[0].
I added the references and added slot function here* and getting error "Unknown function 'setFile'
inline function onKnS1Control(component, value) { Synth.getAudioSampleProcessor("Script FX1").slot[0].setFile("{PROJECT_FOLDER}"+inst[value]); }; Content.getComponent("KnS1").setControlCallback(onKnS1Control);
-
@Rognvald You already have the references in
on init
you don't need to get the reference in the control callback - in fact you should never create references in control callbacks.// This goes in on init const var ScriptFX1 = Synth.getAudioSampleProcessor("Script FX1"); const slots = []; for (i = 0; i < 4; i++) { slots[i] = ScriptFX1.getAudioFile(i); }
// This goes in the control callback slot[0].setFile()
-
@d-healey Thanks again, this is where I was going wrong. Learning slowly but surly :)
-
@d-healey Sorry i am still battling with this same error "Unknown function 'setFile'..
//-------------------------------------------------------------------------------------------------------- const var ScriptFX1 = Synth.getAudioSampleProcessor("Script FX1"); const slots = []; for (i = 0; i < 4; i++) { slots[i] = ScriptFX1.getAudioFile(i); } //-------------------------------------------------------------------------------------------------------- // Load Audiofiles into pool ---------------------------------------------------------------------------------------------- Engine.loadAudioFilesIntoPool(); //-------------------------------------------------------------------------------------------------------- // PLAYER-1 const vars---------------------------------------------------------------------------------------------- //const var AudioLoopPlayer1 = Synth.getChildSynth("Audio Loop Player1"); const var Random = Content.getComponent("Random1"); const var KnS1 = Content.getComponent("KnS1"); const var Next = Content.getComponent("Next1"); const var Prev = Content.getComponent("Prev1"); //-------------------------------------------------------------------------------------------------------- // PLAYER 2 const vars---------------------------------------------------------------------------------------------- //const var AudioLoopPlayer1 = Synth.getChildSynth("Audio Loop Player1"); const var Random2 = Content.getComponent("Random2"); const var KnS2 = Content.getComponent("KnS2"); const var Next2 = Content.getComponent("Next2"); const var Prev2 = Content.getComponent("Prev2"); //-------------------------------------------------------------------------------------------------------- // PLAYER 1 Array Samples in AudioFiles-Folder---------------------------------------------------------------------- const var inst = ["Wi_trap808-1.wav","Wi_trap808-2.wav","Wi_trap808-3.wav","Wi_trap808-4.wav","Wi_trap808-5.wav","Wi_trap808-6.wav"]; //-------------------------------------------------------------------------------------------------------- // PLAYER 2 Array Samples in AudioFiles-Folder---------------------------------------------------------------------- const var inst2 = ["Wi_Kick-1.wav","Wi_Kick-2.wav","Wi_Kick-3.wav","Wi_Kick-4.wav","Wi_Kick-5.wav","Wi_Kick-6.wav"]; //-------------------------------------------------------------------------------------------------------- //PLAYER 1 Knob1 Sample selection--------------------------------------------------------------------------------- inline function onKnS1Control(component, value) { slot[0].setFile("{PROJECT_FOLDER}"+inst[value]); }; Content.getComponent("KnS1").setControlCallback(onKnS1Control); //-------------------------------------------------------------------------------------------------------- //PLAYER 2 Knob1 Sample selection--------------------------------------------------------------------------------- inline function onKnS2Control(component, value) { slot[1].setFile("{PROJECT_FOLDER}"+inst[value]); }; Content.getComponent("KnS2").setControlCallback(onKnS2Control); //--------------------------------------------------------------------------------------------------------
-
@Rognvald Have you created external audio slots for your script effect node?
-
-
Shouldn't ScriptFX1 module be a part of your button script? I think you're writing to slot[i] but thats not a module. It looks like you're assigning to a slot....but it doesn't know what that slot is for.
-
@Rognvald send me a snippet, I'll take a look in the morning. It's some issue with the references
-
@d-healey The buttons are linked to the knobs which should change the files in the slot. I thought..
Thanks I will create a snippet :)