aboutsummaryrefslogtreecommitdiff
path: root/doc/tutorials/intro/37.math.pd
blob: 6ccae57e288c46d5478836d5f2f88eff22295058 (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#N canvas 10 40 620 460 10;
#X obj 637 350 +~;
#X obj 641 499 trigger;
#X text 25 8 ARITHMETIC;
#X text 30 29 Pd's arithmetic objects include:;
#X obj 231 30 +;
#X obj 256 30 -;
#X obj 282 30 *;
#X obj 308 30 /;
#X obj 334 30 pow;
#X obj 359 30 max;
#X obj 385 30 min;
#X obj 54 189 +;
#X floatatom 54 118 0 0 0 0 - - -;
#X floatatom 54 210 0 0 0 0 - - -;
#X floatatom 67 141 0 0 0 0 - - -;
#X msg 85 167 bang;
#X text 120 168 Bang outputs sum;
#X text 92 117 Numbers in left inlet add and output sum;
#X text 109 140 Numbers in right inlet only change the inlet's value
;
#X text 29 74 The example below performs basic addition with two numbers:
i.e. a + b = c;
#X text 34 263 The example below incorporates a creation argument:
i.e. a + 42 = b;
#X floatatom 34 295 0 0 0 0 - - -;
#X floatatom 34 338 0 0 0 0 - - -;
#X obj 34 317 + 42;
#N canvas 10 40 620 460 basic_examples 0;
#X obj 44 129 +;
#X obj 113 129 -;
#X obj 179 129 *;
#X obj 244 129 /;
#X obj 316 129 pow;
#X obj 394 129 max;
#X obj 482 129 min;
#X floatatom 44 32 5 0 0 0 - - -;
#X floatatom 44 150 0 0 0 0 - - -;
#X floatatom 113 149 0 0 0 0 - - -;
#X floatatom 179 149 0 0 0 0 - - -;
#X floatatom 244 149 0 0 0 0 - - -;
#X floatatom 316 149 0 0 0 0 - - -;
#X floatatom 394 150 0 0 0 0 - - -;
#X floatatom 482 149 0 0 0 0 - - -;
#X floatatom 495 32 5 0 0 0 - - -;
#X msg 360 32 bang;
#X connect 0 0 8 0;
#X connect 1 0 9 0;
#X connect 2 0 10 0;
#X connect 3 0 11 0;
#X connect 4 0 12 0;
#X connect 5 0 13 0;
#X connect 6 0 14 0;
#X connect 7 0 0 0;
#X connect 7 0 1 0;
#X connect 7 0 2 0;
#X connect 7 0 3 0;
#X connect 7 0 4 0;
#X connect 7 0 5 0;
#X connect 7 0 6 0;
#X connect 15 0 6 1;
#X connect 15 0 5 1;
#X connect 15 0 4 1;
#X connect 15 0 3 1;
#X connect 15 0 2 1;
#X connect 15 0 1 1;
#X connect 15 0 0 1;
#X connect 16 0 0 0;
#X connect 16 0 1 0;
#X connect 16 0 2 0;
#X connect 16 0 3 0;
#X connect 16 0 4 0;
#X connect 16 0 5 0;
#X connect 16 0 6 0;
#X restore 33 521 pd basic_examples;
#X text 32 422 However \, [pow] \, [max] \, and [min] objects may need
some explanation.;
#N canvas 10 40 620 460 understanding_POW 0;
#X text 12 25 [POW];
#X obj 17 66 pow 2;
#X floatatom 17 86 2 0 0 0 - - -;
#X msg 17 46 2;
#X text 61 115 - it is important to note that [pow] only works with
NON-negative mantissas. That is to say that negative floating point
fractions will be ignored.;
#X obj 18 153 pow 2;
#X floatatom 18 173 2 0 0 0 - - -;
#X msg 13 111 -2;
#X msg 24 132 -1.5;
#X text 65 202 - however \, [pow] is capable of computing negative
exponents!;
#X floatatom 19 201 0 0 0 0 - - -;
#X obj 19 221 pow -2;
#X floatatom 19 242 0 0 0 0 - - -;
#X text 57 39 - this object is used to exponentiate a number. The object
returns the value at the left inlet to the power of the right inlet
where the left inlet is the base and the right inlet is the exponent.
For example: 2 to the power of 2 = 4 (i.e. 2 Squared);
#X connect 1 0 2 0;
#X connect 3 0 1 0;
#X connect 5 0 6 0;
#X connect 7 0 5 0;
#X connect 8 0 5 0;
#X connect 10 0 11 0;
#X connect 11 0 12 0;
#X restore 33 456 pd understanding_POW;
#N canvas 10 40 620 460 understanding_MAX_and_MIN 0;
#X text 34 9 [MAX];
#X obj 32 51 max 10;
#X floatatom 32 29 5 0 0 0 - - -;
#X floatatom 32 76 5 0 0 0 - - -;
#X text 87 26 - [max] returns the greater of the two numbers passed
to its inlets. For example \, if the creation argument (or right inlet)
is equal to 10 \, and you send 9 to the left inlet then the object
will return 10 If you pass it an 11 \, then object returns 11;
#X floatatom 33 116 5 0 0 0 - - -;
#X floatatom 33 163 5 0 0 0 - - -;
#X text 35 96 [MIN];
#X text 88 113 - [min] returns the lesser of the two numbers passed
to its inlets. For example \, if the creation argument (or right inlet)
is equal to 10 \, and you send 9 to the left inlet then the object
will return 9 If you pass it an 11 \, then object returns 10;
#X obj 33 138 min 10;
#X text 32 185 - It is important to note that [max] and [min] output
a number with every number or "bang" that is sent to the left inlet.
;
#X floatatom 35 234 5 0 0 0 - - -;
#X floatatom 35 282 5 0 0 0 - - -;
#X obj 35 256 min 10;
#X obj 76 281 bng 15 50 10 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X text 80 232 Move this number box above 10;
#X connect 1 0 3 0;
#X connect 2 0 1 0;
#X connect 5 0 9 0;
#X connect 9 0 6 0;
#X connect 11 0 13 0;
#X connect 13 0 12 0;
#X connect 13 0 14 0;
#X restore 33 488 pd understanding_MAX_and_MIN;
#X text 469 20 THE SUM OF MANY NUMBERS;
#X msg 600 98 bang;
#X obj 600 150 random 10;
#X obj 662 150 random 10;
#X obj 724 150 random 10;
#X text 628 169 a;
#X text 690 170 b;
#X text 751 169 c;
#X text 631 235 d;
#X floatatom 600 235 0 0 0 0 - - -;
#X obj 600 119 t b b b;
#X obj 600 192 +;
#X obj 600 213 +;
#X floatatom 600 170 0 0 0 0 - - -;
#X floatatom 662 170 0 0 0 0 - - -;
#X floatatom 724 170 0 0 0 0 - - -;
#X text 469 324 RELATED OBJECTS;
#X obj 666 350 -~;
#X obj 695 350 *~;
#X obj 723 350 /~;
#X obj 751 350 max~;
#X obj 781 350 min~;
#X text 540 350 Audio Math;
#X obj 637 374 ==;
#X obj 695 374 >;
#X obj 751 374 <;
#X obj 723 374 >=;
#X obj 781 373 <=;
#X obj 667 374 !=;
#X text 504 375 Relational Tests;
#X text 498 398 Logical Operators;
#X obj 638 398 &;
#X obj 667 398 |;
#X obj 695 398 &&;
#X obj 723 398 ||;
#X obj 751 398 <<;
#X obj 781 398 >>;
#X obj 695 499 expr;
#X obj 637 422 mtof;
#X obj 668 422 ftom;
#X obj 699 422 powtodb;
#X obj 749 422 rmstodb;
#X obj 799 422 dbtopow;
#X obj 849 422 dbtorms;
#X text 445 423 Acoustical Unit Conversion;
#X text 537 450 Higher Math;
#X obj 808 374 mod;
#X obj 835 374 div;
#X obj 641 449 sin;
#X obj 667 449 cos;
#X obj 694 449 tan;
#X obj 721 449 atan;
#X obj 640 473 atan2;
#X obj 731 499 random;
#X obj 678 473 sqrt;
#X obj 709 473 log;
#X obj 735 473 exp;
#X obj 761 473 abs;
#X text 570 499 Other;
#N canvas 10 40 620 460 related_objects_from_other_libraries 0;
#X obj 37 25 vector+;
#X obj 37 45 vector-;
#X obj 37 65 vector*;
#X obj 85 25 vector/;
#X obj 85 45 rgb2hsv;
#X obj 85 65 hsv2rgb;
#X obj 133 25 abs~;
#X obj 133 45 db2v;
#X obj 133 65 v2db;
#X obj 163 25 avg~;
#X obj 164 45 tavg~;
#X obj 164 65 pdf~;
#X obj 201 24 <~;
#X obj 201 45 ==~;
#X obj 201 67 >~;
#X obj 228 25 &&~;
#X obj 228 46 ||~;
#X obj 228 67 matrix~;
#X obj 280 25 mavg;
#X obj 280 46 mean;
#X obj 280 68 divide;
#X obj 323 27 divmod;
#X obj 324 47 minus;
#X obj 324 67 plus;
#X text 29 104 These objects are offered in Pd only if you have downloaded
and properly installed the appropriate library. These objects may or
may not exist in a single library.;
#X text 28 153 The best places to find information about Pd's libraries
is:;
#X text 25 175 www.puredata.org and click on "Downloads" then "Software"
;
#X text 27 190 or;
#X text 27 205 iem.kug.ac.at/pdb/;
#X obj 370 27 q8_rsqrt~;
#X obj 370 51 q8_sqrt~;
#X restore 520 537 pd related_objects_from_other_libraries;
#X obj 778 499 f;
#X obj 806 499 int;
#X obj 809 398 %;
#X obj 754 449 pow;
#X connect 11 0 13 0;
#X connect 12 0 11 0;
#X connect 14 0 11 1;
#X connect 15 0 11 0;
#X connect 21 0 23 0;
#X connect 23 0 22 0;
#X connect 29 0 38 0;
#X connect 30 0 41 0;
#X connect 31 0 42 0;
#X connect 32 0 43 0;
#X connect 38 0 30 0;
#X connect 38 1 31 0;
#X connect 38 2 32 0;
#X connect 39 0 40 0;
#X connect 40 0 37 0;
#X connect 41 0 39 0;
#X connect 42 0 39 1;
#X connect 43 0 40 1;