File: 10.subpatch.pd

package info (click to toggle)
pd 0.32p1-5
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,704 kB
  • ctags: 5,418
  • sloc: ansic: 38,382; tcl: 1,036; makefile: 612; sh: 265
file content (45 lines) | stat: -rw-r--r-- 3,097 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#N canvas 84 47 512 612 12;
#X msg 30 316 bang;
#X floatatom 356 339;
#X text 40 23 You can nest entire windows inside Pd boxes (and so on \, as deep as you wish.) There are two different ways to do it. First \, if you just want to add a room to the house \, so to speak \, type;
#N canvas 344 151 329 103 sample-subpatch 0;
#X text 39 43 this is a subpatch of the main patch.;
#X restore 29 85 pd sample-subpatch;
#X text 160 85 <-- you can give the window a name as an argument;
#N canvas 0 0 654 340 eager-adder 0;
#X obj 62 73 inlet;
#X obj 118 73 inlet;
#X obj 62 188 outlet;
#X obj 118 101 t b f;
#X obj 62 156 +;
#X text 197 23 this is a sample subpatch which maintains the sum of two inputs \, doing the computation when either input changes. IF it's the left input \, the "+" object takes care if it \; if the right \, the "trigger" object first gives the "+" the new value \, then "bangs" the right inlet to make "+" do the computation.;
#X text 55 232 Aside: this shows why \, in Pd and Max \, objects such as "+" only trigger on their left inlets: it's easy to build up from there \, but if more than one inlet were "hot" \, you wouldn't be able to change both of them without firing the calculation twice.;
#X text 197 112 Because of the two inlets and the one outlet \, the containing box (int eh parent patch) has two inlets and one outlet. They respect the left-to-right order of the inlet and outlet objects in the subpatch.;
#X connect 0 0 4 0;
#X connect 1 0 3 0;
#X connect 3 0 4 0;
#X connect 3 1 4 1;
#X connect 4 0 2 0;
#X restore 135 185 pd eager-adder;
#X floatatom 135 158;
#X floatatom 228 158;
#X floatatom 135 213;
#X text 28 231 There is also a facility for making many copies of a patch which track any changes you make in the original. The subpatches are called abstractions. For example \, here's a simple abstraction that sends a number to a "receive" on command:;
#X obj 30 340 sendnumber 45 cookies;
#X msg 187 313 bang;
#X obj 187 340 sendnumber 67 pretzels;
#X floatatom 426 340;
#X text 26 533 note that "$1" \, etc \, has a different meaning in object boxes (open one of the "sendnumber" abstractions for comments.);
#X text 29 372 There is a separate file in this directory named "sendnumber.pd" which is loaded every time you type "sendnumber" in a box. You can make changes in the subpatch and save them. The changes will be saved back to sendnumber.pd and not as part of this (containing) patch.;
#X text 28 452 If you change one copy of an abstraction the change isn't automatically made on any other copies. You must keep track \, save the changes \, and cause Pd to reload the other copies (for example \, by closing and reopening the containing patch.);
#X text 309 584 updated for Pd version 0.26;
#X obj 356 312 r cookies;
#X obj 426 313 r pretzels;
#X text 34 109 If you click on the box (in run mode) the subwindow appears. Click on the one below to see how you give a subpatch inlets and outlets.;
#X connect 0 0 10 0;
#X connect 5 0 8 0;
#X connect 6 0 5 0;
#X connect 7 0 5 1;
#X connect 11 0 12 0;
#X connect 18 0 1 0;
#X connect 19 0 13 0;