[Stk] Multichannel audio, RtAudio, and RtWvOut

David Michael david@wildlifeanalysis.org
Thu, 2 Aug 2007 17:01:26 +0000


Thanks Gary

I answered many of my own questions regarding this last night during a little study. Most of my confusion resulted from not understanding some of the details of RtAudio and C++ in general. I have written them down and will post back for those who may have similar confusions. 

Should I also be using StkFrames for handling multichannel data? I assume yes, but the tutorials only show this in context of RtWvOut. 

Thanks
David 

-----Original Message-----
From: Gary Scavone <gary@ccrma.stanford.edu>

Date: Thu, 2 Aug 2007 12:51:54 
To:David Michael <david@wildlifeanalysis.org>
Cc:stk@ccrma.stanford.edu
Subject: Re: [Stk] Multichannel audio, RtAudio, and RtWvOut


Hi David,

You should being using RtAudio for this.  I suggest you look at:

   http://www.music.mcgill.ca/~gary/rtaudio/

for the tutorial.

Regards,

--gary

On 1-Aug-07, at 7:23 PM, David Michael wrote:

> Hello
>
> I have some questions regarding the use of STK for the playback of
> multiple audio channels in realtime. Specifically I am trying to
> code up a panner to handle any number of output channels (similar
> to the NPAN in RTcmix as far as I can tell).
>
> 1) Is there a preferred realtime interface (RtAudio or RtWvOut) for
> realtime multichannel audio data?
>
> 2) Is getting RtAudio to handle multiple channels in the callback
> function just a matter of writing another sample to the buffer
> pointer like so?:
>
> register StkFloat *samples = (StkFloat *) buffer;
>
> for ( int i=0; i<bufferSize; i++ ) {
>     StkFloat xxx = data->instrument->tick();
>     *samples++ = xxx; // channel 1
>     *samples++ = xxx; // channel 2
> }
>
> So for 3 channels it would look like this?:
>
> or ( int i=0; i<bufferSize; i++ ) {
>     StkFloat xxx = data->instrument->tick();
>     *samples++ = xxx; // channel 1
>     *samples++ = xxx; // channel 2
>     *samples++ = xxx; // channel 3
> }
>
> If someone would like to help clarify this aspect of RtAudio, it
> would be much appreciated. If it is only a matter of adding another
> buffer sample to the pointer var, then I see how I could have the
> tick() return an array or vector. Should I be using RtWvOut instead??
>
> 3) I have searched this one out, but are there any tutorials
> anywhere that specifically address the use on STK with multiple
> realtime channels, or alternatively does someone on list have some
> simple example code that they could share?
>
> Thanks in advance for your help
> Best
> David
>
> _______________________________________________
> Stk mailing list
> Stk@ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/stk