[Stk] STK and OpenGL

Stephen Sinclair sinclair at music.mcgill.ca
Fri Nov 7 14:02:20 PST 2008


2008/11/5 Schell <efsubenovex at gmail.com>:
> Hi, I'm learning OpenGL and STK simultaneously and am still very much a noob
> at both, so this may be a silly question, but, how can I enable stk to
> process and send audio while OpenGL is rendering? I've set my first task as
> displaying a waveform created with STK in OpenGL, but in my main function
> focus goes from STK generating audio for a couple seconds, then to Opengl
> rendering a screen. Am I going to have them running in different threads
> (something I know nothing about)?

If you're talking about drawing STK-generated audio to an OpenGL
buffer, you don't need threading.  If you're talking about having an
audio callback playing real-time audio with a separate graphics
process drawing to the screen, then you might need to think about
transmitting information to your audio callback (you have to assume
it's on a separate thread) in a thread-safe manner.  Usually this is
done by using single-read single-writer circular buffers.  There are
lots of example implementations of this online.

If you're experiencing delay because you're rendering too much audio,
the simple answer is to render less audio between redraws of the
screen, I guess, but I don't know exactly what context you're using
this.  It seems like it might not be an STK-specific question though,
if you're just talking about something which takes too much time.

Steve



More information about the Stk mailing list