[Stk] .tick() and callback function

Emile Vrijdags emile.vrijdags at gmail.com
Fri Jan 16 07:47:24 PST 2009


I'm not an expert here, but I think I might have something useful to say 
about your problem.
My guess is you specify how the input can be read while initializing 
your rtaudio object with a call to openstream

http://ccrma.stanford.edu/software/stk/classRtAudio.html#a7

One of its parameters specify how many channels are read and which one 
is the starting channel.
I only use the outputbuffer in my project with 2 channels. With me these 
two channels are interleaved, which means that 1 sample of the channel 1 
is put on the stream then 1 sample of the next channel ... until all 
channels are used, and then you go and put sample nr2 of channel 1 on 
the stream and so on. So I guess this works the same for input.
The input can be read pointerlike in the callbackfunction: (as 
explanatory pseudo-code-like  illustration, not compiled, could contain 
errors, it resembles working output code I have written)

Stkfloat* inputsamples = (StkFloat *) inputBuffer

Stkfloat sampleChan1, sampleChan2;
StkFrames frames(buffersize,2,true); //buffersize from the 
callbackfunction parameters

for(unsigned int i=0; i < buffersize; ++i)
{
    ...
    sampleChan1 = *inputsamples;
    ++inputsamples;
    sampleChan2 = *inputsamples;
    ++inputsamples;
    frames[2*i] = SampleChan1;
    frames[2*i+1] = SampleChan2;
    //of course this can be written much shorter
}

filewvout.tick(frames); //magically a filewvout object appears here :)



Hope this explanes some things (without to many errors) and gets you on 
your way, awaiting a more educated answer

Emile Vrijdags



Beinan Li schreef, op 16/01/2009 1:57:
> Hi,
>
> Might be an obvious one but I'm confused..
> I'm trying to monitor mic input and save everything to a wave file 
> before an interrupting signal
> like CTRL-C. So what I do is to use the call-back function and try to 
> use a FileWvOut object.tick()
> to take the void* inputBuffer, which is first interpreted as a 
> StkFloat. But I notice that .tick() takes
> StkFrame as input parameter.
>
> So my questions are:
>
>    1. How to "tick" the data (inputBuffer) in this case?
>    2. What if my input is multichannel in this case?
>
> Thanks!
>
> Beinan
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Stk mailing list
> Stk at ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/stk
>   



More information about the Stk mailing list