[PD] A slightly more substantial question

Frank Barknecht fbar at footils.org
Thu Apr 10 15:28:12 CEST 2008

Ken Restivo hat gesagt: // Ken Restivo wrote:

> I'm trying to create a PD application that'll be sync'ed to jack
> transport as a sort of master clock.
> I found the jack_transport object, loaded it, and it runs. If I bang
> it regularly with a metro, I can see the current sample in jack
> transport. So far so good.
> My question is about what'd be the most efficient/effective way to
> sync up a tabplay~ or tabread4~ object to the sample clock in jack
> transport. So far I've considered the following approaches:
> 1) Bang jack_transport with the output of a sig~ or phasor~ object,
> getting the clock from jack, and use that to hit tabread4~ (I don't
> know how I'd do this with tabplay~ though, and performance is an
> issue so if tabplay~ is cheaper I want to use it).

If you want to play samples with a different samplerate than the one
Pd and jack are using you have to to use tabread4~. tabplay~ doesn't
do any interpolation or transposition. I normally never use tabplay~
except for some quick prototyping.

> 2) Bang jack_transport with the output of a metro every n
> milliseconds, and calculate what sample I'm supposed to be at in the
> tabread4~ or tabplay~ object, and just "re-sync" periodically if
> they drift. If they aren't ever going to drift (i.e. if PD's
> internal sample clock is sync'ed to JACK), then perhaps this
> "resyncing" will only happen at the start of playing, or perhaps I
> only need to do it then.

I've never used jack_transport, but the samplerates of Jack and Pd
should never get out of sync unless something really bad happens
(xruns etc), and then you have other problems. 

However what can get out of sync is the notion of: "What time is it?"
Pd itself doesn't have a timeline built in, so how to deal with a
global clock very much depends on what your patch looks like. 

Example: Jack transport can do a "rewind to the beginning of a piece".
A Pd patch however may not have a beginning, it might just run a
process which gets modified. What should such a patch do with a
"rewind" order?

Assuming you have a Pd patch which has a beginning and which at the
beginning plays a sample of 2 seconds length with tabread4~ and
vline~. Now jack_transport moves the system to a time 1 second after
the start of the piece. Then you either can ignore this and not play
the sample at all, or you restart the sample, but with the vline~ at
the position it would have 1 second after the beginning. This of
course requires a slighty different patching style than if you would
just ignore it - as you'd have to patch your sample player in a way
that it can always start playing samples at every possible time.

 Frank Barknecht                                     _ ______footils.org__

More information about the Pd-list mailing list