Hi Pedro,
Great example; I’ve run Python’s “black” on the code (to prettify it a bit), and added a main method:
import abjad
from abjadext import rmakers
def rest_selector(argument, first, period):
result = abjad.select.tuplets(argument)
result = abjad.select.get(result, [first], period)
result = result = [abjad.select.leaf(_, 0) for _ in result]
return result
def tie_selector(argument):
result = abjad.select.tuplets(argument)
result = abjad.select.get(result, [0], 1)
result = [abjad.select.leaf(_, -1) for _ in result]
return result
def make_stack(extra_counts, talea_count, first, period):
stack = rmakers.stack(
rmakers.talea(talea_count, 16, extra_counts=extra_counts),
rmakers.force_rest(lambda _: rest_selector(_, first, period)),
rmakers.beam(),
rmakers.tie(tie_selector),
rmakers.extract_trivial(),
)
return stack
def main():
divisions = [(3, 8), (5, 16), (1, 4), (3, 16)]
counts = [0, 1, 1]
talea_count = [1, 2, 3]
rhythmic_score = abjad.Score()
for i in range(8):
a, b = divisions.index((3, 8)), divisions.index((1, 4))
if a > b:
a, b = b, a
period = b - a
selections = make_stack(counts, talea_count, a, period)(divisions)
measure = abjad.Staff(
[abjad.mutate.copy(x) for x in selections],
name=f"voice_{i+1}",
lilypond_type="RhythmicStaff",
)
first_leaf = abjad.select.leaves(measure)[0]
ts = abjad.TimeSignature((9, 8))
abjad.attach(ts, first_leaf)
rhythmic_score.append(measure)
divisions = abjad.sequence.rotate(divisions, 1)
counts = abjad.sequence.rotate(counts, 1)
talea_count = abjad.sequence.rotate(talea_count, 1)
return rhythmic_score
if __name__ == "__main__":
rhythmic_score = main()
abjad.show(rhythmic_score)
Thanks for the modernized example, and happy composing with Abjad!
Trevor.
--
You received this message because you are subscribed to the Google Groups "abjad-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to abjad-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/abjad-user/2cf7d971-d7d0-4717-b9fd-14327b14dd0bn%40googlegroups.com.