Implement smart voice selection for implode#32829
Implement smart voice selection for implode#32829CubikingChill wants to merge 1 commit intomusescore:masterfrom
Conversation
26a47b1 to
fba3966
Compare
fba3966 to
1d4cca9
Compare
|
I ve tested the binary and to me it works great. At the moment there are substantial changes regarding the reference score. Thus I suggest that we test the actual behaviour first. Attached with a brief summery on changes made to test files. |
Test Reference File Changes for Implode FixOverviewThe test reference files What Changed in the Implode BehaviorOld Behavior (Before Fix)
New Behavior (After Fix)
File 1: undoImplodeVoice01-ref.mscxTest ScenarioThis test implodes a staff with:
Changes MadeChange 1: Explicit Track Tags (Measure 2, Voice 3 → Voice 1)Location: Lines 269-283 What happened: When the Ab note from voice 3 (track 2) was moved to voice 1 (track 0), explicit Before: <Chord>
<eid>o_o</eid>
<durationType>quarter</durationType>
<Note>
<eid>p_p</eid>
<Accidental>
<subtype>accidentalFlat</subtype>
<eid>q_q</eid>
</Accidental>
<pitch>68</pitch>
<tpc>10</tpc>
</Note>
</Chord>After: <Chord>
<eid>o_o</eid>
<track>0</track>
<durationType>quarter</durationType>
<Note>
<eid>p_p</eid>
<track>0</track>
<Accidental>
<subtype>accidentalFlat</subtype>
<eid>q_q</eid>
<track>0</track>
</Accidental>
<pitch>68</pitch>
<tpc>10</tpc>
</Note>
</Chord>Why: The Change 2: Added Rests for Voices 2 and 3 (Measure 3)Location: Lines 323-356 What happened: After imploding all notes into voice 1, voices 2 and 3 now contain rests for the second half of measure 3. Before: </Rest>
</voice>
</Measure>
<Measure>
<eid>w_w</eid>
<voice>
<Chord>
<eid>x_x</eid>After: </Rest>
</voice>
<voice>
<location>
<fractions>1/2</fractions>
</location>
<Rest>
<eid>w_w</eid>
<durationType>half</durationType>
</Rest>
</voice>
<voice>
<location>
<fractions>1/2</fractions>
</location>
<Rest>
<eid>x_x</eid>
<durationType>half</durationType>
</Rest>
</voice>
</Measure>
<Measure>
<eid>y_y</eid>
<voice>
<Chord>
<eid>z_z</eid>Why: In MuseScore, when a measure has multiple voices, each voice must have content for the full duration of the measure. After implode moves all notes to voice 1, voices 2 and 3 are filled with rests. The Change 3: Element ID (EID) Shifts (Measure 4)Location: Lines 324-355 What happened: Element IDs shifted because new rest elements were inserted. Before: <Measure>
<eid>w_w</eid>
<voice>
<Chord>
<eid>x_x</eid>
<durationType>half</durationType>
<Note>
<eid>y_y</eid>
<pitch>64</pitch>
...
</Note>
<Note>
<eid>z_z</eid>
<pitch>67</pitch>
...
</Note>
<Note>
<eid>0_0</eid>
<pitch>72</pitch>
...
</Note>
</Chord>
<Rest>
<eid>1_1</eid>
<durationType>half</durationType>
</Rest>
<BarLine>
<subtype>end</subtype>
<span>1</span>
<eid>2_2</eid>
</BarLine>After: <Measure>
<eid>y_y</eid>
<voice>
<Chord>
<eid>z_z</eid>
<durationType>half</durationType>
<Note>
<eid>0_0</eid>
<pitch>64</pitch>
...
</Note>
<Note>
<eid>1_1</eid>
<pitch>67</pitch>
...
</Note>
<Note>
<eid>2_2</eid>
<pitch>72</pitch>
...
</Note>
</Chord>
<Rest>
<eid>3_3</eid>
<durationType>half</durationType>
</Rest>
<BarLine>
<subtype>end</subtype>
<span>1</span>
<eid>4_4</eid>
</BarLine>Why: EIDs (Element IDs) are sequential identifiers assigned to each element in the score. When new elements (the rests in voices 2 and 3) are inserted, all subsequent elements get new IDs. The EIDs shifted by 2 because two new rest elements were added (w_w and x_x for voices 2 and 3). Change 4: Added Rests for Voices 2 and 3 (Measure 4)Location: Lines 377-396 What happened: Similar to measure 3, measure 4 also needs rests for voices 2 and 3 after implode. Added: <voice>
<location>
<fractions>1/2</fractions>
</location>
<Rest>
<eid>5_5</eid>
<durationType>half</durationType>
</Rest>
</voice>
<voice>
<location>
<fractions>1/2</fractions>
</location>
<Rest>
<eid>6_6</eid>
<durationType>half</durationType>
</Rest>
</voice>Why: Same reason as measure 3 - all voices must have content for the full measure duration. File 2: undoImplodeVoice02-ref.mscxTest ScenarioThis test is more complex - it implodes a staff with all 3 voices containing notes:
After implode, all notes should merge into voice 1. Changes MadeChange: Massive EID RenumberingLocation: Throughout the entire file (86 changes) What happened: Because this test involves 3 voices with many elements, and the ExchangeVoice operation creates new undo commands, the element IDs get completely renumbered. Pattern of Changes: Measure 1, Voice 2 (originally voice 2, stays voice 2 after undo):
Measure 1, Voice 3 (originally voice 3, stays voice 3 after undo):
Measure 2, Voice 2:
Measure 2, Voice 3:
Measure 3, Voice 2:
Measure 3, Voice 3:
Measure 4, Voice 2:
Measure 4, Voice 3:
Why the massive renumbering? This test file tests the undo operation after implode. Here's what happens:
The new implode implementation uses The EID changes don't affect functionality - they're just internal identifiers. What matters is that the structure (notes, pitches, durations, voices) remains correct after undo. Summary of ChangesundoImplodeVoice01-ref.mscx
undoImplodeVoice02-ref.mscx
Key changes in measures 3-4:
Technical DetailsWhat are EIDs?EIDs (Element IDs) are unique identifiers assigned to every element in a MuseScore file. They follow a pattern like
EIDs are not part of the musical content - changing them doesn't affect how the score sounds or looks. What are Track Tags?In MuseScore's XML format:
Track tags are usually omitted when an element is in its "natural" voice. They're explicitly added when:
Why Add Rests to Empty Voices?MuseScore requires that all active voices in a measure have content for the full measure duration. This is a fundamental rule of the notation engine:
How to Verify These ChangesYou can verify the changes are correct by:
Related Code ChangesThese test reference file updates correspond to the code changes in:
|
|
Closing because the code was not tested before contributing, because this AI slop is unacceptable and a genuine understanding of the code changes would have just needed a few words summary, because it's not worth using gotos to exit two loops, and because the issue needs to be discussed as it could be argued whether the rests in voice one should be kept or not when merging. See also #32755 (comment) |
|
Thank you very much for your review. Apparently for this PR I don't really know what I was doing. Please have a look at #32862 |
Resolves: #32830