polymorphism: better names for .binaryValue and .booleanValue are .asInteger and...
[supercollider.git] / Help / Libraries / JITLib / tutorials / audio_rate_mapping.html
blob3352e696e5ce6e99fc6d8b3f6888e7475a86ad3d
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="949.43">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0000bf}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000; min-height: 12.0px}
15 span.s1 {color: #0000bf}
16 span.s2 {color: #000000}
17 span.s3 {color: #007300}
18 </style>
19 </head>
20 <body>
21 <p class="p1">// audio mapping in ProxySpace</p>
22 <p class="p1">// todo. expand(numChannels) message</p>
23 <p class="p2"><br></p>
24 <p class="p2"><br></p>
25 <p class="p3">p = <span class="s1">ProxySpace</span>.push(s.boot);</p>
26 <p class="p3">p.fadeTime = 3;</p>
27 <p class="p1">// some filters</p>
28 <p class="p4"><span class="s2">~f1 = { </span>|a_in=#[0,0], freq=500, dt=0.01|<span class="s2"><span class="Apple-converted-space">  </span></span>Ringz<span class="s2">.ar(a_in, freq, dt) };<span class="Apple-converted-space"> </span></span></p>
29 <p class="p3">~f2 = { <span class="s1">|a_in=#[0,0], dt=0.1|</span> <span class="s1">CombL</span>.ar(a_in, 0.5, dt, 15 * dt) };</p>
30 <p class="p3">~f3 = { <span class="s1">|a_in=#[0,0], freq=30|</span> a_in * <span class="s1">LFSaw</span>.ar(freq.neg).max(0) };</p>
31 <p class="p2"><br></p>
32 <p class="p1">// some sources</p>
33 <p class="p3">~x1 = { <span class="s1">LFPulse</span>.kr(<span class="s1">SinOsc</span>.kr(0.2).exprange(2, 200)) * <span class="s1">PinkNoise</span>.ar(0.5.dup) };</p>
34 <p class="p3">~x2 = { <span class="s1">Dust</span>.ar(<span class="s1">SinOsc</span>.kr(0.2, [0, pi]).exprange(2, 2000)) };</p>
35 <p class="p2"><br></p>
36 <p class="p1">// the output</p>
37 <p class="p3">~out.play;</p>
38 <p class="p3">~out = { <span class="s1">|a_in=#[0,0]|</span> a_in };</p>
39 <p class="p2"><br></p>
40 <p class="p1">// some mappings by hand:</p>
41 <p class="p3">~out.mapn(<span class="s3">\a_in</span>, ~x1);</p>
42 <p class="p3">~out.xmapn(<span class="s3">\a_in</span>, ~x2);</p>
43 <p class="p2"><br></p>
44 <p class="p3">~out.xmapn(<span class="s3">\a_in</span>, ~f1); ~f1.xmapn(<span class="s3">\a_in</span>, ~x1);</p>
45 <p class="p3">~out.xmapn(<span class="s3">\a_in</span>, ~f2); ~f2.xmapn(<span class="s3">\a_in</span>, ~x1);</p>
46 <p class="p3">~out.xmapn(<span class="s3">\a_in</span>, ~f2); ~f2.xmapn(<span class="s3">\a_in</span>, ~x1);</p>
47 <p class="p3">~f2.xset(<span class="s3">\dt</span>, 0.01);</p>
48 <p class="p2"><br></p>
49 <p class="p3">~mx1 = { <span class="s1">MouseX</span>.kr(0.0001, 1, 1) };</p>
50 <p class="p3">~f2.xmap(<span class="s3">\dt</span>, ~mx1);</p>
51 <p class="p2"><br></p>
52 <p class="p3">~out.xmapn(<span class="s3">\a_in</span>, ~f3);<span class="Apple-converted-space">  </span>~f3.xmapn(<span class="s3">\a_in</span>, ~f2); ~f2.xmapn(<span class="s3">\a_in</span>, ~x1);</p>
53 <p class="p1">// this should maybe be:</p>
54 <p class="p1">// ~f2 --(\a_in)--&gt; ~f3 --(\a_in)--&gt; ~out</p>
55 <p class="p2"><br></p>
56 <p class="p3">~mx1 = { <span class="s1">LFNoise1</span>.kr(0.1).exprange(0.0001, 1) };</p>
57 <p class="p3">~mF = { ~mx1.kr.linexp(0, 1, 1, 10000) };</p>
58 <p class="p3">~f3.xmap(<span class="s3">\freq</span>, ~mF);</p>
59 <p class="p2"><br></p>
60 <p class="p3">~f1.mapn(<span class="s3">\a_in</span>, ~x2);</p>
61 <p class="p3">~f2.xmapn(<span class="s3">\a_in</span>, ~f1);</p>
62 <p class="p2"><br></p>
63 <p class="p3">~f1.xmapn(<span class="s3">\freq</span>, ~mF, <span class="s3">\dt</span>, ~mx1);</p>
64 <p class="p2"><br></p>
65 <p class="p3">~x2 = { <span class="s1">Impulse</span>.ar(<span class="s1">SinOsc</span>.kr(0.2, [0, pi]).exprange(2, 200)) };</p>
66 <p class="p3">~x1 = { <span class="s1">Saw</span>.ar(20, 0.5.dup) * ~x2.ar };</p>
67 <p class="p3">~out = ~x1;</p>
68 <p class="p2"><br></p>
69 <p class="p2"><br></p>
70 <p class="p1">// possible schema:</p>
71 <p class="p1">/*</p>
72 <p class="p5"><br></p>
73 <p class="p1">px.map knows always already the number of channels of a proxy, so can decide whether</p>
74 <p class="p1">to use map or mapn. (map always would mean flat mapping).</p>
75 <p class="p5"><br></p>
76 <p class="p1">px.mapn could do tricky things like:</p>
77 <p class="p1">px.mapn(\a_in2, [mono1, mono2])</p>
78 <p class="p1">px.mapn(\a_in2, stereo) would still work</p>
79 <p class="p1">px.mapn(\a_in2, [stereo, mono]) could use the first of the stereo chans and the mono</p>
80 <p class="p1">how to get at the second arg of the stereo in? or it could mix/wrap.</p>
81 <p class="p1">--&gt; px.mapn([\a_inx, \a_iny], stereo)</p>
82 <p class="p5"><br></p>
83 <p class="p1">px.mapn(\a_in, stereo) would take the first of the stereo channels</p>
84 <p class="p1">px.map(\a_in, stereo) would use the first of the stereo channels</p>
85 <p class="p1">px.mapn(\a_in, [mono, mono]) would use the first channel</p>
86 <p class="p5"><br></p>
87 <p class="p1">mappings could be saved as is and if the proxy rebuilds with a different channel size, it would unfold?</p>
88 <p class="p5"><br></p>
89 <p class="p5"><br></p>
90 <p class="p1">*/</p>
91 <p class="p2"><br></p>
92 <p class="p2"><br></p>
93 <p class="p2"><br></p>
94 <p class="p2"><br></p>
95 </body>
96 </html>