@@ -0,0 +1,20 @@
|
||||
import fractions
|
||||
import functools
|
||||
|
||||
import generator.rhythm
|
||||
|
||||
@functools.cache
|
||||
def library() -> generator.rhythm.Library:
|
||||
snippets = []
|
||||
for beats in (2, 3, 4, 5):
|
||||
bars = []
|
||||
for mask in range(1 << beats):
|
||||
events = tuple(generator.rhythm.Event(fractions.Fraction(i), fractions.Fraction(1), bool(mask & (1 << i)), 'quarter') for i in range(beats))
|
||||
bar = generator.rhythm.Bar(events, fractions.Fraction(beats))
|
||||
bars.append(bar)
|
||||
snippets.append(generator.rhythm.Snippet(f'{beats}-4/quarters/{mask}', f'{beats}/4', (bar,)))
|
||||
for phase in (0, 1):
|
||||
events = tuple(generator.rhythm.Event(fractions.Fraction(i, 2), fractions.Fraction(1, 2), i % 2 == phase, 'eighth') for i in range(beats * 2))
|
||||
snippets.append(generator.rhythm.Snippet(f'{beats}-4/eighths/{phase}', f'{beats}/4', (generator.rhythm.Bar(events, fractions.Fraction(beats)),)))
|
||||
snippets.append(generator.rhythm.Snippet(f'{beats}-4/pair', f'{beats}/4', (bars[1], bars[-1])))
|
||||
return generator.rhythm.Library(tuple(snippets))
|
||||
Reference in New Issue
Block a user