Debian Codegraph @

demos/wind_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>Wind Tutorial</title>
8 <style>body {max-width: 40em}</style>
9 </head>
10 <body>
11 <h1>Wind Tutorial</h1>
12 <p>This page describes a "wind" effect created by Alex. The basic
13 function is as follows.<br>
14 </p>
15 <p><i>Note: all examples use SAL syntax followed by Lisp syntax in a
16 smaller font. Since SAL does not support optional parameters,
17 keyword parameters are used instead, so these implementations
18 are not exactly equivalent.</i><br>
19 </p>
20 <pre>function wind(dur: 3, scal: 3, cps: 590, bw: 40)
21 return (env(0.07, 0.08, 0.1, 1, 0.6, 0.8, 1) *
22 (reson(scal * noise(), cps, bw, 2) +
23 reson(scal * 1.13 * noise(),
24 cps * pwl(0, 0.74, 0.2, 0.96, 0.5, 0.8, <br> 0.75, 1.16, 0.9, 0.97, 1, 0.74, 1),
25 bw * 1.042, 2))) ~ dur
26
27 <small><small>(defun wind (&amp;optional (dur 3) (scal 3) (cps 590) (bw 40))
28 (stretch dur
29 (mult (env 0.07 0.08 0.1 1 0.6 0.8 1)
30 (sum
31 (reson (scale scal (noise)) cps bw 2)
32 (reson (scale (mult scal 1.13) (noise))
33 (mult cps (pwl 0 0.74 0.2 0.96 0.5 0.8 0.75 1.16 0.9 0.97 1 0.74 1))
34 (mult bw 1.042)
35 2)))))</small></small></pre>
36 <p>The basic idea is to use bandpassed noise to create the sound of
37 wind. In this example,
38 two bandpass filters are added together. The first uses a fixed
39 center frequency and
40 bandwidth, and the second uses a piece-wise linear function to
41 control the center
42 frequency. The entire sound is multiplied by an envelope and
43 stretched to the desired
44 duration. Note how several optional parameters can be used to
45 change the default behavior.</p>
46 <p>A slight elaboration of the wind function uses several copies of
47 wind in sequence with
48 slight overlap:</p><pre>function multiwind()
49 return simrep(i, 4, wind() @ (i * 2.9))</pre>
50
51
52 <pre><small><small>(defun multiwind ()
53 (simrep (i 4) (at (* i 2.9) (wind))))</small></small></pre><small><small>
54
55
56 </small></small>One problem with this approach is that the wind sound becomes
57 periodic. This could be
58 solved by using noise or random numbers to generate the center
59 frequency variation rather
60 than a fixed envelope.<br><br>
61
62 </body></html>