[PD] Array indexing for the wind and the birds

Frank Barknecht fbar at footils.org
Tue Oct 23 09:58:13 CEST 2007

Jeff Rose hat gesagt: // Jeff Rose wrote:

> So I was playing with the FFT example that lets you adjust the gain
> for frequency bands that gets applied to a plain noise signal.  In
> messing around I found that I could actually make some cool sounds
> that seemed like rushes of wind and birds and animals chirping.  So,
> that's the goal.  I want to make a birds and wind patch based on the
> resynthesis.pd audio example.  I thought for starters I would use some
> [metro]s connected to [random]s that would send numbers down to [line]
> objects, which would generate lines to write into my gain array.  Does
> this sound like a reasonable strategy?

Generally a lot of things are resonable strategies. ;) I'm not sure
that I've understood what you want to do, though. 
At http://footils.org/cms/show/60 there is a spectral delay patch,
that maybe can be useful to look at, as it also uses a
changing array to control gain (and feedback and delay) of FFTs. It
also includes a way to control the array(s) algorithmically.

> My real question is how to work with arrays in this manner.  I'd like
> to use [line] objects to generate small sequences that I write into
> short segments of an array.  With a for loop this would be straight
> forward, but I don't know how to iterate through an array, or how to
> generate the line instantaneously rather than having it take some
> amount of time like you normally would use line for an envelope or
> something.

First you start with a counter [f ]x[+ 1] that you reset to 0 on every
go and then bang from an [until], which gets started by a number
instead of a bang. [until] then will bang that many times and thus
make the counter count from 0 to arraysize.

With that counter you drive two things: a) an expr-object which holds
the function that you want to write to the array, like [expr 0.5
* $f1 - 0.2] or so. Normalize the counter as needed and change
parameters of expr as well. Then b) you use the counter value as index
into the array (second inlet of [tabwrite]). Use proper triggering
with [t a a] to first set the index, then calculate the expr.

This general technique can be varied with random objects and what not.
Maybe writing noise with random is a good way to get familiar with it.
It also is used in the examples a lot, e.g. to write hann-curves or
bell-curves in the paf examples (F12, F13).

> In the long run I'll need to remember the start index and length of
> each "chirp" so that after a short delay I can turn the gain back down
> at that location.  Anything like a priority queue in PD, so I can just
> have my delay's pop off the queue?  

Take a look at qlist, textfile, pipe or list-fifo, list-lifo from the
[list]-abs abstractions collection. 

> Also, how tough is it to dynamically create objects from within
> patches?  Say, if I make a self contained chirp patch that deals
> with it's own cleanup, can I sort of instantiate it with some
> parameters and then send it off to do it's thing and die when it's
> done?  (Was just reading the papers on Chuck, so maybe my mind is
> thinking in the wrong way for PD...)

This is not the ideal way of thinking in Pd/Max. For polyphony in Pd
instead you should create all needed objects in advance and possibly
switch~ them off when they are not needed to save CPU. Dynamically
creating objects should only be done on startup of a patch, not while
it's running.

 Frank Barknecht                                     _ ______footils.org__

More information about the Pd-list mailing list