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: 12.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #0019b7; min-height: 12.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #a71e12}
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: #a71e12; min-height: 12.0px}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #0019b7}
18 span
.s1
{font: 18.0px Helvetica
}
19 span
.s2
{color: #0019b7}
20 span
.s3
{color: #000000}
21 span
.Apple-tab-span
{white-space:pre
}
25 <p class=
"p1"><span class=
"s1"><b>SelectXFocus
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>mix one output from many sources
</b></p>
26 <p class=
"p2"><br></p>
27 <p class=
"p3"><br></p>
28 <p class=
"p1">superclass: Object
</p>
29 <p class=
"p3"><br></p>
30 <p class=
"p1">The output is mixed from an array of inputs, linearly interpolating from a number of adjacent channels.
</p>
31 <p class=
"p1">A focus argument allows to control how many adjacent sources are mixed. (by adc)
</p>
32 <p class=
"p2"><br></p>
33 <p class=
"p1"><b><span class=
"Apple-tab-span"> </span>SelectXFocus.ar(which, array, focus)
</b></p>
34 <p class=
"p1"><b><span class=
"Apple-tab-span"> </span>SelectXFocus.kr(which, array, focus)
</b></p>
35 <p class=
"p2"><br></p>
36 <p class=
"p2"><br></p>
37 <p class=
"p4">// examples
<span class=
"Apple-converted-space"> </span></p>
40 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> a;
</p>
41 <p class=
"p5"><span class=
"Apple-tab-span"> </span>a = [
</p>
42 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">Saw
</span>.ar(
<span class=
"s2">LFSaw
</span>.kr(
3 * [
1,
1.01],
0,
100,
230)),
</p>
43 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">SinOsc
</span>.ar,
</p>
44 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">Pulse
</span>.ar(
<span class=
"s2">LFPulse
</span>.kr(
3 * [
1,
1.02],
0,
0.4,
100,
230)),
</p>
45 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">SinOsc
</span>.ar(
<span class=
"s2">SinOsc
</span>.kr(
4 * [
1,
1.03],
0,
200,
300))
</p>
46 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>];
</p>
47 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
48 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s2">SelectXFocus
</span>.ar(
<span class=
"s2">MouseX
</span>.kr(
0,
1) * a.size, a,
<span class=
"s2">MouseY
</span>.kr(
0, a.size)) *
0.2</p>
49 <p class=
"p5">}.play;
</p>
51 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
52 <p class=
"p1">Note: all the ugens are continously running. This may not be the most efficient way if each input is
<span class=
"Apple-converted-space"> </span>cpu-expensive. The array is fixed at the time of writing the SynthDef, and the whole array is embedded in the SynthDef file itself.
<span class=
"Apple-converted-space"> </span>For small arrays this is more efficient than reading from a buffer.
</p>
53 <p class=
"p2"><br></p>
54 <p class=
"p7"><br></p>
55 <p class=
"p7"><br></p>
56 <p class=
"p4">// radio tuner
</p>
57 <p class=
"p4">// (jrh) (cc
2006)
</p>
60 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> a, n, mx, my, mwrap;
</p>
61 <p class=
"p5"><span class=
"Apple-tab-span"> </span>n =
8;
</p>
62 <p class=
"p5"><span class=
"Apple-tab-span"> </span>mx =
<span class=
"s2">MouseX
</span>.kr(
0,
1,
0,
0.1);
</p>
63 <p class=
"p5"><span class=
"Apple-tab-span"> </span>my =
<span class=
"s2">MouseY
</span>.kr;
</p>
64 <p class=
"p5"><span class=
"Apple-tab-span"> </span>mwrap = {
<span class=
"s2">|pmin, pmax, min, max|
</span> sin(mx *
<span class=
"s2">ExpRand
</span>(pmin, pmax)) +
1 *
0.5 *
<span class=
"s2">ExpRand
</span>(min, max) };
</p>
65 <p class=
"p5"><span class=
"Apple-tab-span"> </span>a = {
</p>
66 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> freq, fmul, phase;
</p>
67 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>freq = mwrap.(
10,
40,
200,
5000) +
<span class=
"s2">ExpRand
</span>(
200,
3000);
</p>
68 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>fmul =
<span class=
"s2">LFNoise0
</span>.kr(
<span class=
"s2">ExpRand
</span>(
0.1,
8)).round(
1/
6).exprange(
1,
<span class=
"s2">Rand
</span>(
1,
1.2));
</p>
69 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>phase =
<span class=
"s2">LFNoise2
</span>.ar(mwrap.(
1,
20,
10,
1000),
<span class=
"s2">Rand
</span>(
2,
5));
</p>
70 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">SinOsc
</span>.ar(freq * fmul, phase)
</p>
71 <p class=
"p5"><span class=
"Apple-tab-span"> </span>} ! n;
</p>
72 <p class=
"p5"><span class=
"Apple-tab-span"> </span>a = a.add(
</p>
73 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">SinOsc
</span>.ar(
<span class=
"s2">LFDNoise0
</span>.kr(
11,
<span class=
"s2">SetResetFF
</span>.kr(*
<span class=
"s2">Dust
</span>.kr([
1,
2] *
0.3))).range(
0,
700) +
220)
</p>
74 <p class=
"p5"><span class=
"Apple-tab-span"> </span>);
</p>
75 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s2">SelectXFocus
</span>.ar(mx * n, a, my * n) *
0.2 +
<span class=
"s2">OnePole
</span>.ar(
<span class=
"s2">PinkNoise
</span>.ar(
0.5 !
2),
0.4)
<span class=
"Apple-converted-space"> </span></p>
76 <p class=
"p5"><span class=
"Apple-tab-span"> </span>*
<span class=
"s2">Line
</span>.kr(
0,
1,
3);
</p>
77 <p class=
"p5">}.play;
</p>
79 <p class=
"p2"><br></p>
80 <p class=
"p6"><br></p>
81 <p class=
"p4">// jimmy played harmonica in the pub where I was born
</p>
82 <p class=
"p4">// (hh) (jrh) (cc
2006)
</p>
85 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> blas, zieh, mx, my, trig, which, amp, u, schnauf;
</p>
86 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> del =
9, det =
0.1;
</p>
87 <p class=
"p5"><span class=
"Apple-tab-span"> </span>schnauf =
0.3;
</p>
88 <p class=
"p5"><span class=
"Apple-tab-span"> </span>mx =
<span class=
"s2">MouseX
</span>.kr;
</p>
89 <p class=
"p5"><span class=
"Apple-tab-span"> </span>my =
<span class=
"s2">MouseY
</span>.kr(
0.1,
2,
1);
</p>
90 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
91 <p class=
"p5"><span class=
"Apple-tab-span"> </span>blas = [
0,
12,
24] +.x [
60,
64,
67] ++ [
60+
36];
</p>
92 <p class=
"p5"><span class=
"Apple-tab-span"> </span>zieh = [
62,
67,
71,
<span class=
"Apple-converted-space"> </span>74,
77,
81,
83,
<span class=
"Apple-converted-space"> </span>86,
89,
93];
</p>
93 <p class=
"p6"><br></p>
94 <p class=
"p5"><span class=
"Apple-tab-span"> </span>trig =
<span class=
"s2">Dust
</span>.kr(
1);
</p>
95 <p class=
"p5"><span class=
"Apple-tab-span"> </span>which =
<span class=
"s2">ToggleFF
</span>.kr(
<span class=
"s2">TDelay
</span>.kr(trig, schnauf));
</p>
96 <p class=
"p5"><span class=
"Apple-tab-span"> </span>amp =
<span class=
"s2">EnvGen
</span>.kr(
<span class=
"s2">Env
</span>([
1,
0,
1], [schnauf, schnauf]), trig);
</p>
97 <p class=
"p5"><span class=
"Apple-tab-span"> </span>blas =
<span class=
"s2">Select
</span>.kr(which, [blas, zieh]);
</p>
98 <p class=
"p8"><span class=
"s3"><span class=
"Apple-tab-span"> </span>u =
</span>SelectXFocus
<span class=
"s3">.ar(
</span></p>
99 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>mx * blas.size,
<span class=
"Apple-tab-span"> </span></p>
100 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>blas.collect {
<span class=
"s2">|f|
</span></p>
101 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">Pulse
</span>.ar((
<span class=
"s2">Rand
</span>(-
0.04,
0.09) + f).midicps *
0.5,
<span class=
"s2">0.48</span> +
<span class=
"s2">LFNoise1
</span>.kr(
0.06,
0.1),
0.2)
</p>
102 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>},
</p>
103 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>my
</p>
104 <p class=
"p5"><span class=
"Apple-tab-span"> </span>) *
<span class=
"s2">Slope
</span>.kr(mx + my).abs.lag2(
2) * amp;
</p>
105 <p class=
"p5"><span class=
"Apple-tab-span"> </span>u =
<span class=
"s2">Pan2
</span>.ar(
<span class=
"s2">OnePole
</span>.ar(u, -
0.3), mx *
2 -
1);
</p>
106 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s2">DelayL
</span>.ar(
<span class=
"s2">BPF
</span>.ar(u *
2,
1500,
0.3), del + det,
<span class=
"s2">LFNoise2
</span>.kr(
0.2, det, del)) + u
</p>
107 <p class=
"p5">}.play;
</p>
109 <p class=
"p6"><br></p>
110 <p class=
"p6"><br></p>