-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpz_beat_machine.sc
More file actions
executable file
·93 lines (77 loc) · 1.89 KB
/
Copy pathpz_beat_machine.sc
File metadata and controls
executable file
·93 lines (77 loc) · 1.89 KB
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
84
85
86
87
88
89
90
91
92
93
//// PZ Beat machine 2021 v0.2
/// changelog: PZ_layer now supports 6 args
/*
Class for custom functional beat machine
*/
//////////////////////////////
PZ_machine {
var <>beats=4, <>server=nil, <>routine;
*new {arg server;
^super.new.init(server);
}
init {arg server;
this.server = server;
this.routine = TaskProxy.new;
this.routine.play;
}
ignite {arg server=this.server, beats=this.beats;
this.routine.source = {
inf.do{
server.bind{
// audio
~funcs.do{|f| f.(); };
};
(this.beats).wait;
}
}
}
}
PZ_layer {
classvar <>maxsubdiv=12, <>debug=false;
var <>item=nil, <>itemargs=nil, <>debug=false;
*new {arg ... args;
^super.new.init(args[0], args);
}
init {arg ... args;
this.item = args[0];
this.itemargs = args;
}
rhythm {arg ... args;
var beats=args;
// beats.postln;
^Routine{
if (debug) {
item.postln; beats.asString.postln;
"******".postln;
itemargs.postln;
"******".postln;
};
beats.do{arg beat, index;
if (beat.isArray.not) { // single:
if (beat > 0) {
if (debug) {(index.asString ++ " = " ++ beat.asString).postln;};
(beat.reciprocal.clip(1, maxsubdiv)).do{
item.(itemargs[1][1], itemargs[1][2], itemargs[1][3], itemargs[1][4], itemargs[1][5], itemargs[1][6]);
(beat.clip(maxsubdiv.reciprocal, 1)).wait;
};
} {1.wait};
} { // array:
{
beat.do{arg sub;
if (sub > 0) {
if (debug) {(beat.asString ++ " = " ++ beat.asString ++ sub.asString).postln;};
((sub).clip(1, maxsubdiv)).do{
item.(itemargs[1][1], itemargs[1][2], itemargs[1][3], itemargs[1][4],itemargs[1][5], itemargs[1][6]);
if (sub == 1) {
(sub/beat.size).wait;
} {(beat.size.reciprocal/sub).wait;}
}} {(beat.size.reciprocal).wait;}
};
(beat.size.reciprocal).wait;
}.fork;
1.wait;
};
};
}.play;
}
}