[Stk] Save instrument state

Joseph Cooper josephcooper at gmail.com
Mon Feb 21 20:43:39 PST 2011


I would like to use STK together with OpenAL for real-time 3D
synthesis.  With OpenAL, you fill Buffers with audio data and then
assign those Buffers to Sources that can be assigned a 3D location.
You can then move the Sources or the Listener around and it handles
panning and distance attenuation (as well as doppler effect and a
number of other effects if you want).
Anyway, the problem is that it would seem I need to make these buffers
relatively large to avoid starvation.  The end effect of this is that,
when an instrument is triggered, it begins immediately, but when the
instrument changes (note-off, or other change) there is a
variable-length short-but-noticeable delay (depending on where exactly
the buffer was being read when the event happened).  OpenAL-soft
recently implemented a function that lets you write into a buffer that
is in the middle of being processed (with pointers telling you where
it's currently being read and where it's safe to write).  So.... if I
have tick'ed an instrument into the future but then want to rewind
because some of the data I generated have been invalidated because of
an event, would that be possible?  Are there any thoughts on what it
would take to implement "save points" for some instruments so that you
could roll-back to an earlier state and then process forward with the
necessary changes?  Does someone have a more elegant approach to
solving the problem?
On a related note, is there a clean way to tell if an instrument is
completely done generating sound so that its resources can be
recovered?  E.g., has the ADSR envelope finished its final phase, or
has the shaker simulated its final shake?

Thanks,
jc



More information about the Stk mailing list