Sample stops playing when key is released
-
I would like to alter this code so that the entire sample gets played once a key is pressed, regardless if the user releases the key before the sample is done playing.
const var ids = Engine.createMidiList(); inline function onButton1Control(component, value) { local noteNumber = 36; if (value) { //Turn off old note if (ids.getValue(noteNumber) != -1) Synth.noteOffByEventId(ids.getValue(noteNumber)); //Play new note ids.setValue(noteNumber, Synth.playNote(noteNumber, 36)); } }; Content.getComponent("Button1").setControlCallback(onButton1Control);
-
@pcs800 If you enable one-shot mode in the sampler's playback settings it will do this without any scripting.
-
David is of course right, but if you do want to script this, perhaps to be able to let the user switch between one shot and normal you can easily use this
Sampler1AsChild.setAttribute(Sampler1AsChild.OneShot, true);
just make sure to use the as child refence
-
@rglides and false if you want Normal mode