2 summary:: Read a signal from a bus.
3 related:: Classes/InFeedback, Classes/LagIn, Classes/AudioIn
4 categories:: UGens>InOut
9 In.ar and In.kr read signals from audio and control buses, respectively. (See the link::Tutorials/Getting-Started/11-Busses##Busses:: chapter of the link::Tutorials/Getting-Started/00-Getting-Started-With-SC##Getting Started:: tutorial series for details on buses.)
11 In.ar and In.kr behave slightly differently with respect to signals left on the bus in the previous calculation cycle.
13 In.ar can access audio signals that were generated in the current calculation cycle by Synth nodes located earlier in the node tree (see link::Guides/Order-of-execution::). It does not read signals left on an audio bus from the previous calculation cycle. If synth A reads from audio bus 0 and synth B writes to audio bus 0, and synth A is earlier than synth B, In.ar in synth A will read 0's (silence). This is to prevent accidental feedback. link::Classes/InFeedback:: supports audio signal feedback.
15 In.kr is for control buses. Control signals may be generated by Synth nodes within the server, or they may be set by the client and expected to hold steady. Therefore, In.kr does not distinguish between "new" and "old" data: it will always read the current value on the bus, whether it was generated earlier in this calculation cycle, left over from the last one, or set by the client.
17 Note that using the link::Classes/Bus:: class to allocate a multichannel bus simply
18 reserves a series of adjacent bus indices with the link::Classes/Server:: object's bus
19 allocators. code::abus.index:: simply returns the first of those indices.
21 When using a Bus with an In or link::Classes/Out:: UGen there is nothing to
22 stop you from reading to or writing from a larger range, or from
23 hardcoding to a bus that has been allocated. You are responsible for
24 making sure that the number of channels match and that there are no
25 conflicts. See the link::Reference/Server-Architecture:: and link::Classes/Bus:: helpfiles for more
26 information on buses and how they are used.
29 The hardware input busses begin just after the hardware output busses and
30 can be read from using In.ar (See link::Reference/Server-Architecture:: for more
31 details). The number of hardware input and output busses can vary
32 depending on your Server's options. For a convienent wrapper class which
33 deals with this issue see link::Classes/SoundIn:: .
42 The index of the bus to read in from.
47 The number of channels (i.e. adjacent buses) to read in. You
48 cannot modulate this number by assigning it to an argument in a
54 read from an audio bus:
62 SynthDef("help-PinkNoise", { arg out=0;
63 Out.ar(out, PinkNoise.ar(0.1))
66 SynthDef("help-In", { arg out=0, in=0;
74 //play noise on the right channel
75 x = Synth("help-PinkNoise", [\out, 1]);
77 //read the input and play it out on the left channel
78 Synth.after(x, "help-In", [\out, 0, \in, 1]);
81 read from a control bus:
84 SynthDef("help-InKr",{ arg out=0, in=0;
86 SinOsc.ar(In.kr(in, 1), 0, 0.1)
89 SynthDef("help-lfo", { arg out=0;
90 Out.kr(out, LFNoise1.kr(0.3, 200, 800))
98 Synth("help-InKr",[\in, b.index]);
101 Synth("help-lfo", [\out, b.index]);
104 read control data from a synth later in the node order:
107 SynthDef("help-Infreq", { arg bus;
108 Out.ar(0, FSinOsc.ar(In.kr(bus), 0, 0.5));
111 SynthDef("help-Outfreq", { arg freq = 400, bus;
112 Out.kr(bus, SinOsc.kr(1, 0, freq/40, freq));
115 b = Bus.control(s,1);
118 // add the first control Synth at the tail of the default server; no audio yet
119 x = Synth.tail(s, "help-Outfreq", [\bus, b.index]);
121 // add the sound producing Synth BEFORE it; It receives x's data from the previous cycle
122 y = Synth.before(x, "help-Infreq", [\bus, b.index]);
124 // add another control Synth before y, at the head of the server
125 // It now overwrites x's cycle old data before y receives it
126 z = Synth.head(s, "help-Outfreq", [\bus, b.index, \freq, 800]);
129 c = Bus.control(s, 1);
131 // now y receives x's data even though z is still there
132 y.set(\bus, c.index); x.set(\bus, c.index);
134 x.free; y.free; z.free;