[Stk] Polyphony and Stereo Panning with CrtSine
Stephen Sinclair
sinclair at music.mcgill.ca
Thu Sep 20 08:08:24 PDT 2012
> What is the best way to generate multiple tones and implement this
> simultaneously with a callback function
Two options are important here. When you open a real-time output
stream using RtAudio::openStream, you can provide StreamParameters
and StreamOptions. nChannels is specified in StreamParameters, and
should be set to 2.
Then, StreamOptions::flags can have the option RTAUDIO_NONINTERLEAVED.
By default it is not set, so the data provided to the callback is
interleaved. Therefore you can do hard panning of your two sines by:
for ( unsigned int i=0; i<nBufferFrames; i++ ) {
*outputSamples++ = data->sine->tick();
*outputSamples++ = data->sineTwo->tick();
}
Otherwise if you select the non-interleaved format, then hard panning
should be accomplished by:
for ( unsigned int i=0; i<nBufferFrames; i++ ) {
outputSamples[i] = data->sine->tick();
outputSamples[i + nBufferFrames] = data->sineTwo->tick();
}
Steve
On Wed, Sep 19, 2012 at 5:44 PM, Adams, Alexander <aadams85 at uncc.edu> wrote:
> I need to generate two Sinewaves and assign outputs to them either by hard
> panning left and right or with selected outputs. i am able generate one
> sine wave and pane it either way by doing
>
> *outputSamples++ = data->sine->tick();
> *outputSamples++ = data->pan;
> or
>
> *outputSamples++ = data->sineTwo->tick();
> *outputSamples++ = data->pan;
>
> What is the best way to generate multiple tones and implement this
> simultaneously with a callback function or should i be using something from
> the instrument class...i am on a bit of a time constraint so help would be
> greatly appreciated.
>
> Thanks
>
> also i am new to Stk so details and/or sample code would be great.....Thanks
>
> _______________________________________________
> Stk mailing list
> Stk at ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/stk
>
More information about the Stk
mailing list