[PD] accuracy of signal/message-objects

Frank Barknecht fbar at footils.org
Tue May 8 01:43:46 CEST 2007

martin.peach at sympatico.ca hat gesagt: // martin.peach at sympatico.ca wrote:

> > Frank Barknecht wrote:
> > I think, it's comport's fault: [metro] generates clock-delayed
> > messages. These are like messages tagged with a time-stamp
> > referring to Pd's internal clock. However an object needs to
> > actually use the time-stamps and "look at the clock" to see what
> > time it is. Objects like [vline~] or [delay] do this, but comport
> > doesn't.

(Actually I may be wrong here: Maybe comport doesn't need to do
anything about this, as it's not a dsp-object. But read on.)

> Well that's interesting! How does one access these timestamps? I
> thought a bang has no associated info.

Well, there are no "real" timestamps attached to a bang-message. But
Pd has a clock running (actually many, sync'd to the main scheduler
clock), and objects that want to know the current time a message
arrives, need to look at the clock. 

vsnapshot~ for example (d_ctl.c) seems to do it like this: In its
dsp-perform routine, which is called every sample block, it stores the
current time with "x->x_time = clock_getlogicaltime();" Then in the
bang-routine, vsnapshot~ uses "int indx =
clock_gettimesince(x->x_time) * x->x_sampspermsec;" to calculate the
correct index into the incoming sample block from the difference
between the time stored previously and the current time. This is what
I meant with "looking at the clock".

Objects like [delay] or [metro] produce these clock-delayed messages.
They register their clocks with Pd's main scheduler using
clock_new(...) and then order the scheduler to generate the
clock-delayed messages like the metro-bangs using clock_delay(). The
actual output of [delay], [metro] etc. then is initiated by the
scheduler which calls the registered clock methods: delay_tick(),

However I must admit, I'm not sure how this relates to comport and if
comport should also register its port-writing-method with a clock and
let the scheduler "tick" the clock and initiate the writing and if
that could get rid of the jitter you mentioned. 

At least "normal" objects like [float] don't do any funky clock-stuff
and still don't disturb the correct timing of clock-delayed messages.

 Frank Barknecht                 _ ______footils.org_ __goto10.org__

More information about the Pd-list mailing list