list
From Pdpedia
| {{{example_image}}} caption | |
| Description: | description is required |
|---|---|
| Abbreviation: | |
| Library: | vanilla |
| Author(s): | Miller S. Puckette and others |
| Developer(s): | |
| Release version: | |
| Release date: | 2007 |
| Status: | active |
| Dependencies: | |
| License: | BSD |
| Website: | http://crca.ucsd.edu/~msp/software.html |
| Programming Language: | |
| Platform(s): | GNU/Linux, Mac OS X, Windows |
| Language: | English |
| Data type(s): | |
| Distribution(s): | DesireData, PDa, Pd-extended, Pd-vanilla, puredata debian package, pure:dyne |
Prepend - prepend the second list to the first
- building and using variable-length messages
length - number of items in list
trim - convert list to message, using first item as selector
example 1: simple rhythmic sequencer
example 3: serializing a message without delays
Split - cut a list into smaller ones
Messages in Pd are simewhat artificially divided into two classes. First are data-holding messages (bang, float, symbol \, list) which are the primary way of communicating between objects. Second is "everything else" (you could call them out-of-band messages or metamessages) that describe changes in configuration, read and write files, quit Pd, etc. These are provided so that complex objects don't need to have 100 separate inlets for every possible functionality. It's not clear whether this was a good design choice, but it's entrenched.
non-list message converted to list
example 2: sequencer with pitch
There are four list classes:
The top part of this patch demonstrates building up a message from a variable number of elements provided sequentially. The "list prepend" object stores the list and, each time a number arrives \, prepends the previous list to it.
The "list length" object outputs the number of arguments in a list or other message.
The "until" object can be used as shown to iterate through all the items of a list.
The "list split" object takes lists and outputs the first "n" items (left outlet) and the remaining ones (middle outlet). The two outputs appear in the usual right-to-left order. In case there are fewer than "n" items in the list, it is output (in its entirety) from the third outlet instead. The creation argument or the inlet sets the split point.
This example is a slight modification of example 1 showing how to build up lists with more than one item per iteration. We regard pairs of numbers as specifying a delay time and a pitch. Unlike the previous example, the delay here is interpreted as teh delay until the next event, not the delay since the previous one. This is done by taking the "pitch" output before the delay object (previously the "output" was taken from the delay object's output.)
list starting with symbol
- append the second list to the first
(needs explicit "list" selector)
- prepend the second list to the first
numeric list
- split a list in two
<- click to test
-- add --
number is one-element list
send
clear
- trim the "list" selector off
First store list, then start the loop
bang is zero-element list
The distinction becomes visible, and ugly, when the leading item in a data-holding message is a symbol. In this case \, to disambiguate it from the other sort, the printed form of the message has a selector, "list" or "symbol" prepended to it. Underneath \, there is always a selector in fromt of data messages, but it is implied if the first data item is a number.
- output number of items in list
"until" bangs its output until told to stop by a "bang" to its right inlet.
non-list message converted to list
- short for "list append"
same for right inlet...
"trigger list" is needed only to connect outlet of
list with three symbols
Store the remaining list.
In general, inlets that take lists (two each for append/prepend \, and one each for split and trim) will convert non-list messages (such as "set 5") to lists (such as "list set 5" automatically. Here's more about lists in Pd:
-- add --
send
clear
printout shows the growing message.
list with no items
(note: only the first item
"list append" stores the growing message which is output by the "send" button above. "list prepend" would have been equivalent.
third outlet of "split" tells us to stop.
need be a number to make this
list with one number
In the example below, the top message sets$1 to "x.wav" and$2 to 44100 in the "read" message. The lower message box outputs the message "read x.wav 44100". The "set" message changes the content of the message box itself (click on the longer message box below to repair the damage.) The "ugly" message, since it is neither "list" nor "set", gets interpreted in an arbitrary (and probably inappropriate!) way.
a list.)
... etc
Second outlet of "split" becomes the new list for "list append" above.
<- creation args initialize the list to append
<- creation args initialize the list to prepend
The bottom part of the patch takes numbers off the beginning of the list, one by one, to use as delays.
And here are some examples showing how to use these objects to compose and/or use variable length messages:
<- if the first item is a number, it's a list.
First outlet is the output.
new split point
<-- test message
simple sequencer
<-- creation arg inits split point
printout shows the sequence as it starts.
another sequencer
good
Split off the first item. If there is none, nothing comes out the first or second outlet, but instead we get a "bang" from the third one.
serializer
bad
first n
rest of list
ugly
The rest of the list is stored for next time.
reset message as it was
After delay, output a bang and recall the rest of the list.
click for
details:
"list prepend" to its own inlet.
these two are equivalent:
updated for Pd version 0.40.
shorter than n
Contents |

