Debian Codegraph @

demos/warble_tutorial.htm

raw
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="content-type" content="text/html;
5 charset=windows-1252">
6 <meta name="GENERATOR" content="Microsoft FrontPage 3.0">
7 <title>Warble Tutorial</title>
8 <style>body {max-width: 40em}</style>
9 </head>
10 <body>
11 <h1>Warble Tutorial</h1>
12 <p>The warble function by Alex illustrates the use of AM and FM
13 oscillators to create an "analog" electronic synthesizer sound.</p>
14 <p><i>Note: all examples use SAL syntax followed by Lisp syntax in a
15 smaller font. Since SAL does not support optional parameters,
16 keyword parameters are used instead, so these implementations
17 are not exactly equivalent.</i><br>
18 </p>
19 <pre>function warble(dur: 1, pch: 60)
20 return (env(0.017, 0.1, 0.004, 1, 0.7, 0.8, 1) *
21 amosc(pch, fmosc(hz-to-step(8),
22 pwl(0, 4, 0.2, -4, 0.56, 9, 0.7, <br> 0, 1, -8, 1))) +
23 env(0.2, 0.09, 0.07, 0.92, 0.8, 0.6, 1) ~ 0.96 *
24 amosc(pch, fmosc(pch * 1.414,
25 pwl(0.2, 80, 0.5, 4, 0.9,<br> 1120, 1, 200, 1)))) ~ dur<br><br><small><small>(defun warble (&amp;optional (dur 1) (pch 60))
26 (stretch dur
27 (sum (mult
28 (env 0.017 0.1 0.004 1 0.7 0.8 1)
29 (amosc pch (fmosc (hz-to-step 8)
30 (pwl 0 4 0.2 -4 0.56 9 0.7 0 1 -8 1))))
31 (mult (stretch 0.96 (env 0.2 0.09 0.07 0.92 0.8 0.6 1))
32 (amosc pch (fmosc (* pch 1.414)
33 (pwl 0.2 80 0.5 4 0.9 1120 1 200 1)))))))</small></small></pre><small><small>
34 </small></small><p>This sound is the sum of two components. Each of these components is the product of an
35 envelope (<tt>env</tt>) and an AM oscillator (<tt>amosc</tt>).
36 The first one modulates the AM oscillator with a low frequency
37 (about 8 Hz) sinusoid
38 produced by an FM oscillator. The modulator varies in frequency
39 according to a piece-wise
40 linear envelope.</p>
41 <p>The second component is similar, but uses a much higher
42 modulating frequency in the
43 audio range, producing a ring-modulation effect. Another
44 piece-wise linear envelope sweeps
45 the modulator frequency by as much as 1120 Hz.</p>
46 <h2>Thicker Texture</h2>
47 <p>A thicker texture can be obtained by playing copies of warble
48 together with slight
49 parameter changes. Here is an example:</p>
50 <pre>function thicker()
51 return sim(0.5 * warble(dur: 8, pch: 48) @ 0.0,
52 0.3 * warble(dur: 8.05, pch: 47.9) @ 0.05)
53 <br><small><small>(defun thicker ()
54 (sim (scale 0.5 (at 0.00 (warble 8 48)))
55 (scale 0.3 (at 0.05 (warble 8.05 47.9)))))</small></small></pre>
56 <h2>Another FM Sound</h2>
57 <p>The following produces another analog-sounding FM texture:</p>
58 <pre>function mod(dur)
59 return (pwl(0, 1000, 0.2, 200, 0.5, 8000, 1, 100, 1) *
60 fmosc(c4, pwl(0, 1, 0.5, 3.25, 1, 0.74, 1)) ~ dur
61
62 function blurp(dur)
63 return fmosc(c3, osc(7, dur) * mod(dur))
64 <br><small><small>(defun mod (dur)
65 (stretch dur
66 (mult (pwl 0 1000 .2 200 .5 8000 1 100 1)
67 (fmosc c4 (pwl 0 1 .5 3.25 1 .74 1)))))
68
69 (defun blurp (dur)
70 (fmosc c3 (mult (osc 07 dur) (mod dur))))</small></small></pre><small><small>
71 </small></small><p>This example relies on a combination of AM and FM: the output is
72 from an FM oscillator,
73 but its modulator is formed by multiplying (AM) two oscillators.
74 The first is low
75 frequency (about 12 Hz), giving a warbling sound, and the second,
76 generated by <code>(mod
77 dur)</code>, is another FM oscillator. It appears that the
78 modulation generated by the
79 piece-wise linear function is almost insignificant. You might try
80 scaling the expression
81 (pwl 0 1 .5 3.25 1 .74 1) in <code>mod</code> by varying amounts
82 to see what happens.</p>
83 <p>The original duration of <code>blurp</code> was 3.1 (seconds),
84 but longer versions are
85 interesting and reveal more detail.</p>
86 <h2>Yet Another Sound</h2>
87 <p>See <a href="scratch_tutorial.htm#ring">Other Sounds Using Ring
88 in Vinal Scratch
89 Tutorial</a> for another example.</p>
90 </body></html>