1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"824.42">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica
; min-height: 22.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #942b17}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Helvetica
; min-height: 11.0px}
18 span
.s1
{font: 18.0px Helvetica
}
19 span
.s2
{color: #001fb3}
20 span
.s3
{color: #942b17}
21 span
.s4
{color: #000000}
22 span
.Apple-tab-span
{white-space:pre
}
26 <p class=
"p1"><span class=
"s1"><b>Rotate2
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>Rotate a sound field
</b></p>
27 <p class=
"p2"><br></p>
28 <p class=
"p3"><b>Rotate2.kr(x, y, pos)
</b></p>
29 <p class=
"p4"><br></p>
30 <p class=
"p3">Rotate2 can be used for rotating an ambisonic B-format sound field around an axis.
</p>
31 <p class=
"p3">Rotate2 does an equal power rotation so it also works well on stereo sounds.
</p>
32 <p class=
"p3">It takes two audio inputs (x, y) and an angle control (pos).
</p>
33 <p class=
"p3">It outputs two channels (x, y).
</p>
34 <p class=
"p3">It computes this:
</p>
35 <p class=
"p4"><br></p>
36 <p class=
"p3">xout = cos(angle) * xin + sin(angle) * yin;
</p>
37 <p class=
"p3">yout = cos(angle) * yin - sin(angle) * xin;
</p>
38 <p class=
"p4"><br></p>
39 <p class=
"p3">where angle = pos * pi,
<span class=
"Apple-converted-space"> </span>so that -
1 becomes -pi and +
1 becomes +pi.
<span class=
"Apple-converted-space"> </span></p>
40 <p class=
"p3">This allows you to use an LFSaw to do continuous rotation around a circle.
</p>
41 <p class=
"p4"><br></p>
42 <p class=
"p3"><b>x, y
</b> - input signals
</p>
43 <p class=
"p3"><b>pos
</b> - angle to rotate around the circle from -
1 to +
1.
<span class=
"Apple-converted-space"> </span></p>
44 <p class=
"p3">-
1 is
180 degrees, -
0.5 is left,
0 is forward, +
0.5 is right, +
1 is behind.
</p>
45 <p class=
"p4"><br></p>
48 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> w, x, y, p, q, a, b, c, d;
</p>
49 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
50 <p class=
"p5"><span class=
"Apple-tab-span"> </span>p =
<span class=
"s2">WhiteNoise
</span>.ar(
0.05);
<span class=
"s3">// source
</span></p>
51 <p class=
"p5"><span class=
"Apple-tab-span"> </span>q =
<span class=
"s2">LFSaw
</span>.ar(
200,
0,
0.03)+
<span class=
"s2">LFSaw
</span>.ar(
200.37,
0,
0.03)+
<span class=
"s2">LFSaw
</span>.ar(
201,
0,
0.03);
</p>
52 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
53 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>// B-format encode
2 signals at opposite sides of the circle
</p>
54 <p class=
"p5"><span class=
"Apple-tab-span"> </span>#w, x, y =
<span class=
"s2">PanB2
</span>.ar(p, -
0.5) +
<span class=
"s2">PanB2
</span>.ar(q,
0.5);
<span class=
"Apple-converted-space"> </span></p>
55 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
56 <p class=
"p5"><span class=
"Apple-tab-span"> </span>#x, y =
<span class=
"s2">Rotate2
</span>.ar(x, y,
<span class=
"s2">MouseX
</span>.kr(-
1,
1));
</p>
57 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
58 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>// B-format decode to quad
</p>
59 <p class=
"p5"><span class=
"Apple-tab-span"> </span>#a, b, c, d =
<span class=
"s2">DecodeB2
</span>.ar(
4, w, x, y);
</p>
60 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
61 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span>[a, b, d, c]
</span>// reorder to my speaker arrangement: Lf Rf Lr Rr
</p>
62 <p class=
"p5">}.play;
</p>
64 <p class=
"p8"><br></p>
65 <p class=
"p8"><br></p>
66 <p class=
"p8"><br></p>
67 <p class=
"p7">// Rotation of
2 mono sounds in the stereo field:
</p>
70 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>// rotation via lfo
</p>
71 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> x, y;
</p>
72 <p class=
"p5"><span class=
"Apple-tab-span"> </span>x =
<span class=
"s2">PinkNoise
</span>.ar(
0.4);
</p>
73 <p class=
"p5"><span class=
"Apple-tab-span"> </span>y =
<span class=
"s2">LFTri
</span>.ar(
800) *
<span class=
"s2">LFPulse
</span>.kr(
3,
0,
0.3,
0.2);
</p>
74 <p class=
"p5"><span class=
"Apple-tab-span"> </span>#x, y =
<span class=
"s2">Rotate2
</span>.ar(x, y,
<span class=
"s2">LFSaw
</span>.kr(
0.1));
</p>
75 <p class=
"p5"><span class=
"Apple-tab-span"> </span>[x,y]
</p>
76 <p class=
"p5">}.play;
</p>
78 <p class=
"p6"><br></p>
80 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>// rotation via mouse
</p>
81 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> x, y;
</p>
82 <p class=
"p5"><span class=
"Apple-tab-span"> </span>x =
<span class=
"s2">Mix
</span>.fill(
4, {
<span class=
"s2">LFSaw
</span>.ar(
200 +
2.0.rand2,
0,
0.1) });
</p>
83 <p class=
"p5"><span class=
"Apple-tab-span"> </span>y =
<span class=
"s2">SinOsc
</span>.ar(
900) *
<span class=
"s2">LFPulse
</span>.kr(
3,
0,
0.3,
0.2);
</p>
84 <p class=
"p5"><span class=
"Apple-tab-span"> </span>#x, y =
<span class=
"s2">Rotate2
</span>.ar(x, y,
<span class=
"s2">MouseX
</span>.kr(
0,
2));
</p>
85 <p class=
"p5"><span class=
"Apple-tab-span"> </span>[x,y]
</p>
86 <p class=
"p5">}.play;
</p>
87 <p class=
"p6"><br></p>
88 <p class=
"p6"><br></p>
89 <p class=
"p7">// Rotate B-format about Z axis:
</p>
90 <p class=
"p6"><br></p>
91 <p class=
"p5">wout = win;
</p>
92 <p class=
"p5">zout = zin;
</p>
93 <p class=
"p5">#xout, yout =
<span class=
"s2">Rotate2
</span>.ar(xin, yin, pos);
</p>
94 <p class=
"p6"><br></p>
95 <p class=
"p7">// Rotate B-format about Y axis:
</p>
96 <p class=
"p6"><br></p>
97 <p class=
"p5">wout = win;
</p>
98 <p class=
"p5">yout = yin;
</p>
99 <p class=
"p5">#xout, zout =
<span class=
"s2">Rotate2
</span>.ar(xin, zin, pos);
</p>
100 <p class=
"p6"><br></p>
101 <p class=
"p7">// Rotate B-format about X axis:
</p>
102 <p class=
"p6"><br></p>
103 <p class=
"p5">wout = win;
</p>
104 <p class=
"p5">xout = xin;
</p>
105 <p class=
"p5">#yout, zout =
<span class=
"s2">Rotate2
</span>.ar(yin, zin, pos);
</p>
106 <p class=
"p6"><br></p>
107 <p class=
"p6"><br></p>
108 <p class=
"p6"><br></p>