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.44">
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: 12.0px Monaco
; min-height: 16.0px}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #000000}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #000000; min-height: 12.0px}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #0000bf}
18 span
.s1
{color: #0000bf}
19 span
.s2
{color: #000000}
20 span
.s3
{color: #bf0000}
21 span
.Apple-tab-span
{white-space:pre
}
25 <p class=
"p1"><b>PitchShift
</b></p>
26 <p class=
"p2"><br></p>
27 <p class=
"p3"><b>PitchShift.ar(in, windowSize, pitchRatio, pitchDispersion, timeDispersion, mul, add)
</b></p>
28 <p class=
"p2"><br></p>
29 <p class=
"p3">A time domain granular pitch shifter.
</p>
30 <p class=
"p3">Grains have a triangular amplitude envelope and an overlap of
4:
1.
</p>
31 <p class=
"p3"><b>in
</b> - the input signal.
</p>
32 <p class=
"p3"><b>windowSize
</b> - the size of the grain window in seconds. This value cannot be modulated.
</p>
33 <p class=
"p3"><b>pitchRatio
</b> - the ratio of the pitch shift. Must be from
0.0 to
4.0.
</p>
34 <p class=
"p3"><b>pitchDispersion
</b> - the maximum random deviation of the pitch from the pitchRatio.
</p>
35 <p class=
"p3"><b>timeDispersion
</b> - a random offset of from zero to timeDispersion seconds is added to the delay
</p>
36 <p class=
"p3">of each grain. Use of some dispersion can alleviate a hard comb filter effect due to uniform
</p>
37 <p class=
"p3">grain placement. It can also be an effect in itself. timeDispersion can be no larger than windowSize.
</p>
38 <p class=
"p4"><br></p>
40 <p class=
"p5">play({
</p>
41 <p class=
"p5"><span class=
"Apple-tab-span"> </span>z =
<span class=
"s1">Blip
</span>.ar(
800,
6,
0.1);
</p>
42 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s1">PitchShift
</span>.ar(z,
0.02,
<span class=
"s1">Line
</span>.kr(
0.1,
4,
20),
0,
0.0001)
</p>
44 <p class=
"p6"><br></p>
46 <p class=
"p7">// pitch shift input - USE HEADPHONES to prevent feedback.
</p>
47 <p class=
"p5">play({
</p>
48 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>PitchShift
<span class=
"s2">.ar(
</span></p>
49 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><span class=
"s1">SoundIn
</span><span class=
"s2">.ar([
0,
1]),
<span class=
"Apple-tab-span"> </span></span>// stereo audio input
</p>
50 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0.1,
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// grain size
</p>
51 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><span class=
"s1">MouseX
</span><span class=
"s2">.kr(
0,
2),
<span class=
"Apple-tab-span"> </span></span>// mouse x controls pitch shift ratio
</p>
52 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0,
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// pitch dispersion
</p>
53 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0.004<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// time dispersion
</p>
54 <p class=
"p5"><span class=
"Apple-tab-span"> </span>)
</p>
56 <p class=
"p6"><br></p>
58 <p class=
"p7">// use PitchShift to granulate input - USE HEADPHONES to prevent feedback.
</p>
59 <p class=
"p7">// upper left corner is normal playback. x = pitch dispersion, y = time dispersion
</p>
60 <p class=
"p5"><span class=
"s1">var
</span> grainSize;
</p>
61 <p class=
"p5">grainSize =
0.5;
</p>
62 <p class=
"p5">play({
</p>
63 <p class=
"p8"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>PitchShift
<span class=
"s2">.ar(
</span></p>
64 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">SoundIn
</span>.ar([
0,
1]),
<span class=
"Apple-converted-space"> </span></p>
65 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>grainSize,
<span class=
"Apple-converted-space"> <span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span></p>
66 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>1,
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// nominal pitch rate =
1</p>
67 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><span class=
"s1">MouseX
</span><span class=
"s2">.kr(
0,
1),
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// pitch dispersion
</p>
68 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">MouseY
</span>.kr(
0, grainSize)
<span class=
"Apple-tab-span"> </span><span class=
"s3">// time dispersion
</span></p>
69 <p class=
"p5"><span class=
"Apple-tab-span"> </span>)
</p>
71 <p class=
"p4"><br></p>