-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathControl_buses.tex
73 lines (59 loc) · 3.02 KB
/
Control_buses.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
\section{Control Buses}
\label{sec:control-buses}
Earlier in this tutorial we talked about Audio Buses (section \ref{sec:audiobus}) and the Bus Object (section \ref{sec:busobject}). We chose to leave aside the topic of Control Buses at that time in order to focus on the concept of audio routing.
Control Buses in SuperCollider are for routing control signals, not audio. Except for this difference, there is no other practical or conceptual distinction between audio and control buses. You create and manage a control bus the same way you do with audio buses, simply using \texttt{.kr} instead of \texttt{.ar}. SuperCollider has 4096 control buses by default.
The first part of the example below uses an arbitrary bus number just for the sake of demonstration. The second part uses the Bus object, which is the recommended way of creating buses.
\begin{lstlisting}[style=SuperCollider-IDE, basicstyle=\scttfamily\footnotesize]
// Write a control signal into control bus 55
{Out.kr(55, LFNoise0.kr(1))}.play;
// Read a control signal from bus 55
{In.kr(55).poll}.play;
// Using the Bus object
~myControlBus = Bus.control(s, 1);
{Out.kr(~myControlBus, LFNoise0.kr(5).range(440, 880))}.play;
{SinOsc.ar(freq: In.kr(~myControlBus))}.play;
\end{lstlisting}
The next example shows a single control signal being used to modulate two different synths at the same time. In the \texttt{Blip} synth, the control signal is rescaled to control number of harmonics between 1 and 10. In the second synth, the same control signal is rescaled to modulate the frequency of the \texttt{Pulse} oscillator.
\begin{lstlisting}[style=SuperCollider-IDE, basicstyle=\scttfamily\footnotesize]
// Create the control bus
~myControl = Bus.control(s, 1);
// Feed the control signal into the bus
c = {Out.kr(~myControl, Pulse.kr(freq: MouseX.kr(1, 10), mul: MouseY.kr(0, 1)))}.play;
// Play the sounds being controlled
// (move the mouse to hear changes)
(
{
Blip.ar(
freq: LFNoise0.kr([1/2, 1/3]).range(50, 60),
numharm: In.kr(~myControl).range(1, 10),
mul: LFTri.kr([1/4, 1/6]).range(0, 0.1))
}.play;
{
Splay.ar(
Pulse.ar(
freq: LFNoise0.kr([1.4, 1, 1/2, 1/3]).range(100, 1000)
* In.kr(~myControl).range(0.9, 1.1),
mul: SinOsc.ar([1/3, 1/2, 1/4, 1/8]).range(0, 0.03))
)
}.play;
)
// Turn off control signal to compare
c.free;
\end{lstlisting}
\subsection{asMap}
In the next example, the method \texttt{asMap} is used to directly map a control bus to a running synth node. This way you don't even need \texttt{In.kr} in the synth definition.
\begin{lstlisting}[style=SuperCollider-IDE, basicstyle=\scttfamily\footnotesize]
// Create a SynthDef
SynthDef("simple", {arg freq = 440; Out.ar(0, SinOsc.ar(freq, mul: 0.2))}).add;
// Create control buses
~oneBus = Bus.control(s, 1);
~anotherBus = Bus.control(s, 1);
// Start controls
{Out.kr(~oneBus, LFSaw.kr(1).range(100, 1000))}.play;
{Out.kr(~anotherBus, LFSaw.kr(2, mul: -1).range(500, 2000))}.play;
// Start a note
x = Synth("simple", [\freq, 800]);
x.set(\freq, ~oneBus.asMap);
x.set(\freq, ~anotherBus.asMap);
x.free;
\end{lstlisting}