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.43">
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: #001bb9; min-height: 12.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #001bb9}
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 14.0px; text-indent: -14.0px; font: 12.0px Helvetica
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica
; min-height: 19.0px}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica
}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #ad140d}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #2c7014}
21 p
.p12
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
22 span
.s1
{font: 18.0px Helvetica
}
23 span
.s2
{font: 14.0px Helvetica
}
24 span
.s3
{color: #000000}
25 span
.s4
{color: #0021e7}
26 span
.s5
{color: #001bb9}
27 span
.s6
{color: #0000ff}
28 span
.s7
{color: #2c7014}
29 span
.s8
{color: #ad140d}
30 span
.Apple-tab-span
{white-space:pre
}
34 <p class=
"p1"><span class=
"s1"><b>InFeedback
</b></span><span class=
"s2"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>read signal from a bus with a current or one cycle old timestamp
</b></p>
35 <p class=
"p2"><br></p>
36 <p class=
"p3"><span class=
"s3"><b>Inherits from:
</b><a href=
"../../Core/Object.html"><span class=
"s4"><b>Object
</b></span></a></span><b> :
</b><a href=
"../../Core/Kernel/AbstractFunction.html"><b>AbstractFunction
</b></a><b> :
</b><a href=
"../UGen.html"><b>UGen
</b></a><b> :
</b><a href=
"../Multichannel/MultiOutUGen.html"><b>MultiOutUGen
</b></a><b> :
</b><a href=
"AbstractIn.html"><span class=
"s4"><b>AbstractIn
</b></span></a></p>
37 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
38 <p class=
"p1"><b>*ar(bus, numChannels)
</b></p>
39 <p class=
"p4"><b><span class=
"Apple-tab-span"> </span></b></p>
40 <p class=
"p1"><b>bus
</b>- the index of the bus to read in from.
</p>
41 <p class=
"p5"><b>numChannels
</b>- the number of channels (i.e. adjacent buses) to read in. The default is
1. You cannot modulate this number by assigning it to an argument in a SynthDef.
</p>
42 <p class=
"p4"><br></p>
43 <p class=
"p1">When the various output ugens (
<a href=
"Out.html"><span class=
"s5"><b>Out
</b></span></a>,
<a href=
"OffsetOut.html"><span class=
"s5"><b>OffsetOut
</b></span></a>,
<a href=
"XOut.html"><span class=
"s5"><b>XOut
</b></span></a>) write data to a bus, they
<i>mix
</i> it with any data from the current cycle, but
<i>overwrite
</i> any data from the previous cycle. (
<a href=
"ReplaceOut.html"><span class=
"s5"><b>ReplaceOut
</b></span></a> overwrites all data regardless.) Thus depending on node order and what synths are writing to the bus, the data on a given bus may be from the current cycle or be one cycle old at the time of reading.
<a href=
"In.html"><span class=
"s5"><b>In
</b></span></a><b>.ar
</b> checks the timestamp of any data it reads in and zeros any data from the previous cycle (for use within that node; the data remains on the bus). This is fine for audio data, as it avoids feedback, but for control data it is useful to be able to read data from any place in the node order. For this reason
<b>In.kr
</b> also reads data that is older than the current cycle.
</p>
44 <p class=
"p4"><br></p>
45 <p class=
"p1">In some cases we might also want to read audio from a node later in the current node order. This is the purpose of InFeedback. The delay introduced by this is one block size, which equals about
0.0014 sec at the default block size and sample rate. (See the resonator example below to see the implications of this.)
</p>
46 <p class=
"p4"><br></p>
47 <p class=
"p1">The variably mixing and overwriting behaviour of the output ugens can make order of execution crucial. (No pun intended.) For example with a node order like the following the InFeedback ugen in Synth
2 will only receive data from Synth
1 (-
> = write out;
<- = read in):
</p>
48 <p class=
"p4"><br></p>
49 <p class=
"p1">Synth
1 -
> busA
<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>this synth overwrites the output of Synth3 before it reaches Synth
2</p>
50 <p class=
"p1">Synth
2 (with InFeedback)
<- busA
<span class=
"Apple-converted-space"> </span></p>
51 <p class=
"p1">Synth
3 -
> busA
</p>
52 <p class=
"p4"><br></p>
53 <p class=
"p1">If Synth
1 were moved after Synth
2 then Synth
2's InFeedback would receive a mix of the output from Synth
1 and Synth
3. This would also be true if Synth
2 came after Synth1 and Synth
3. In both cases data from Synth
1 and Synth
3 would have the same time stamp (either current or from the previous cycle), so nothing would be overwritten.
</p>
54 <p class=
"p4"><br></p>
55 <p class=
"p1">Because of this it is often useful to allocate a separate bus for feedback. With the following arrangement Synth
2 will receive data from Synth3 regardless of Synth
1's position in the node order.
</p>
56 <p class=
"p2"><br></p>
57 <p class=
"p1">Synth
1 -
> busA
</p>
58 <p class=
"p1">Synth
2 (with InFeedback)
<- busB
<span class=
"Apple-converted-space"> </span></p>
59 <p class=
"p1">Synth
3 -
> busB + busA
<span class=
"Apple-converted-space"> </span></p>
60 <p class=
"p4"><br></p>
61 <p class=
"p1">The second example below demonstrates this issue.
</p>
62 <p class=
"p4"><br></p>
63 <p class=
"p1">See also
<a href=
"LocalIn.html"><span class=
"s6"><b>LocalIn
</b></span></a> and
<a href=
"LocalOut.html"><span class=
"s6"><b>LocalOut
</b></span></a>.
</p>
64 <p class=
"p2"><br></p>
65 <p class=
"p6"><br></p>
66 <p class=
"p7"><b>Examples
</b></p>
67 <p class=
"p4"><br></p>
68 <p class=
"p1">audio feedback modulation:
</p>
69 <p class=
"p2"><br></p>
70 <p class=
"p8"><span class=
"Apple-tab-span"> </span>(
</p>
71 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"s5">SynthDef
</span>(
<span class=
"s7">\help_InFeedback
</span>, {
<span class=
"s5">arg
</span> out=
0, in=
0;
</p>
72 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s5">var
</span> input, sound;
</p>
73 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>input =
<span class=
"s5">InFeedback
</span>.ar(in,
1);
</p>
74 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>sound =
<span class=
"s5">SinOsc
</span>.ar(input *
1300 +
300,
0,
0.4);
</p>
75 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s5">Out
</span>.ar(out, sound);
</p>
76 <p class=
"p9"><br></p>
77 <p class=
"p8"><span class=
"Apple-tab-span"> </span>}).play;
</p>
78 <p class=
"p8"><span class=
"Apple-tab-span"> </span>)
</p>
79 <p class=
"p9"><br></p>
80 <p class=
"p1">this shows how a node can read audio from a bus that is being written to by a synth following it:
</p>
81 <p class=
"p9"><br></p>
82 <p class=
"p8"><span class=
"Apple-tab-span"> </span>(
</p>
83 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"s5">SynthDef
</span>(
<span class=
"s7">\help_InFeedback
</span>, {
<span class=
"s5">arg
</span> out=
0, in=
0;
</p>
84 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s5">Out
</span>.ar(out,
</p>
85 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s5">InFeedback
</span>.ar(in,
1)
</p>
86 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>);
</p>
87 <p class=
"p8"><span class=
"Apple-tab-span"> </span>}).send(s);
</p>
88 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"s5">SynthDef
</span>(
<span class=
"s7">\help_SinOsc
</span>, {
<span class=
"s5">arg
</span> out=
0, freq=
440;
</p>
89 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s5">Out
</span>.ar(out,
<span class=
"s5">SinOsc
</span>.ar(freq,
0,
0.1))
</p>
90 <p class=
"p8"><span class=
"Apple-tab-span"> </span>}).send(s);
</p>
91 <p class=
"p8"><span class=
"Apple-tab-span"> </span>)
</p>
92 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
93 <p class=
"p8"><span class=
"Apple-tab-span"> </span>x =
<span class=
"s5">Bus
</span>.audio(s,
1);
</p>
94 <p class=
"p9"><br></p>
95 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// read from bus n play to bus
0 (silent)
</p>
96 <p class=
"p11"><span class=
"s3"><span class=
"Apple-tab-span"> </span>a =
</span><span class=
"s5">Synth
</span><span class=
"s3">(
</span>\help_InFeedback
<span class=
"s3">,[
</span>\in
<span class=
"s3">, x,
</span>\out
<span class=
"s3">,
0]);
</span></p>
97 <p class=
"p9"><br></p>
98 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// now play a synth after this one, playing to bus x
</p>
99 <p class=
"p8"><span class=
"Apple-tab-span"> </span>b =
<span class=
"s5">Synth
</span>.after(a,
<span class=
"s7">\help_SinOsc
</span>, [
<span class=
"s7">\out
</span>, x]);
</p>
100 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
101 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// add another synth before a which also writes to bus x
</p>
102 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// now you can't hear b, as its data is one cycle old, and is overwritten by c
</p>
103 <p class=
"p8"><span class=
"Apple-tab-span"> </span>c =
<span class=
"s5">Synth
</span>.before(a,
<span class=
"s7">\help_SinOsc
</span>, [
<span class=
"s7">\out
</span>, x,
<span class=
"s7">\freq
</span>,
800]);
</p>
104 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
105 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// free c and you can hear b again
</p>
106 <p class=
"p8"><span class=
"Apple-tab-span"> </span>c.free;
</p>
107 <p class=
"p8"><span class=
"Apple-tab-span"> </span>x.free;
</p>
108 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
109 <p class=
"p8"><span class=
"Apple-tab-span"> </span>a.free; b.free;
</p>
110 <p class=
"p9"><br></p>
111 <p class=
"p1">The example below implements a resonator. Note that you must subtract the blockSize in order for the tuning to be correct. See
<b>LocalIn
</b> for an equivalent example.
</p>
112 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
113 <p class=
"p8"><span class=
"Apple-tab-span"> </span>(
</p>
114 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"s5">var
</span> play, imp, initial;
</p>
115 <p class=
"p12"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span><span class=
"s5">SynthDef
</span><span class=
"s3">(
</span>"testRes"<span class=
"s3">, {
</span></p>
116 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
117 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span>play =
</span><span class=
"s5">InFeedback
</span><span class=
"s3">.ar(
10,
1);
</span>//
10 is feedback channel
</p>
118 <p class=
"p8"><span class=
"Apple-tab-span"> </span>imp =
<span class=
"s5">Impulse
</span>.ar(
1);
</p>
119 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
120 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// feedback
</p>
121 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"s5">OffsetOut
</span>.ar(
10,
<span class=
"s5">DelayC
</span>.ar(imp + (play *
0.995),
1,
<span class=
"Apple-converted-space"> </span></p>
122 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>440.reciprocal -
<span class=
"s5">ControlRate
</span>.ir.reciprocal));
<span class=
"s8">// subtract block size
</span></p>
123 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
124 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"s5">OffsetOut
</span>.ar(
0, play);
</p>
125 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
126 <p class=
"p8"><span class=
"Apple-tab-span"> </span>}).play(s);
</p>
127 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
128 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// Compare with this for tuning
</p>
129 <p class=
"p8"><span class=
"Apple-tab-span"> </span>{
<span class=
"s5">SinOsc
</span>.ar(
440,
0,
0.2) }.play(s,
1);
</p>
130 <p class=
"p8"><span class=
"Apple-tab-span"> </span>)
</p>
131 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>