-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChannel.io
44 lines (36 loc) · 1.2 KB
/
Channel.io
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
// Channel represents a mixer channel.
// Connection to patterns also done here.
Channel := Object clone do(
patternChain := nil
solo := false
mute := false
init := method(
self patternChain = PatternChain clone
)
// pattern setter/getter
// returns pattern
$ := method(
// change size if needed
if(self patternChain size != M maximumNumberOfPatternsPerChannel,
self patternChain setSize(M maximumNumberOfPatternsPerChannel)
)
selectedSlot := 0
firstArgType := call evalArgAt(0) type
// get slot number (if any)
if(firstArgType == "Number",
selectedSlot = call evalArgAt(0)
)
// for cases: $, $(n)
if(call message argCount < 2 and firstArgType == "Number" or firstArgType == "nil",
return self patternChain[selectedSlot]
)
patternStack := PatternStack clone
call message arguments foreach(item,
compiledItem := call sender doMessage(item)
// convert to pattern if the input is raw string
if(compiledItem type == "Sequence", compiledItem = compiledItem asPattern)
if(compiledItem type != "Number", patternStack append(compiledItem))
)
self patternChain atPut(selectedSlot, patternStack)
)
)