Closed synchronisator closed 1 year ago
To be more specific. This is only a problem with multiple ties in the same voice! I just looked at the code to find the problem and it seems to be here: lib/src/part.dart:58
if (currentNote.isNoteOn) {
tiedNotes[currentNote.voice] = {
currentNote.pitch!.value: [currentNote],
};
}
Tied Notes are seperated by voice. But in my case there are two notes in the same voice, starting a tie.
The second note overrides the content in the tiedNotes Array, so the following
final notes = tiedNotes[currentNote.voice]?[currentNote.pitch!.value];
Cant find the first note.
I am not sure how to solve this, but i think this is the problem.
I think the Problem can be solved, adding new pitches to the Map:
Current code:
// If note is note on, create a new entry in tiedNotes
if (currentNote.isNoteOn) {
tiedNotes[currentNote.voice] = {
currentNote.pitch!.value: [currentNote],
};
}
Bugfix:
// If note is note on, create a new entry in tiedNotes
if (currentNote.isNoteOn) {
if(!tiedNotes.containsKey(currentNote.voice)){
tiedNotes[currentNote.voice] = {};
}
tiedNotes[currentNote.voice]!.putIfAbsent(currentNote.pitch!.value, () => [currentNote]);
}
In my testcase this is working, but i cant say if the outcome of this method is still correct. Maybe someone else could verify this solution.
Thanks
fixed at #9
Hi,
i tried to use your library and found an issue with more than one tie.
The music xml is this:
When parsing this i got:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:music_xml/src/part.dart': Failed assertion: line 66 pos 18: 'notes != null': is not true.
It works if i remove
and
from the notes 2 and 4