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: 18.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.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: 9.0px Monaco
; color: #606060}
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}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #0019b7}
18 span
.s1
{color: #0019b7}
19 span
.s2
{color: #000000}
20 span
.s3
{color: #326f17}
21 span
.s4
{color: #a71e12}
22 span
.Apple-tab-span
{white-space:pre
}
26 <p class=
"p1"><b>Stepper
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>pulse counter
</b></p>
27 <p class=
"p2"><br></p>
28 <p class=
"p3"><b>Stepper.kr(trig, reset, min, max, step, resetval)
</b></p>
29 <p class=
"p2"><br></p>
30 <p class=
"p3">Each trigger increments a counter which is output as a signal. The counter wraps between min and max.
</p>
31 <p class=
"p3"><b>trig
</b> - trigger. Trigger can be any signal. A trigger happens when the signal changes from
</p>
32 <p class=
"p3">non-positive to positive.
</p>
33 <p class=
"p3"><b>reset
</b> - resets the counter to
<b>resetval
</b> when triggered.
</p>
34 <p class=
"p3"><b>min
</b> - minimum value of the counter.
</p>
35 <p class=
"p3"><b>max
</b> - maximum value of the counter.
</p>
36 <p class=
"p3"><b>step
</b> - step value each trigger. May be negative.
</p>
37 <p class=
"p3"><b>resetval
</b> - value to which the counter is reset when it receives a reset trigger. If nil, then this is patched to
<b>min
</b>.
</p>
38 <p class=
"p2"><br></p>
39 <p class=
"p4"><span class=
"s1">SynthDef
</span><span class=
"s2">(
</span>"help-Stepper"<span class=
"s2">,{
</span><span class=
"s1">arg
</span><span class=
"s2"> out=
0;
</span></p>
40 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s1">Out
</span>.ar(out,
</p>
41 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">SinOsc
</span>.ar(
</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=
"s1">Stepper
</span>.kr(
<span class=
"s1">Impulse
</span>.kr(
10),
0,
<span class=
"s1">4,
16,
1</span>) *
100,
<span class=
"Apple-converted-space"> </span></p>
43 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0,
0.05</p>
44 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
45 <p class=
"p5"><span class=
"Apple-tab-span"> </span>)
</p>
46 <p class=
"p5">}).play;
</p>
47 <p class=
"p2"><br></p>
48 <p class=
"p4"><span class=
"s1">SynthDef
</span><span class=
"s2">(
</span>"help-Stepper"<span class=
"s2">,{
</span><span class=
"s1">arg
</span><span class=
"s2"> out=
0;
</span></p>
49 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s1">Out
</span>.ar(out,
</p>
50 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">SinOsc
</span>.ar(
</p>
51 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">Stepper
</span>.kr(
<span class=
"s1">Impulse
</span>.kr(
10),
0,
<span class=
"s1">4,
16, -
3</span>) *
100,
<span class=
"Apple-converted-space"> </span></p>
52 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0,
0.05</p>
53 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
54 <p class=
"p5"><span class=
"Apple-tab-span"> </span>)
</p>
55 <p class=
"p5">}).play;
</p>
56 <p class=
"p6"><br></p>
57 <p class=
"p4"><span class=
"s1">SynthDef
</span><span class=
"s2">(
</span>"help-Stepper"<span class=
"s2">,{
</span><span class=
"s1">arg
</span><span class=
"s2"> out=
0;
</span></p>
58 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s1">Out
</span>.ar(out,
</p>
59 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">SinOsc
</span>.ar(
</p>
60 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">Stepper
</span>.kr(
<span class=
"s1">Impulse
</span>.kr(
10),
0,
<span class=
"s1">4,
16,
4</span>) *
100,
<span class=
"Apple-converted-space"> </span></p>
61 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0,
0.05</p>
62 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
63 <p class=
"p5"><span class=
"Apple-tab-span"> </span>)
</p>
64 <p class=
"p5">}).play;
</p>
65 <p class=
"p6"><br></p>
66 <p class=
"p6"><br></p>
67 <p class=
"p7">///////////////////////////////////////////////////////////////////////////////////
</p>
69 <p class=
"p7">// Using Stepper and BufRd for sequencing
</p>
71 <p class=
"p6"><br></p>
72 <p class=
"p5">s.boot;
</p>
73 <p class=
"p6"><br></p>
74 <p class=
"p5">s.sendMsg(
<span class=
"s3">\b_alloc
</span>,
10,
128);
</p>
75 <p class=
"p6"><br></p>
76 <p class=
"p5">m = #[
0,
3,
5,
7,
10];
</p>
77 <p class=
"p6"><br></p>
78 <p class=
"p5">a = ({rrand(
0,
15)}.dup(
16).degreeToKey(m) +
36).midicps;
</p>
79 <p class=
"p5">s.performList(
<span class=
"s3">\sendMsg
</span>,
<span class=
"s3">\b_setn
</span>,
10,
0, a.size, a);
</p>
80 <p class=
"p6"><br></p>
82 <p class=
"p8">SynthDef
<span class=
"s2">(
</span><span class=
"s3">\stepper
</span><span class=
"s2">, {
</span></p>
83 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s1">var
</span> rate, clock, index, freq, ffreq, env, out, rev, lfo;
</p>
84 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
85 <p class=
"p5"><span class=
"Apple-tab-span"> </span>rate =
<span class=
"s1">MouseX
</span>.kr(
1,
5,
1);
</p>
86 <p class=
"p5"><span class=
"Apple-tab-span"> </span>clock =
<span class=
"s1">Impulse
</span>.kr(rate);
</p>
87 <p class=
"p5"><span class=
"Apple-tab-span"> </span>env =
<span class=
"s1">Decay2
</span>.kr(clock,
0.002,
2.5);
</p>
88 <p class=
"p5"><span class=
"Apple-tab-span"> </span>index =
<span class=
"s1">Stepper
</span>.kr(clock,
0,
0,
15,
1,
0);
</p>
89 <p class=
"p5"><span class=
"Apple-tab-span"> </span>freq =
<span class=
"s1">BufRd
</span>.kr(
1,
10, index,
1,
1);
</p>
90 <p class=
"p5"><span class=
"Apple-tab-span"> </span>freq =
<span class=
"s1">Lag2
</span>.kr(freq) + [
0,
0.3];
</p>
91 <p class=
"p5"><span class=
"Apple-tab-span"> </span>ffreq =
<span class=
"s1">MouseY
</span>.kr(
80,
1600,
1) * (env *
4 +
2);
</p>
92 <p class=
"p5"><span class=
"Apple-tab-span"> </span>out =
<span class=
"s1">Mix
</span>.ar(
<span class=
"s1">LFPulse
</span>.ar(freq * [
1,
3/
2,
2],
0,
0.3));
</p>
93 <p class=
"p5"><span class=
"Apple-tab-span"> </span>out =
<span class=
"s1">RLPF
</span>.ar(out, ffreq,
0.3, env);
</p>
94 <p class=
"p5"><span class=
"Apple-tab-span"> </span>out =
<span class=
"s1">RLPF
</span>.ar(out, ffreq,
0.3, env);
</p>
95 <p class=
"p5"><span class=
"Apple-tab-span"> </span>out = out *
0.02;
</p>
96 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
97 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// echo
</p>
98 <p class=
"p5"><span class=
"Apple-tab-span"> </span>out =
<span class=
"s1">CombL
</span>.ar(out,
1,
0.66/rate,
2,
0.8, out);
<span class=
"Apple-tab-span"> </span></p>
99 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
100 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// reverb
</p>
101 <p class=
"p5"><span class=
"Apple-tab-span"> </span>rev = out;
</p>
102 <p class=
"p5"><span class=
"Apple-tab-span"> </span>5.do { rev =
<span class=
"s1">AllpassN
</span>.ar(rev,
0.05, {
0.05.rand}.dup, rrand(
1.5,
2.0)) };
</p>
103 <p class=
"p5"><span class=
"Apple-tab-span"> </span>out = out + (
0.3 * rev);
</p>
104 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
105 <p class=
"p5"><span class=
"Apple-tab-span"> </span>out =
<span class=
"s1">LeakDC
</span>.ar(out);
</p>
106 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
107 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// flanger
</p>
108 <p class=
"p5"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>lfo =
<span class=
"s1">SinOsc
</span>.kr(
0.2, [
0,
0.5pi],
0.0024,
0.0025);
</p>
109 <p class=
"p5"><span class=
"Apple-tab-span"> </span>1.do { out =
<span class=
"s1">DelayL
</span>.ar(out,
0.1,
<span class=
"s1">lfo
</span>,
1, out) };
</p>
110 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
111 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// slight bass emphasis
</p>
112 <p class=
"p5"><span class=
"Apple-tab-span"> </span>out =
<span class=
"s1">OnePole
</span>.ar(out,
0.9);
</p>
113 <p class=
"p6"><br></p>
114 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s1">Out
</span>.ar(
0, out);
</p>
115 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
116 <p class=
"p5">}).send(s);
</p>
118 <p class=
"p6"><br></p>
119 <p class=
"p5">s.sendMsg(
<span class=
"s3">\s_new
</span>,
<span class=
"s3">\stepper
</span>,
1000,
0,
0);
</p>
120 <p class=
"p6"><br></p>
121 <p class=
"p5">a = ({rrand(
0,
15)}.dup(
16).degreeToKey(m) +
38).midicps;
</p>
122 <p class=
"p5">s.performList(
<span class=
"s3">\sendMsg
</span>,
<span class=
"s3">\b_setn
</span>,
10,
0, a.size, a);
</p>
123 <p class=
"p6"><br></p>
124 <p class=
"p7"><span class=
"s2">a = a *
2.midiratio;
</span>// transpose up
2 semitones
</p>
125 <p class=
"p5">s.performList(
<span class=
"s3">\sendMsg
</span>,
<span class=
"s3">\b_setn
</span>,
10,
0, a.size, a);
</p>
126 <p class=
"p6"><br></p>
127 <p class=
"p6"><br></p>
129 <p class=
"p5">a = [
97.999,
195.998,
523.251,
466.164,
195.998,
233.082,
87.307,
391.995,
87.307,
261.626,
195.998,
77.782,
233.082,
195.998,
97.999,
155.563 ];
</p>
130 <p class=
"p5">s.performList(
<span class=
"s3">\sendMsg
</span>,
<span class=
"s3">\b_setn
</span>,
10,
0, a.size, a);
</p>
132 <p class=
"p6"><br></p>
133 <p class=
"p5">s.sendMsg(
<span class=
"s3">\n_free
</span>,
1000);
</p>
134 <p class=
"p6"><br></p>