cursor.addNote doesn't update internal segment reference
Triggered by the report in https://musescore.org/en/node/97556 we discovered that Cursor.addNote()
already moves the internal input position of the score to the next segment BUT it seems to not (correctly) update the internal segment reference of the Cursor itself.
Creating a score in 4/4 and adding 6 1/8ths using cursor.addNote
results in 6 subsequent notes (as expected), but leaves cursor.segment/measure/tick
as it was (tick remains at 0).
Alternatively, calling cursor.next
inbetween each addNote call (as is done in the exemplary random2.qml plugin) results in unexpected rests inbetween the added notes:
During creation the following was logged:
Debug: realMeasures: 2 Debug: Adding note 0 at beat 0 Debug: expand voice: found Rest 4/4 Debug: addClone Rest at 240 1/8 Debug: addClone Rest at 480 1/4 Debug: addClone Rest at 960 1/2 Debug: segment after addNote: Ms::Segment(0xb589fc0) measure: Ms::Measure(0x12478630) tick: 0 Debug: segment after next: Ms::Segment(0xb588c10) measure: Ms::Measure(0x12478630) tick: 240 Debug: Adding note 1 at beat 0.5 Debug: expand voice: found Rest 1/8 Debug: segment after addNote: Ms::Segment(0xb588c10) measure: Ms::Measure(0x12478630) tick: 240 Debug: segment after next: Ms::Segment(0xb588d00) measure: Ms::Measure(0x12478630) tick: 480 Debug: Adding note 2 at beat 1 Debug: expand voice: found Rest 1/4 Debug: reinstate at 720, 240 Debug: addClone Rest at 720 1/8 Debug: segment after addNote: Ms::Segment(0xb588d00) measure: Ms::Measure(0x12478630) tick: 480 Debug: segment after next: Ms::Segment(0xb588df0) measure: Ms::Measure(0x12478630) tick: 960 Debug: Adding note 3 at beat 2 Debug: expand voice: found Rest 1/2 Debug: addClone Rest at 1200 1/8 Debug: addClone Rest at 1440 1/4 Debug: segment after addNote: Ms::Segment(0xb588df0) measure: Ms::Measure(0x12478630) tick: 960 Debug: segment after next: Ms::Segment(0xb589ed0) measure: Ms::Measure(0x12478778) tick: 1920 Debug: Adding note 4 at beat 4 Debug: expand voice: found Rest 4/4 Debug: addClone Rest at 2160 1/8 Debug: addClone Rest at 2400 1/4 Debug: addClone Rest at 2880 1/2 Debug: segment after addNote: Ms::Segment(0xb589ed0) measure: Ms::Measure(0x12478778) tick: 1920 Debug: segment after next: Ms::Segment(0xb5801a0) measure: Ms::Measure(0x12478778) tick: 2160 Debug: Adding note 5 at beat 4.5 Debug: expand voice: found Rest 1/8 Debug: segment after addNote: Ms::Segment(0xb5801a0) measure: Ms::Measure(0x12478778) tick: 2160 Debug: segment after next: Ms::Segment(0xb5800b0) measure: Ms::Measure(0x12478778) tick: 2400
The defect seems related to the code having to 'reinstate', whatever that may be.
I think it might be as simple to fix as updating the _segment of Cursor at the end of addNote.
Comments
https://github.com/musescore/MuseScore/pull/2412
Fixed in branch master, commit 3ce4f22d27
fix #100181 update internal segment reference of cursor after addNote
update plugins after fixing input position in Cursor.addNote
added initial test run for cursor
Fixed in branch master, commit 386bb4f203
Merge pull request #2412 from jeetee/fix_cursor_addNote_cursor_position
Fix #100181 cursor addNote segment reference
Fixed in branch 2.0.3, commit b084f79c9c
fix #100181 update internal segment reference of cursor after addNote
update plugins after fixing input position in Cursor.addNote
added initial test run for cursor
Automatically closed -- issue fixed for 2 weeks with no activity.