-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMetro.sc
67 lines (43 loc) · 1.3 KB
/
Metro.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
/*
//////////////////////////////////////////////////
// Metro.sc //
// //
// A Metronome with support for changing tempos //
//////////////////////////////////////////////////
USAGE:
m = Metron([[120, 4], [90, 4], [60, 4]]);
m.play;
m.stop;
*/
Metron {
var <>array, routine;
*new { arg thisArray;
^super.new.init(thisArray);
}
init { arg thisArray = [[120, 4], [80, 3], [60, 3], [40, 2], [70, 3], [140,6]];
array = thisArray;
SynthDef("impulse", {
Out.ar(0,
EnvGen.kr(Env.perc, 0.2, doneAction: 2) *
0.3 *
SinOsc.ar([59.99, 60.01].midicps.dup)
)
}).add;
routine = Routine({
array.do({arg i;
Tempo.bpm_(i[0]);
i[1].do({ arg i;
[i,BeatSched.beat].postln;
Synth(\impulse);
Tempo.beats2secs(1).wait;
});
});
});
}
play {
SystemClock.play(routine);
}
stop {
SystemClock.stop(routine);
}
}