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: #0000bf; min-height: 12.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #0000bf}
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: 9.0px Monaco
}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
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: #bf0000}
19 span
.s1
{font: 18.0px Helvetica
}
20 span
.s2
{font: 14.0px Helvetica
}
21 span
.s3
{color: #000000}
22 span
.s4
{color: #0000bf}
23 span
.s5
{color: #0000bf}
24 span
.s6
{color: #0000bf}
25 span
.s7
{font: 9.0px Monaco
}
26 span
.s8
{color: #0000bf}
27 span
.s9
{color: #0000bf}
28 span
.s10
{font: 12.0px Helvetica
}
29 span
.s11
{color: #0000bf}
30 span
.s12
{color: #606060}
31 span
.s13
{color: #007300}
32 span
.Apple-tab-span
{white-space:pre
}
36 <p class=
"p1"><span class=
"s1"><b>In
</b></span><span class=
"s2"><b><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>read a signal from a bus
</b></p>
37 <p class=
"p2"><br></p>
38 <p class=
"p3"><span class=
"s3"><b>Inherits from:
</b><a href=
"../../Core/Object.html"><b>Object
</b></a></span><span class=
"s4"><b> :
</b><a href=
"../../Core/Kernel/AbstractFunction.html"><span class=
"s5"><b>AbstractFunction
</b></span></a><b> :
</b><a href=
"../UGen.html"><span class=
"s5"><b>UGen
</b></span></a></span><b> :
</b><a href=
"../Multichannel/MultiOutUGen.html"><span class=
"s6"><b>MultiOutUGen
</b></span></a><span class=
"s6"><b> :
</b><a href=
"AbstractIn.html"><b>AbstractIn
</b></a></span></p>
39 <p class=
"p2"><br></p>
40 <p class=
"p1"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span><b>*ar(bus, numChannels)
</b>- read a signal from an audio bus.
</p>
41 <p class=
"p1"><b><span class=
"Apple-tab-span"> </span>*kr(bus, numChannels)
</b>-
<b> </b>read a signal from a control bus.
</p>
42 <p class=
"p4"><br></p>
43 <p class=
"p1"><b>bus
</b>- the index of the bus to read in from.
</p>
44 <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>
45 <p class=
"p2"><br></p>
46 <p class=
"p1">In.kr is functionally similar to
<a href=
"InFeedback.html"><span class=
"s8">InFeedback
</span></a><b>.
</b>That is it reads all data on the bus whether it is from the current cycle or not. This allows for it to receive data from later in the node order. In.ar reads only data from the current cycle, and will zero data from earlier cycles (for use within that synth; the data remains on the bus). Because of this and the fact that the various out ugens
<i>mix
</i> their output with data from the current cycle but
<i>overwrite
</i> data from an earlier cycle it may be necessary to use a private control bus when this type of feedback is desired. There is an example below which demonstrates the problem. See the
<a href=
"InFeedback.html"><span class=
"s8">InFeedback
</span></a> and
<a href=
"../../ServerArchitecture/Order-of-execution.html"><span class=
"s8">Order-of-execution
</span></a> helpfiles for more details.
</p>
47 <p class=
"p4"><br></p>
48 <p class=
"p1">Note that using the
<b>Bus
</b> class to allocate a multichannel bus simply reserves a series of adjacent bus indices with the
<a href=
"../../ServerArchitecture/Server.html"><span class=
"s8">Server
</span></a> object's bus allocators. abus.index simply returns the first of those indices. When using a Bus with an
<b>In
</b> or
<a href=
"Out.html"><span class=
"s8">Out
</span></a> ugen there is nothing to stop you from reading to or writing from a larger range, or from hardcoding to a bus that has been allocated. You are responsible for making sure that the number of channels match and that there are no conflicts. See the
<a href=
"../../ServerArchitecture/Server-Architecture.html"><span class=
"s8">Server-Architecture
</span></a> and
<a href=
"../../ServerArchitecture/Bus.html"><span class=
"s8">Bus
</span></a> helpfiles for more information on buses and how they are used.
<span class=
"Apple-converted-space"> </span></p>
49 <p class=
"p4"><br></p>
50 <p class=
"p1">The hardware input busses begin just after the hardware output busses and can be read from using In.ar. (See
<span class=
"Apple-converted-space"> </span><a href=
"../../ServerArchitecture/Server-Architecture.html"><span class=
"s8">Server-Architecture
</span></a> for more details.) The number of hardware input and output busses can vary depending on your Server's options. For a convienent wrapper class which deals with this issue see
<a href=
"SoundIn.html"><span class=
"s9">SoundIn
</span></a>.
</p>
51 <p class=
"p4"><br></p>
52 <p class=
"p1">read from an audio bus
</p>
53 <p class=
"p4"><br></p>
54 <p class=
"p6"><span class=
"s10"><span class=
"Apple-tab-span"> </span></span>(
</p>
55 <p class=
"p6"><span class=
"Apple-tab-span"> </span>s =
<span class=
"s11">Server
</span>.local;
</p>
56 <p class=
"p6"><span class=
"Apple-tab-span"> </span>s.boot;
</p>
57 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
58 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
59 <p class=
"p6"><span class=
"Apple-tab-span"> </span>(
</p>
60 <p class=
"p8"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span><span class=
"s11">SynthDef
</span><span class=
"s3">(
</span>"help-PinkNoise"<span class=
"s3">, {
</span><span class=
"s11">arg
</span><span class=
"s3"> out=
0;
<span class=
"Apple-converted-space"> </span></span></p>
61 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s11">Out
</span>.ar(out,
<span class=
"s11">PinkNoise
</span>.ar(
0.1))
<span class=
"Apple-converted-space"> </span></p>
62 <p class=
"p6"><span class=
"Apple-tab-span"> </span>}).send(s);
</p>
63 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
64 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s11">SynthDef
</span>(
<span class=
"s12">"help-In"</span>, {
<span class=
"s11">arg
</span> out=
0, in=
0;
</p>
65 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s11">var
</span> input;
</p>
66 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>input =
<span class=
"s11">In
</span>.ar(in,
1);
</p>
67 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s11">Out
</span>.ar(out, input);
</p>
68 <p class=
"p7"><br></p>
69 <p class=
"p6"><span class=
"Apple-tab-span"> </span>}).send(s);
</p>
70 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
71 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
72 <p class=
"p9"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>//play noise on the right channel
</p>
73 <p class=
"p8"><span class=
"s3"><span class=
"Apple-tab-span"> </span>x =
</span><span class=
"s11">Synth
</span><span class=
"s3">(
</span>"help-PinkNoise"<span class=
"s3">, [
</span><span class=
"s13">\out
</span><span class=
"s3">,
1]);
</span></p>
74 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-converted-space"> </span></p>
75 <p class=
"p9"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>//read the input and play it out on the left channel
</p>
76 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s11">Synth
</span>.after(x,
<span class=
"s12">"help-In"</span>, [
<span class=
"s13">\out
</span>,
0,
<span class=
"s13">\in
</span>,
1]);
<span class=
"Apple-converted-space"> </span></p>
77 <p class=
"p7"><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 class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
78 <p class=
"p7"><br></p>
79 <p class=
"p1">read from a
<span class=
"Apple-converted-space"> </span>control bus
</p>
80 <p class=
"p7"><br></p>
81 <p class=
"p6"><span class=
"Apple-tab-span"> </span>(
</p>
82 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s11">SynthDef
</span>(
<span class=
"s12">"help-InKr"</span>,{
<span class=
"s11">arg
</span> out=
0, in=
0;
</p>
83 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s11">Out
</span>.ar(out,
</p>
84 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s11">SinOsc
</span>.ar(
<span class=
"s11">In
</span>.kr(in,
1),
0,
0.1)
</p>
85 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
86 <p class=
"p6"><span class=
"Apple-tab-span"> </span>}).send(s);
</p>
87 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s11">SynthDef
</span>(
<span class=
"s12">"help-lfo"</span>, {
<span class=
"s11">arg
</span> out=
0;
<span class=
"Apple-converted-space"> </span></p>
88 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s11">Out
</span>.kr(out,
<span class=
"s11">LFNoise1
</span>.kr(
0.3,
200,
800))
<span class=
"Apple-converted-space"> </span></p>
89 <p class=
"p6"><span class=
"Apple-tab-span"> </span>}).send(s);
</p>
90 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
91 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
92 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
93 <p class=
"p6"><span class=
"Apple-tab-span"> </span>b =
<span class=
"s11">Bus
</span>.control(s,
1);
</p>
94 <p class=
"p6"><span class=
"Apple-tab-span"> </span>b.set(
800);
</p>
95 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
96 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s11">Synth
</span>(
<span class=
"s12">"help-InKr"</span>,[
<span class=
"s13">\in
</span>, b]);
<span class=
"Apple-converted-space"> </span></p>
97 <p class=
"p6"><span class=
"Apple-tab-span"> </span>b.set(
400);
</p>
98 <p class=
"p6"><span class=
"Apple-tab-span"> </span>b.set(
300);
</p>
99 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s11">Synth
</span>(
<span class=
"s12">"help-lfo"</span>, [
<span class=
"s13">\out
</span>, b]);
</p>
100 <p class=
"p7"><br></p>
101 <p class=
"p1">read control data from a synth later in the node order
</p>
102 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
103 <p class=
"p6"><span class=
"Apple-tab-span"> </span>(
</p>
104 <p class=
"p8"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span><span class=
"s11">SynthDef
</span><span class=
"s3">(
</span>"help-Infreq"<span class=
"s3">, {
</span><span class=
"s11">arg
</span><span class=
"s3"> bus;
</span></p>
105 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s11">Out
</span>.ar(
0,
<span class=
"s11">FSinOsc
</span>.ar(
<span class=
"s11">In
</span>.kr(bus),
0,
0.5));
</p>
106 <p class=
"p6"><span class=
"Apple-tab-span"> </span>}).send(s);
</p>
107 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
108 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"s11">SynthDef
</span>(
<span class=
"s12">"help-Outfreq"</span>, {
<span class=
"s11">arg
</span> freq =
400, bus;
</p>
109 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s11">Out
</span>.kr(bus,
<span class=
"s11">SinOsc
</span>.kr(
1,
0, freq/
40, freq));
</p>
110 <p class=
"p6"><span class=
"Apple-tab-span"> </span>}).send(s);
</p>
111 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
112 <p class=
"p6"><span class=
"Apple-tab-span"> </span>b =
<span class=
"s11">Bus
</span>.control(s,
1);
</p>
113 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
114 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
115 <p class=
"p9"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// add the first control Synth at the tail of the default server; no audio yet
</p>
116 <p class=
"p6"><span class=
"Apple-tab-span"> </span>x =
<span class=
"s11">Synth
</span>.tail(s,
<span class=
"s12">"help-Outfreq"</span>, [
<span class=
"s13">\bus
</span>, b]);
</p>
117 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
118 <p class=
"p9"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// add the sound producing Synth BEFORE it; It receives x's data from the previous cycle
</p>
119 <p class=
"p6"><span class=
"Apple-tab-span"> </span>y =
<span class=
"s11">Synth
</span>.before(x,
<span class=
"s12">"help-Infreq"</span>, [
<span class=
"s13">\bus
</span>, b]);
</p>
120 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
121 <p class=
"p9"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// add another control Synth before y, at the head of the server
</p>
122 <p class=
"p9"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// It now overwrites x's cycle old data before y receives it
</p>
123 <p class=
"p6"><span class=
"Apple-tab-span"> </span>z =
<span class=
"s11">Synth
</span>.head(s,
<span class=
"s12">"help-Outfreq"</span>, [
<span class=
"s13">\bus
</span>, b,
<span class=
"s13">\freq
</span>,
800]);
</p>
124 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
125 <p class=
"p9"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// get another bus
</p>
126 <p class=
"p6"><span class=
"Apple-tab-span"> </span>c =
<span class=
"s11">Bus
</span>.control(s,
1);
</p>
127 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
128 <p class=
"p9"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// now y receives x's data even though z is still there
</p>
129 <p class=
"p6"><span class=
"Apple-tab-span"> </span>y.set(
<span class=
"s13">\bus
</span>, c); x.set(
<span class=
"s13">\bus
</span>, c);
</p>
130 <p class=
"p7"><span class=
"Apple-tab-span"> </span></p>
131 <p class=
"p6"><span class=
"Apple-tab-span"> </span>x.free; y.free; z.free;
</p>
132 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>