Audio Loop Player Script
-
Hi all you helping people out there.
I've just started my second project in Hise and beeing more complex than the first, the first issue already appered.I would like to have a Loop of static noise, well ... looping for lack of a different word,.
Activated with a button and NOT via midi.Any ideas and tipps, how I could script that?
Thanks in advance! -
-
Hmm...
I set up a Switch/Button to change a few things as well as play a note, but the note is only getting played, when compiling. Everything else seems to get correctly triggered after the callback.inline function onSwitchControl(component, value) { if(value) { Keys.set("visible", 1); NoiseSlide.set("visible", 1); KeyON.setBypassed("false"); KeyOFF.setBypassed("false"); Synth.playNote(6, 100); } else { Keys.set("visible", 0); NoiseSlide.set("visible", 0); KeyON.setBypassed("true"); KeyOFF.setBypassed("true"); } }; Switch.setControlCallback(onSwitchControl);
...Any ideas, what I'm missing?
-
@VorosMusic You're passing booleans as strings.
inline function onSwitchControl(component, value) { if(value) { KeyON.setBypassed(false); //No quotation marks KeyOFF.setBypassed(false); Synth.playNote(6, 100); } else { KeyON.setBypassed(true); KeyOFF.setBypassed(true); } //you can also move these out here: Keys.set("visible", value); NoiseSlide.set("visible", value); };
Or if you want to be even more efficient:
//Since you're using a switch, you can treat *value* like a boolean. /* The 1-value trick inverts the boolean of the switch. Which means when the switch is active (1), setBypassed is false (0) & vice-versa. */ inline function onSwitchControl(component, value) { KeyON.setBypassed(1-value); KeyOFF.setBypassed(1-value); Keys.set("visible", value); NoiseSlide.set("visible", value); if (value) Synth.playNote(6, 100); };
-
@iamlamprey Oh cool.
I didn't know I could treat the switch value as a boolean.
Thanks for the trick.And I try if rewriting that fixes my issue!
-
@iamlamprey
The code is a lot cleaner now, but still the same problem.On its own:
- playing the note works
- switching visibility works
Together, everything works as expected, except the note is not playing...
:face_with_raised_eyebrow: -
@VorosMusic So to clarify:
INSIDE HISE
Everything works properly.IN COMPILED PLUGIN/EXE
Hiding/showing elements works, but no audio from playNote() method?If that's the case, it suggests either the Loop Player can't find the audio file (https://docs.hise.audio/working-with-hise/settings/project.html#embed-audio-files), or the Bypass of the Loop Player is inverted or not working correctly.
-
@iamlamprey Thank you for your help!
I don't know why. I redid some other elements of my code and suddenly it worked.
So yes for now its working properly in Hise itself. -
-