mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 19:23:59 +00:00
Merge adjacent rests
This commit is contained in:
parent
a7b2fab331
commit
b4204dd0e8
|
@ -706,6 +706,26 @@ void VLSong::AddNote(VLLyricsNote note, size_t measure, VLFraction at)
|
|||
i->fDuration = at-t;
|
||||
i = fMeasures[measure].fMelody.insert(++i, note);
|
||||
}
|
||||
if (i->fPitch == VLNote::kNoPitch) {
|
||||
//
|
||||
// Merge with adjacent rests
|
||||
//
|
||||
if (i != fMeasures[measure].fMelody.begin()) {
|
||||
VLNoteList::iterator j = i;
|
||||
--j;
|
||||
if (j->fPitch == VLNote::kNoPitch) {
|
||||
j->fDuration += i->fDuration;
|
||||
fMeasures[measure].fMelody.erase(i);
|
||||
i = j;
|
||||
}
|
||||
}
|
||||
VLNoteList::iterator j = i;
|
||||
++j;
|
||||
if (j != fMeasures[measure].fMelody.end() && j->fPitch == VLNote::kNoPitch) {
|
||||
i->fDuration += j->fDuration;
|
||||
fMeasures[measure].fMelody.erase(j);
|
||||
}
|
||||
}
|
||||
break; // Exit here
|
||||
}
|
||||
t = tEnd;
|
||||
|
@ -750,8 +770,14 @@ void VLSong::DelNote(size_t measure, VLFraction at)
|
|||
fMeasures[measure].fMelody.erase(i);
|
||||
} else {
|
||||
//
|
||||
// Turn into rest
|
||||
// Merge with next if it's a rest, otherwise, just turn into rest
|
||||
//
|
||||
VLNoteList::iterator j = i;
|
||||
++j;
|
||||
if (j != fMeasures[measure].fMelody.end() && j->fPitch == VLNote::kNoPitch) {
|
||||
i->fDuration += j->fDuration;
|
||||
fMeasures[measure].fMelody.erase(j);
|
||||
}
|
||||
i->fPitch = VLNote::kNoPitch;
|
||||
i->fTied = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user