aboutsummaryrefslogtreecommitdiff
path: root/pd/doc/3.audio.examples/02.amplitude.pd
blob: 814d7d7c78d8aa289a0f721f8e33354ba7a77920 (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
#N canvas 73 190 702 512 12;
#X obj 64 65 osc~ 440;
#X obj 64 283 dac~;
#X text 145 66 <-- 440 Hz. sine wave at full blast;
#X msg 431 7 \; pd dsp 1;
#X msg 514 7 \; pd dsp 0;
#X text 456 45 ON;
#X text 534 43 OFF;
#X text 164 18 CONTROLLING AMPLITUDE;
#X text 35 327 Amplitudes of audio signals can have any reasonable
range \, but when you output a signal via the dac~ object \, the samples
should range between -1 and +1. Values out of that range will be "clipped."
;
#X obj 64 202 *~ 0;
#X floatatom 103 163 0 0 0;
#X obj 91 130 dbtorms;
#X floatatom 91 98 0 0 80;
#X text 137 98 <-- set amplitude here in dB;
#X text 211 133 <-- this converts dB to linear units;
#X text 114 282 <-- and out. We'resending to both channels now.;
#X text 210 164 <-- this shows the linear gain;
#X text 116 204 <-- multiply the sine wave by the gain \, reducing
its amplitude. You can also use the "*~" object to multiply two signals.
The "0" argument here instructs it that we'll just send it messages
to set the multiplier.;
#X text 35 396 Here we calculate a gain for the multiplier (*~) using
a "dbtorms" object (acronym for "dB to RMS"). 100 dB is normalized
to one \, and zero dB artificially outputs a true 0;
#X text 34 452 Pd assumes you have a two channel audio system unless
you tell it otherwise.;
#X text 440 486 updated for Pd version 0.33;
#X connect 0 0 9 0;
#X connect 9 0 1 0;
#X connect 9 0 1 1;
#X connect 11 0 9 1;
#X connect 11 0 10 0;
#X connect 12 0 11 0;