/
extEveryPattern.sc
63 lines (52 loc) · 1.13 KB
/
extEveryPattern.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
/*
Pattern and Array extension to describe changes after n repeats.
*Inspired* by Tidal by Alex McLean. Is not a port.
Example:
(
Pbind(
\octave, [3,4,5],
\legato, 0.5,
\scale, Scale.minorPentatonic,
\degree, Place([0,[2,1]], 2).andEvery(3, Pwhite(4,8,8)),
\dur, [1,1,1,1].andEvery(3, [1,1,0.5,0.5,0.5,0.5]) / 4
).play
)
*/
+ SequenceableCollection {
andEvery { |num, new, repeats=inf, typeA, typeB|
var patB;
var pTypeB = typeB ? Pseq;
var pTypeA = typeA ? Pseq;
if ( new.isKindOf(Pattern) ) {
patB = new;
} {
patB = pTypeB.new(new);
};
^Pseq([ Pn(pTypeA.new(this), num ), patB ], repeats);
}
}
+ SimpleNumber {
andEvery { |num, new, repeats=inf, typeA, typeB|
var patB;
var pTypeB = typeB ? Pseq;
var pTypeA = typeA ? Pseq;
if ( new.isKindOf(Pattern) ) {
patB = new;
} {
patB = pTypeB.new(new);
};
^Pseq([ Pn(pTypeA.new([this]), num ), patB ], repeats);
}
}
+ Pattern {
andEvery { |num, new, repeats=inf, typeB|
var patB;
var pTypeB = typeB ? Pseq;
if ( new.isKindOf(Pattern) ) {
patB = new;
} {
patB = pTypeB.new(new);
};
^Pseq([ Pn(this, num), patB ], repeats);
}
}