[PD-dev] a few questions

Frank Barknecht barknech at ph-cip.uni-koeln.de
Wed Sep 4 09:38:35 CEST 2002

Hi Scott,
J. Scott Hildebrand hat gesagt: // J. Scott Hildebrand wrote:

>      i'm just a little confused on a few little Pd things.
> 1. when the control of an external program is finished with the perform
> function, does the control go to the beginning of the perform function, or
> the very beginning of the external code?

Only the perform function gets called automatically while running PD
with DSP on. You also have a constructor, say "myexternal_tilde_new"
that sets up internal data structures and in/outlets, that gets
called on object creation together with the setup function, that
registers the various handler functions (class_add_method, ...) Of
course, the handler functions (or methods) get called, when a
respective event occurs, but otherwise they are ignored. 

So the answer is: 
 control goes to the beginning of the perform function

or more correctly:
 control goes to the beginning of the perform function when the
 perform function gets called again by PD's dsp chain.

> 2. just for some conceptual aid, when the while(n--) loop is executing,
> what "direction" is the data read into the in1[] array? and to correctly
> output the data in order, which is the data that is first to be outputted;
> the beginning or the end of the in1[] array?

The beginning is outputted first normally, that is, if you have a
standard loop like this: 
    while (n--) {  *out++ = *in++; }

While n is counted backwards to zero, out[] (== *out) and in[] (==
*in) are counted from their first elements upwards n times.

The reason for counting n backwards is just shortness, I think. It's
an idiom and you could also use a for-loop counting upwards to n. If
you don't use n inside the loop, both are the same.

 Frank Barknecht                               _ ______footils.org__

More information about the Pd-dev mailing list