-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chain.sc
55 lines (51 loc) · 1.47 KB
/
Chain.sc
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
Chain {
var <>out;
var <>numCh;
var <>chain;
var <>bus;
var <group;
*new { arg out, numCh, chain;
^super.newCopyArgs(out, numCh, chain).init;
}
init {
this.createChain;
}
createChain {
group = Group.new();
bus = chain.size.collect{ Bus.audio(Server.default, numCh) };
chain = chain.collect{|i, idx|
case
{idx == 0} {
if(i.class == Array){
i.collect{|j|
Synth(j, [\in, bus[idx], \out, bus[idx + 1]], group, \addToHead)
}
}{
Synth(i, [\in, bus[idx], \out, bus[idx + 1]], group, \addToHead)
}
}
{idx == chain.size} {
if(i.class == Array){
i.collect{|j|
Synth(j, [\in, bus[idx], \out, out], group, \addToTail)
}
}{
Synth(i, [\in, bus[idx], \out, out], group, \addToTail)
}
}
{idx > 0} {
if(i.class == Array){
i.collect{|j|
Synth(j, [\in, bus[idx], \out, bus[idx + 1]], group, \addToTail)
}
}{
Synth(i, [\in, bus[idx], \out, bus[idx + 1]], group, \addToTail)
}
}
}
}
free {
group.free;
bus.do(_.free);
}
}