[Portaudio] running a nmber of clocks per sample?

malik martin laserbeak43 at gmail.com
Fri Jan 8 08:48:12 EST 2010


Actually,
I'm wondering, How does this paTestCallback() example work? It
probably comes down to the simple characteristics of a for-loop, but
after 'i' matches the value of framesperbuffer and, in the case of the
example, 0 is returned, what happens? is paTestCallback() called
again, with all of the function variables reinitialized?  if so, when?
immediately after what? I've read the doxygen docs, so sorry if this
might seem obvious, but i'm just not seeing it at the moment.

Thanks.
Malik
( http://www.freewebs.com/laserbeak43 )



On Fri, Jan 8, 2010 at 8:11 AM, malik martin <laserbeak43 at gmail.com> wrote:
> Neat trick! Thanks!
>
> Malik
> ( http://www.freewebs.com/laserbeak43 )
>
>
>
> On Fri, Jan 8, 2010 at 1:44 AM, Ross Bencina <rossb-lists at audiomulch.com> wrote:
>> Robert Bielik wrote:
>>> unsigned cntr;
>>> const unsigned samplesPerIntervalFor5Hz = 44100 / 5.0;
>>> if (++cntr >= samplesPerIntervalFor5Hz) {
>>>   cntr = 0;
>>>   // Do 5 Hz activity here
>>> }
>>
>> or if you want to avoid quantizing your time steps to the sample rate
>> (sometimes important, sometimes not):
>>
>> double unsigned cntr = 0.; // don't forget to initialize!
>> const double samplesPerIntervalFor5Hz = 44100 / 5.0;
>> cntr += 1.;
>> if (cntr >= samplesPerIntervalFor5Hz) {
>>   cntr -= samplesPerIntervalFor5Hz;
>>   // Do 5 Hz activity here
>> }
>>
>>
>> Ross.
>>
>> _______________________________________________
>> Portaudio mailing list
>> Portaudio at music.columbia.edu
>> http://music.columbia.edu/mailman/listinfo/portaudio
>>
>


More information about the Portaudio mailing list