{
if (musicScore == null)
return;
int notes = musicScore.getTotalNotes();
MusicScoreNote scoreNote;
Note note;
JoinedNotes topJoinedNotes = null;
JoinedNotes bottomJoinedNotes = null;
Bar bar = null;
int channel;
int midiNote;
int measure;
for (int i = 0;i < notes;i ++)
{
scoreNote = musicScore.getNote(i);
if (scoreNote.isBar())
{
if (bar != null)
musicCanvas.addBar(bar);
bar = new Bar();
topJoinedNotes = bottomJoinedNotes = null;
}
else if (bar != null)
{
channel = scoreNote.getChannel();
midiNote = scoreNote.getMidiNote();
measure = scoreNote.getMeasure();
note = null;
if ((midiNote > 0) && (midiNote < 127) &&
((measure == 1) || (measure == 2) || (measure == 4) || (measure == 8) || (measure == 16)))
{
if (channel == 0)
{
note = new Note(0);
if (scoreNote.getBeamToNextNote() != 0)
{
if (bottomJoinedNotes == null)
{
bottomJoinedNotes = new JoinedNotes();
musicCanvas.addJoinedNotes(bottomJoinedNotes, true);
}
bottomJoinedNotes.addNote(note);
}
else if (bottomJoinedNotes != null)
{
bottomJoinedNotes.addNote(note);
bottomJoinedNotes = null;
}
else
musicCanvas.addNote(note, true);
}
else if (channel == 1)
{
note = new Note(1);
if (scoreNote.getBeamToNextNote() != 0)
{
if (topJoinedNotes == null)
{
topJoinedNotes = new JoinedNotes();
musicCanvas.addJoinedNotes(topJoinedNotes, false);