aboutsummaryrefslogtreecommitdiff
path: root/pd/doc/2.control.examples/12.PART2.subpatch.pd
diff options
context:
space:
mode:
Diffstat (limited to 'pd/doc/2.control.examples/12.PART2.subpatch.pd')
-rw-r--r--pd/doc/2.control.examples/12.PART2.subpatch.pd72
1 files changed, 72 insertions, 0 deletions
diff --git a/pd/doc/2.control.examples/12.PART2.subpatch.pd b/pd/doc/2.control.examples/12.PART2.subpatch.pd
new file mode 100644
index 00000000..5bd40306
--- /dev/null
+++ b/pd/doc/2.control.examples/12.PART2.subpatch.pd
@@ -0,0 +1,72 @@
+#N canvas 84 47 648 623 12;
+#X msg 29 318 bang;
+#X floatatom 432 341 0 0 0;
+#X text 32 14 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 422 119 sample-subpatch 1;
+#X text 39 43 this is a subpatch of the main patch.;
+#X restore 29 85 pd sample-subpatch;
+#X text 201 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 0 0 0;
+#X floatatom 256 158 0 0 0;
+#X floatatom 135 213 0 0 0;
+#X text 26 235 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 29 342 sendnumber 45 cookies;
+#X msg 226 314 bang;
+#X obj 226 341 sendnumber 67 pretzels;
+#X floatatom 519 341 0 0 0;
+#X text 27 553 note that "$1" \, etc \, has a different meaning in
+object boxes (open one of the "sendnumber" abstractions for comments.)
+;
+#X text 26 470 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 obj 432 314 r cookies;
+#X obj 519 314 r pretzels;
+#X text 31 107 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 text 332 594 updated for Pd version 0.34;
+#X text 27 372 There is a separate file in this directory named "sendnumber.pd"
+which is loaded every time you type "sendnumber" in a box. Click on
+a "sendnumber" box above to see it. 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 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 16 0 1 0;
+#X connect 17 0 13 0;