Support tuplet annotations
We don't have any built-in support for tuplets. Users can manually construct these using MusicText (for plain number/ratio annotations) and in combination with a Path (for brackets), but it's a bit tricky and tedious to get everything aligned right.
We should add a built-in class, something like Tuplet(Spanner), which:
- Allows optionally adding a bracket which can point up or down
- Supports simple number values and colon ratios (
2:3) - If it's not too awkward, it would be nice to also support notehead-value-style annotations like
2:3[eighth note glyph]
Maybe the init signature would look something like
class Tuplet(Spanner):
def __init__(self, pos, parent, end_pos, end_parent, ratio_text,
include_bracket=True, bracket_dir=DirectionY.DOWN):
...
where ratio_text could accept strings like 2:3 and automatically map the characters to their SMuFL counterparts (
see https://w3c.github.io/smufl/latest/tables/tuplets.html).
See OctaveLine for a spanner which is represented by a child Path and MusicText, and TabNumber for a class which converts an input value character-wise to SMuFL glyphs.
@craigvear maybe you deleted this comment, but it's not a bad idea..
Instead of a Spanner format init as suggested above, could it not be based on a BeamGroup design and take in a list of ChordRests? This way we can get it to follow the contour of the stems.
I recommend splitting the difference by making two classes, one a dumb Tuplet(Spanner) as described above, and another smarter one as you suggest.
this way tuplet spanners can be used outside the chordrest context. In any case, I recommend at least starting with the simple, dumb spanner and merging that first so we can have a clearly working base to build smarter things on. The bare tuplet spanner alone already has enough nuances as it is.
Released in 0.1.8