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
Following #380, @sildater suggested opening an issue for that, even if the ScoreVariant class does not seem public looking at its doc.
I was trying to manually split a score into multiple chunks of a few measures, which was in good progress, but I was suggested the object ScoreVariant that would do exactly what I wanted to do.
However, while it does work for some measures, some others seem to cause issues, like the measure 9 of a Rachmaninoff piece:
Manual extraction of measure 9 (working):
Automatic extraction of measure 9 using ScoreVariant (bugged):
After some investigations, I managed to track down what the issue was. When creating the new part with this score, it seems that the ScoreVariant objects creates it with part._quarter_durations set to [1] by default, while the original part has it set to [120]. Setting it manually using the part.quarter_duration_map method seems to fix the problem.
It's weird that the ScoreVariant does not take care of this by itself, as it seems that its create_variant_part method does play with the quarter durations (although I did not investigate further).
You can generate both versions with the following script:
frompathlibimportPathimportpartituraasptimportpartitura.scoreSCORE_PATH=Path('/home/user/nasap-dataset/Rachmaninoff/Preludes_op_32/5/xml_score.musicxml')
START_MEASURE=8END_MEASURE=10OUT_DIR=Path("/tmp") /SCORE_PATH.namescore=pt.load_musicxml(SCORE_PATH)
assertlen(score.parts) ==1part=score.parts[0]
OUT_DIR.mkdir(exist_ok=True)
# Get the asked measuresstart_measure: pt.score.Measure=part.measures[START_MEASURE-1]
end_measure: pt.score.Measure=part.measures[END_MEASURE-1]
print(f"Start measure: {start_measure}")
print(f"End measure: {end_measure}")
# Create a new ScoreVariantsv=pt.score.ScoreVariant(part)
sv.add_segment(start_measure.start, end_measure.end)
new_part=sv.create_variant_part()
# See the difference between the quarter durations of the original and new partprint(f"{part._quarter_durations=}")
print(f"{new_part._quarter_durations=}")
# Save the new part without adapting the quarter durationspt.save_musicxml(new_part, OUT_DIR/f"M{START_MEASURE}-{END_MEASURE}_naive.musicxml")
# Manually fix the quarter durations and save the new versionnew_part.set_quarter_duration(0, part.quarter_duration_map(start_measure.start.t))
pt.save_musicxml(new_part, OUT_DIR/f"M{START_MEASURE}-{END_MEASURE}_fixed.musicxml")
EDIT: You can find another example of this issue in measure 26 of Bach/Fugue/bwv_857 in the ASAP dataset.
The text was updated successfully, but these errors were encountered:
Following #380, @sildater suggested opening an issue for that, even if the
ScoreVariant
class does not seem public looking at its doc.I was trying to manually split a score into multiple chunks of a few measures, which was in good progress, but I was suggested the object
ScoreVariant
that would do exactly what I wanted to do.However, while it does work for some measures, some others seem to cause issues, like the measure 9 of a Rachmaninoff piece:
Manual extraction of measure 9 (working):
Automatic extraction of measure 9 using
ScoreVariant
(bugged):After some investigations, I managed to track down what the issue was. When creating the new part with this score, it seems that the
ScoreVariant
objects creates it withpart._quarter_durations
set to[1]
by default, while the original part has it set to[120]
. Setting it manually using thepart.quarter_duration_map
method seems to fix the problem.It's weird that the
ScoreVariant
does not take care of this by itself, as it seems that itscreate_variant_part
method does play with the quarter durations (although I did not investigate further).You can generate both versions with the following script:
EDIT: You can find another example of this issue in measure 26 of Bach/Fugue/bwv_857 in the ASAP dataset.
The text was updated successfully, but these errors were encountered: