Sample playback with stored sample start offsets
-
I've hit a bit of a dead end. I'm trying to hack together a sample playback mode that uses a momentary switch to decide whether to 'continue' a sample from the previous last played position or not.
The idea is to have a sustain pedal that enables this mode. When the pedal is released, all of the offsets return to zero, but in the mean time each offset should increase by the number of samples that a note is held for.
I've tried writing a custom script voice start modulator but I'm getting crashes trying to start timer objects inside of the onVoiceStart callback (tried in stable and a recent build).
Any thoughts on the best way to approach this? Thanks in advance!
-
Maybe
Synth.playNoteWithStartOffset(int channel, int number, int velocity, int offset);
will provide a solution instead of using modulators. -
@d-healey Interesting, thanks!! That does look very useful for actually setting the offset onto the intended target.
However, my current issues start with the simple gathering of the information required to store the offset somewhere to be used later. So far I've tried using timer callbacks to increment values per note (startTimer in onVoiceStart, stopTimer in onVoiceEnd). I tried stashing the value inside of
this.data.offset
inside the timer callback as well trying a parent scoped array (egvar posValues = []
).At first I thought the
Message.getTimestamp()
function might be useful but that consistently returns 0. I assume that's because I'm not in a host, but if that's the case I don't to base this off the timeline anyway.EDIT: Running through Xcode I noticed that the timer related crashes are due to thread safety issues while modifying the array. I suspected that this might be the case, but I'm still stumped on how to get this value of "samples played between note on and note off".
-
@Christoph-Hart I'm thinking that one of the best methods for approaching this feature would be to add it as a distinct playback option for the Sampler.
But before I start coding, I wanted to ask whether you would be open to this as an eventual pull request?