Hi,
I want to ask a general question in relation scheduling in pd. I've tried looking at the docs and source code, but I'm still confused.
From the docs, audio is computed every 64 samples, so
with a sample rate of 44100 this means that 64 samples of output must be computed every 1.45 ms.
So my question is, if I have a clock object that calls a function say every 20ms, and this function takes 10ms to complete, how is audio interleaved with the execution of this function? Another way of phrasing this would be: are functions that are called by clocks executed atomically? Doesn't seem that they can be, unless they execute in less than 1.45 ms.
any thoughts/explanations are appreciated (i've a feeling they might radically change my understanding of how pd works!!)
Brian
__________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
On Wed, 20 Aug 2003, Brian Sheehan wrote:
Hi,
I want to ask a general question in relation scheduling in pd. I've tried looking at the docs and source code, but I'm still confused.
From the docs, audio is computed every 64 samples, so
with a sample rate of 44100 this means that 64 samples of output must be computed every 1.45 ms.
So my question is, if I have a clock object that calls a function say every 20ms, and this function takes 10ms to complete, how is audio interleaved with the execution of this function? Another way of phrasing this would be: are functions that are called by clocks executed atomically? Doesn't seem that they can be, unless they execute in less than 1.45 ms.
any thoughts/explanations are appreciated (i've a feeling they might radically change my understanding of how pd works!!)
Well, yes. you better write functions that take less that 1.45 ms to finish, .. .much less. PD is not multithreaded or asynchron, thats what makes messages deterministic wrt to the audio processing.
Guenter
Brian
Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
PD-dev mailing list PD-dev@iem.at http://iem.at/cgi-bin/mailman/listinfo/pd-dev
Hi guenter, thanks for your reply.
Ok, that's what I had figured from the documentation.
Which is why I'm confused - I have a function that is called by a clock every 20ms, and it takes 8-9 ms to execute. Audio seems to be produced fine, and the function seems to do its job. I only get problems if I try to decrease the interval between calls to the function to less than the execution time of the function (which makes sense).
This seems inconsistent with my understanding of scheduling... unless i've made a mistake timing the function - i've been using gettimeofday() (under Mac OS X).
thanks again,
Brian --- guenter geiger geiger@xdv.org wrote:
On Wed, 20 Aug 2003, Brian Sheehan wrote:
Hi,
I want to ask a general question in relation scheduling in pd. I've tried looking at the docs
and
source code, but I'm still confused.
From the docs, audio is computed every 64
samples, so
with a sample rate of 44100 this means that 64
samples
of output must be computed every 1.45 ms.
So my question is, if I have a clock object that
calls
a function say every 20ms, and this function takes 10ms to complete, how is audio interleaved with
the
execution of this function? Another way of
phrasing
this would be: are functions that are called by
clocks
executed atomically? Doesn't seem that they can
be,
unless they execute in less than 1.45 ms.
any thoughts/explanations are appreciated (i've a feeling they might radically change my
understanding
of how pd works!!)
Well, yes. you better write functions that take less that 1.45 ms to finish, .. .much less. PD is not multithreaded or asynchron, thats what makes messages deterministic wrt to the audio processing.
Guenter
Brian
Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site
design software
PD-dev mailing list PD-dev@iem.at http://iem.at/cgi-bin/mailman/listinfo/pd-dev
PD-dev mailing list PD-dev@iem.at http://iem.at/cgi-bin/mailman/listinfo/pd-dev
__________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
hi,
Well, yes. you better write functions that take less that 1.45 ms to finish, .. .much less. PD is not multithreaded or asynchron, thats what makes messages deterministic wrt to the audio processing.
hum, that's right but looks like there's no way of achieving some longer operations, in fact, if you know some operations will take time, you just have to thread them, check out cooled~ for an example of this.
cheers, sevy
Guenter
Hi yves,
Where can I find cooled~?
thanks,
Brian --- Yves Degoyon ydegoyon@free.fr wrote:
hi,
Well, yes. you better write functions that take
less that
1.45 ms to finish, .. .much less. PD is not
multithreaded or
asynchron, thats what makes messages deterministic
wrt to the
audio processing.
hum, that's right but looks like there's no way of achieving some longer operations, in fact, if you know some operations will take time, you just have to thread them, check out cooled~ for an example of this.
cheers, sevy
Guenter
__________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
hi,
in CVS now !!
or, on the originating site : http://ydegoyon.free.fr
cheers, sevy
Brian Sheehan wrote:
Hi yves,
Where can I find cooled~?
thanks,
Brian --- Yves Degoyon ydegoyon@free.fr wrote:
hi,
Well, yes. you better write functions that take
less that
1.45 ms to finish, .. .much less. PD is not
multithreaded or
asynchron, thats what makes messages deterministic
wrt to the
audio processing.
hum, that's right but looks like there's no way of achieving some longer operations, in fact, if you know some operations will take time, you just have to thread them, check out cooled~ for an example of this.
cheers, sevy
Guenter
Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
On Thu, 21 Aug 2003, Yves Degoyon wrote:
hi,
Well, yes. you better write functions that take less that 1.45 ms to finish, .. .much less. PD is not multithreaded or asynchron, thats what makes messages deterministic wrt to the audio processing.
hum, that's right but looks like there's no way of achieving some longer operations, in fact, if you know some operations will take time, you just have to thread them,
right, threading makes this possible but is very dangerous when used the wrong way, because it will destroy the determinism of pd programming.
To decide this we would have to know what takes so long to compute...
Guenter
check out cooled~ for an example of this.
cheers, sevy
Guenter
Actually, you can write control functions that take any "reasonable" amount of time to execute... they just can't exceed the audio FIFO size, and as noted earlier, can't be called so often that Pd can't catch up between calls.
Something about this (in a more general context) is in my "FTS" article on http://www.crca.ucsd.edu/~msp/publications.html (number 17).
cheers Miller
On Thu, Aug 21, 2003 at 02:13:07PM -0400, Yves Degoyon wrote:
hi,
Well, yes. you better write functions that take less that 1.45 ms to finish, .. .much less. PD is not multithreaded or asynchron, thats what makes messages deterministic wrt to the audio processing.
hum, that's right but looks like there's no way of achieving some longer operations, in fact, if you know some operations will take time, you just have to thread them, check out cooled~ for an example of this.
cheers, sevy
Guenter
PD-dev mailing list PD-dev@iem.at http://iem.at/cgi-bin/mailman/listinfo/pd-dev