-
Notifications
You must be signed in to change notification settings - Fork 5
/
Cues.sc
83 lines (66 loc) · 1.76 KB
/
Cues.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Cues {
var <>cueList, <>current, >hook;
var cueListRaw, <>liveReload = true;
var attachmentList;
var blockTrigger;
*new {
^super.new.init;
}
init {
current = 0;
cueList = Array.new;
cueListRaw = Array.new;
attachmentList = Array.new;
blockTrigger = BlockTriggerCP.new;
}
add { arg function, attachment;
cueList = cueList.add(function.asCueFunction);
cueListRaw = cueListRaw.add(function);
attachmentList = attachmentList.add(attachment);
}
put {arg cueNumber, function, attachment;
if(cueList.size < cueNumber) {
cueList = cueList.extend(cueNumber, nil);
cueListRaw = cueListRaw.extend(cueNumber, nil);
attachmentList = attachmentList.extend(cueNumber, nil);
};
cueListRaw[cueNumber - 1] = function;
attachmentList[cueNumber - 1] = attachment;
cueList[cueNumber - 1] = function.asCueFunction;
}
next { var currentFuncIndex;
currentFuncIndex = current;
if(blockTrigger.allow){
hook.value(this);
current = current + 1;
this.changed(\current);
if(liveReload) {this.reloadCue};
cueList[currentFuncIndex].value(this);
attachmentList[currentFuncIndex].value(this);
this.changed(\next);
^current;
}
}
trigger { arg cueNumber = 1;
cueNumber = cueNumber - 1;
this.setCurrent(cueNumber);
^this.next;
}
setCurrent {arg cueNumber;
/*("Next cue will be " ++ (cue + 1)).postln;*/
current = cueNumber.abs;
this.changed(\current);
^current;
}
getCueObject { arg cueNumber;
^cueList[cueNumber - 1];
}
reloadCue {
if(cueList[current].notNil){
cueList[current] = cueListRaw[current].asCueFunction;
}
}
blockTrigger { arg interval = 0.3;
blockTrigger.interval = interval;
}
}