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=
"949.35">
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 Helvetica
; color: #0021e7}
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: #bf0000}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #007300}
19 span
.s1
{color: #000000}
20 span
.s2
{text-decoration: underline
}
21 span
.s3
{color: #0000bf}
22 span
.s4
{color: #bf0000}
23 span
.s5
{color: #007300}
24 span
.Apple-tab-span
{white-space:pre
}
28 <p class=
"p1"><b>PV_Min
<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>minimum magnitude
</b></p>
29 <p class=
"p2"><br></p>
30 <p class=
"p3"><b>PV_Min(bufferA,
<span class=
"Apple-converted-space"> </span>bufferB)
</b></p>
31 <p class=
"p2"><br></p>
32 <p class=
"p3">Output copies bins with the minimum magnitude of the two inputs.
</p>
33 <p class=
"p3"><b>bufferA
</b> - fft buffer A.
</p>
34 <p class=
"p3"><b>bufferB
</b> - fft buffer B.
</p>
35 <p class=
"p2"><br></p>
36 <p class=
"p4"><span class=
"s1">See also
<a href=
"FFT Overview.html"><span class=
"s2">FFT Overview
</span></a>.
</span></p>
37 <p class=
"p2"><br></p>
38 <p class=
"p5">s.boot;
</p>
39 <p class=
"p6"><br></p>
42 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s3">var
</span> inA, chainA, inB, chainB, chain ;
</p>
43 <p class=
"p5"><span class=
"Apple-tab-span"> </span>inA =
<span class=
"s3">Saw
</span>.ar(
<span class=
"s3">LFNoise1
</span>.kr(
2).exprange(
10,
1000));
</p>
44 <p class=
"p5"><span class=
"Apple-tab-span"> </span>inB =
<span class=
"Apple-converted-space"> </span><span class=
"s3">Pulse
</span>.ar(
<span class=
"s3">LFNoise1
</span>.kr(
2).exprange(
10,
1000));
</p>
45 <p class=
"p5"><span class=
"Apple-tab-span"> </span>chainA =
<span class=
"s3">FFT
</span>(
<span class=
"s3">LocalBuf
</span>(
2048), inA);
</p>
46 <p class=
"p5"><span class=
"Apple-tab-span"> </span>chainB =
<span class=
"s3">FFT
</span>(
<span class=
"s3">LocalBuf
</span>(
2048), inB);
</p>
47 <p class=
"p5"><span class=
"Apple-tab-span"> </span>chain =
<span class=
"s3">PV_Min
</span>(chainA, chainB);
<span class=
"Apple-converted-space"> </span></p>
48 <p class=
"p5"><span class=
"Apple-tab-span"> </span>0.1 *
<span class=
"s3">IFFT
</span>(chain).dup;
</p>
49 <p class=
"p5">}.play
</p>
51 <p class=
"p6"><br></p>
52 <p class=
"p6"><br></p>
53 <p class=
"p7">// stereo version:
</p>
54 <p class=
"p6"><br></p>
57 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s3">var
</span> inA, chainA, inB, chainB, chain ;
</p>
58 <p class=
"p5"><span class=
"Apple-tab-span"> </span>inA =
<span class=
"s3">Saw
</span>.ar(
<span class=
"s3">LFNoise1
</span>.kr(
2).exprange(
10,
1000));
<span class=
"s4">// same saw through different pulses
</span></p>
59 <p class=
"p5"><span class=
"Apple-tab-span"> </span>inB =
<span class=
"Apple-converted-space"> </span><span class=
"s3">Pulse
</span>.ar(
<span class=
"s3">LFNoise1
</span>.kr(
2.dup).exprange(
10,
1000));
</p>
60 <p class=
"p5"><span class=
"Apple-tab-span"> </span>chainA =
<span class=
"s3">FFT
</span>(
<span class=
"s3">LocalBuf
</span>(
2048.dup), inA);
</p>
61 <p class=
"p5"><span class=
"Apple-tab-span"> </span>chainB =
<span class=
"s3">FFT
</span>(
<span class=
"s3">LocalBuf
</span>(
2048.dup), inB);
</p>
62 <p class=
"p5"><span class=
"Apple-tab-span"> </span>chain =
<span class=
"s3">PV_Min
</span>(chainA, chainB);
<span class=
"Apple-converted-space"> </span></p>
63 <p class=
"p5"><span class=
"Apple-tab-span"> </span>0.1 *
<span class=
"s3">IFFT
</span>(chain);
</p>
64 <p class=
"p5">}.play
</p>
66 <p class=
"p6"><br></p>
67 <p class=
"p6"><br></p>
68 <p class=
"p6"><br></p>
70 <p class=
"p5"><span class=
"s3">SynthDef
</span>(
<span class=
"s5">\help_max
</span>, {
<span class=
"s3">arg
</span> out=
0, soundBufnum1=
0, soundBufnum2 =
0;
</p>
71 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s3">var
</span> inA, chainA, inB, chainB, chain ;
</p>
72 <p class=
"p5"><span class=
"Apple-tab-span"> </span>inA =
<span class=
"s3">PlayBuf
</span>.ar(
1, soundBufnum1,
<span class=
"s3">BufRateScale
</span>.kr(soundBufnum1), loop:
1);
</p>
73 <p class=
"p5"><span class=
"Apple-tab-span"> </span>inB =
<span class=
"Apple-converted-space"> </span><span class=
"s3">PlayBuf
</span>.ar(
1, soundBufnum2,
<span class=
"s3">BufRateScale
</span>.kr(soundBufnum2), loop:
1);
</p>
74 <p class=
"p5"><span class=
"Apple-tab-span"> </span>chainA =
<span class=
"s3">FFT
</span>(
<span class=
"s3">LocalBuf
</span>(
2048), inA);
</p>
75 <p class=
"p5"><span class=
"Apple-tab-span"> </span>chainB =
<span class=
"s3">FFT
</span>(
<span class=
"s3">LocalBuf
</span>(
2048), inB);
</p>
76 <p class=
"p5"><span class=
"Apple-tab-span"> </span>chain =
<span class=
"s3">PV_Min
</span>(chainA, chainB);
<span class=
"Apple-converted-space"> </span></p>
77 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s3">Out
</span>.ar(out,
<span class=
"Apple-converted-space"> </span>0.5 *
<span class=
"s3">IFFT
</span>(chain).dup);
</p>
78 <p class=
"p5">}).store;
</p>
80 <p class=
"p6"><br></p>
81 <p class=
"p6"><br></p>
83 <p class=
"p7"><span class=
"s1">q = q ? ();
</span>// use global dictionary
</p>
84 <p class=
"p6"><br></p>
85 <p class=
"p8"><span class=
"s1"><span class=
"Apple-tab-span"> </span>q[
</span><span class=
"s5">\bufferA
</span><span class=
"s1">] =
</span><span class=
"s3">Buffer
</span><span class=
"s1">.read(s,
</span>"sounds/a11wlk01.wav"<span class=
"s1">);
</span></p>
86 <p class=
"p7"><span class=
"s1"><span class=
"Apple-tab-span"> </span></span><span class=
"s3">CocoaDialog
</span><span class=
"s1">.getPaths({
</span><span class=
"s3">arg
</span><span class=
"s1"> paths;
</span>// get a second soundfile;
</p>
87 <p class=
"p5"><span class=
"Apple-tab-span"> </span>paths.do({
<span class=
"s3">arg
</span> p;
<span class=
"Apple-converted-space"> </span></p>
88 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>q[
<span class=
"s5">\bufferB
</span>] =
<span class=
"s3">Buffer
</span>.read(s, p);
</p>
89 <p class=
"p9"><span class=
"s1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><span class=
"s3">Synth
</span><span class=
"s1">(
</span>\help_max
<span class=
"s1">, [
</span>\out
<span class=
"s1">,
0,
</span>\soundBufnum1
<span class=
"s1">, q[
</span>\bufferA
<span class=
"s1">],
</span>\soundBufnum2
<span class=
"s1">, q[
</span>\bufferB
<span class=
"s1">]]);
</span></p>
90 <p class=
"p5"><span class=
"Apple-tab-span"> </span>})
</p>
92 <p class=
"p8"><span class=
"s1"><span class=
"Apple-tab-span"> </span></span>"cancelled"<span class=
"s1">.postln;
</span></p>
95 <p class=
"p6"><br></p>
96 <p class=
"p5">q[
<span class=
"s5">\bufferA
</span>].free;
</p>
97 <p class=
"p5">q[
<span class=
"s5">\bufferB
</span>].free;
</p>