-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcanto live automation.scd
65 lines (63 loc) · 1.76 KB
/
canto live automation.scd
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
(
e.faderAuto = Order();
e.faderAutoEnabled = true;
e.faderAutoWaitTime = 0.5;
e.actions[ \touch ][ \all ] = { |sl,val,i|
//[ val, i, Process.elapsedTime ].postln;
if( e.faderAuto[ i ].isNil ) {
e.faderAuto[ i ] = ();
};
if( val.asInt == 1 ) { // touch down
if( e.faderAuto[i].task.isNil or: { e.faderAuto[i].task.isPlaying.not } ) {
if( e.faderAuto[i].lastClick.isNil ) {
e.faderAuto[i].lastClick = Process.elapsedTime;
} {
if( (Process.elapsedTime - e.faderAuto[i].lastClick)
.inclusivelyBetween(0.2, e.faderAutoWaitTime).not ) {
e.faderAuto[i].lastClick = Process.elapsedTime; // ignore
} {
// start recording
e.faderAuto[i].lastClick = nil;
e.faderAuto[i].timeValuePairs = [];
e.faderAuto[i].recording = true;
"recording %\n".postf( i );
}
};
} {
e.faderAuto[i].task.stop;
e.faderAuto[i].task = nil;
e.faderAuto[i].lastClick = nil;
};
} { // touch up
if( e.faderAuto[i].recording == true ) {
e.faderAuto[i].recording = false;
"ended recording %\n".postf( i );
e.faderAuto[i].task.stop;
if( e.faderAuto[i].timeValuePairs.size > 0 ) {
e.faderAuto[i].task = Task({
var lastTime;
loop {
lastTime = e.faderAuto[i].timeValuePairs[0];
e.faderAuto[i].timeValuePairs.pairsDo({ |time, value|
(time - lastTime).wait;
lastTime = time;
e.sliders[i].valueAction = value;
});
};
}).start;
"started playing %\n".postf( i );
} {
e.faderAuto[i].task = nil;
};
};
};
};
e.actions.slider[ \all ] = { |sl, i|
if( e.faderAutoEnabled == true ) {
if( e.faderAuto[i].notNil && { e.faderAuto[i].recording == true }) {
e.faderAuto[i].timeValuePairs = e.faderAuto[i].timeValuePairs
.addAll( [ Process.elapsedTime, sl.value ] );
};
};
};
)