You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the text of the PR that added segments and variable unfolding to partitura. It is copied here for future reference.
This PR contains the following new things in partitura.score.py:
class Segment(TimedObject): a segment of a part between two time points that are relevant to the repetition structure
add_segments(part): a function adding segments to a part based on existing TimedObjects: Repeat, Ending, DaCapo, DalSegno, Segno, AlCoda, Coda, Fine
get_segments(part): returns a dict of segments indexed by segment ID
pretty_segments(part): creates a pretty string describing the segments of a part
class Path: a Path object encodes a sequence of segments and utility needed to extend that sequence, if it hasn't reached an end of the part.
unfold_paths(*args): recursively unfold and multiply a Path into all possible Paths and store these in a list
get_paths(part, *args): call unfold_paths with the starting segment Path and return the resulting paths as parametrized (for options, see below)
new_part_from_path(*args): create a new part from a Path
new_scorevariant_from_path(*args): create a new ScoreVariant from a Path
Updated functions from which now use the new unfolding:
iter_unfolded_parts(*args): iterator over all unfolded parts
unfolded_part_maximal(*args): returns the longest unfolded part
unfolded_part_alignment(*args): returns the unfolded part that best fits the note IDs in an alignment
make_score_variants(*args): creates a list of ScoreVariant objects
Why?
Theses changes solve limit cases of unfolding/segmentation:
Volta brackets with >2 endings are supported
Nested repeats are supported
Other navigation marks (segno, coda, capo, fine) are supported
Additionally, the changes make the following possible:
get all unfoldings with some specific constraints:
all!
the longest!
the longest without repeats after a jump mark (dal segno, al cado, da capo)
all without repeats after a jump mark (dal segno, al cado, da capo)
the shortest
create any unfolding:
pick any segment(s) you like from the list of segments (print(partitura.score.pretty_segments(part)) for an overview)
add them to a path p = Path(["C","K","&",...], segments)
create a new part from this path new_part = new_part_from_path(p, part)
get informative strings about segments and paths:
as above: print(partitura.score.pretty_segments(part))
for paths use print(path) or print(path.pretty())
How?
The Segments add information about the structure and the possible jumps from every segment to the part.
The Path parses this tree of possible unfoldings (with constraints, if desired).
The ScoreVariant creates a variant of the score based on the list of of segment IDs stored (or possibly computed) in a Path.
Other Bits and Fixes:
load_musicxml: correct parsing of location attribute of barline tag
load_musicxml: correct parsing of navigation markers (Da Capo, Al Segno, Segno, Al Coda, Coda, Fine)
score.py: TimedObject subclasses for navigation markers
ScoreVariant.create_variant_part(): Ignore the following score elements for the new part: Repeat, Ending, ToCoda, DaCapo, DalSegno, Segment, Page, System
ScoreVariant.create_variant_part(): Check for previous clefs before adding new clef element
modified the unfolding unittest and added a new more complex test for unfolding with jumps and three Volta brackets
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This is the text of the PR that added segments and variable unfolding to partitura. It is copied here for future reference.
This PR contains the following new things in partitura.score.py:
class Segment(TimedObject)
: a segment of a part between two time points that are relevant to the repetition structureadd_segments(part)
: a function adding segments to a part based on existing TimedObjects: Repeat, Ending, DaCapo, DalSegno, Segno, AlCoda, Coda, Fineget_segments(part)
: returns a dict of segments indexed by segment IDpretty_segments(part)
: creates a pretty string describing the segments of a partclass Path
: a Path object encodes a sequence of segments and utility needed to extend that sequence, if it hasn't reached an end of the part.unfold_paths(*args)
: recursively unfold and multiply a Path into all possible Paths and store these in a listget_paths(part, *args)
: call unfold_paths with the starting segment Path and return the resulting paths as parametrized (for options, see below)new_part_from_path(*args)
: create a new part from a Pathnew_scorevariant_from_path(*args)
: create a new ScoreVariant from a PathUpdated functions from which now use the new unfolding:
iter_unfolded_parts(*args)
: iterator over all unfolded partsunfolded_part_maximal(*args)
: returns the longest unfolded partunfolded_part_alignment(*args)
: returns the unfolded part that best fits the note IDs in an alignmentmake_score_variants(*args)
: creates a list of ScoreVariant objectsWhy?
Theses changes solve limit cases of unfolding/segmentation:
Additionally, the changes make the following possible:
print(partitura.score.pretty_segments(part))
for an overview)p = Path(["C","K","&",...], segments)
new_part = new_part_from_path(p, part)
print(partitura.score.pretty_segments(part))
print(path)
orprint(path.pretty())
How?
The Segments add information about the structure and the possible jumps from every segment to the part.
The Path parses this tree of possible unfoldings (with constraints, if desired).
The ScoreVariant creates a variant of the score based on the list of of segment IDs stored (or possibly computed) in a Path.
Other Bits and Fixes:
load_musicxml
: correct parsing of location attribute of barline tagload_musicxml
: correct parsing of navigation markers (Da Capo, Al Segno, Segno, Al Coda, Coda, Fine)score.py
: TimedObject subclasses for navigation markersScoreVariant.create_variant_part()
: Ignore the following score elements for the new part: Repeat, Ending, ToCoda, DaCapo, DalSegno, Segment, Page, SystemScoreVariant.create_variant_part()
: Check for previous clefs before adding new clef elementpart.measure_number_map
herepart.measure_number_map
Beta Was this translation helpful? Give feedback.
All reactions