Jim's
Tutorials

Spring 2017
course
navigation

feb 1

sound design - feb 1

an example of a sub patch and triggering

Jim coded a subpatch example .
This illustrates a few ideas.
First, the subpatch_example.pd file "calls" the patches (i.e. functions) in the other files. The "inlet" boxes are the arguments passed into the patch, the "outlet" boxes are the return values.
In python one of these might look something like
# --- sumdiff.py -- def sumdiff(a, b): return (a+b, a-b) # -- sumdiff_example.py -- from sumdiff import sumdiff (out1, out2) = sumdiff(20, 13) print out1, out2
The second idea that this example illustrates is "triggering".
Pd is an event-driven language, which means that it operates in terms of something happening ("being activated") when it receives a certain signal ("input").
Conceptually this means that a function like f(a,b) might have the issue that 'a' and 'b' might be seen as two different signals, and therefore might run f twice by when it should run once.
To address this concern, the normal Pd convention is that only changes to the top left input are treated as a "do this now" or "triggering" signal. And there are boxes in the language that will pack up multiple values and feed them to another box in a "right to left" order, so that the last one triggers it and runs the function. Their docs calls this "hot" and "cold" inputs.
In the first subdiff example, the [+] and [-] boxes within sumdiff act this way. Changing the right input to the patch doesn't change the output, until the left input is changed - then the numbers are updated correctly. Each tiny movement of the mouse or "return" that you type is another "trigger". The numbers in the picture look wrong because I changed the top right when all started as zero. The bottom ones didn't change.
If however you would like to have something where the user can manipulate either of several inputs, you can explicitly issue a "bang" (i.e. a trigger) to the left input. This means that the left left side of the [+] gets both a number (which is what it add) and possibly a "bang" which says "do this now". The [trigger bang float] box (which is just [t b f] in some of the patches I've seen) sends two outputs, a bang and a float, given one input (the float). In the subdiff2 one, changing either of the top inputs does the right thing.
Tricky ...

Lysha's Week:

Jim responds

For where Pd looks for files, see https://puredata.info/docs/manuals/pd/x3.htm#s5 . You can set its default path (a list of folders where it looks for files including external patches and audio) with the Pd >> Preferences >> Path ... menu.
Looks like explicit file names are either (a) relative to the .pd script's folder (i.e. foo.aiff is in the same folder, ../foo.aiff is up one folder, ./audio/foo.aiff is in the audio folder below this one) or (b) absolute paths that start with (i.e. /Users/mahoney/Desktop/foo.aiff). These names go within a message box, without quotes.
Here's an example I put together from the help entry for [readsf~] , with playsound.pd and lynn_will.aiff in the same folder (my Desktop).
You can add extensions to Pd by downloading them with the Help >> Find Externals menu. Some of these as listed in http://blazicek.net/list_of_pure_data_objects.html in the "Extended objects" category can do things like read all the files in a folder, things like [getdir] and [folder_list] . I expect this would for example let you read all the audio files in a given folder without naming them ahead of time.

installing extensions

For linux, see http://puredata.info/docs/faq/faqsection_view?section=Installing
$ apt-get install puredata $ apt-get install pd-*
including pd-extended

nick's notes for next time

http://cs.marlboro.edu/ courses/ spring2017/jims_tutorials/ pd/ feb_1
last modified Wednesday February 1 2017 11:29 am EST

attachments [paper clip]

     name last modified size
   lynn_will.aiff Feb 1 2017 12:32 am 1.35MB    playsound.pd Feb 1 2017 12:31 am 856B [IMG]playsound.png Feb 1 2017 12:42 am 83.3kB