Further improvements in decomposition

This commit is contained in:
Matthias Neeracher 2009-03-14 23:04:25 +00:00
parent 3c4bf6eeb6
commit 9db3336ca6

View File

@ -437,6 +437,7 @@ void VLMeasure::DecomposeNotes(const VLProperties & prop, VLNoteList & decompose
const VLFraction kQuarterDur(1,4); const VLFraction kQuarterDur(1,4);
const VLFraction kEighthLoc(1,8); const VLFraction kEighthLoc(1,8);
const VLFraction kQuarTripLoc(1,6); const VLFraction kQuarTripLoc(1,6);
const VLFraction kMinDuration(1,4*prop.fDivisions);
VLFraction at(0); VLFraction at(0);
VLNoteList::const_iterator i = fMelody.begin(); VLNoteList::const_iterator i = fMelody.begin();
@ -451,18 +452,31 @@ void VLMeasure::DecomposeNotes(const VLProperties & prop, VLNoteList & decompose
VLLyricsNote c = *i; // Current note, remaining duration VLLyricsNote c = *i; // Current note, remaining duration
VLLyricsNote p = c; // Next partial note VLLyricsNote p = c; // Next partial note
VLFraction r(0);
do { do {
// //
// Start with longest possible note // Start with longest possible note
// //
p.MakeRepresentable(); p.MakeRepresentable();
// //
// Don't paint ourselves into a corner by leaving a non-representable
// remainder.
//
if (p.fDuration != c.fDuration && (c.fDuration-p.fDuration) % kMinDuration != 0) {
r += kMinDuration;
p.fDuration = c.fDuration-r;
continue;
}
//
// Don't try to further shrink a minimal note
//
if (p.fDuration == kMinDuration)
goto haveDuration;
//
// Prefer further triplets // Prefer further triplets
// //
if (prevTriplets) { if (prevTriplets) {
if (p.fDuration > 3*prevTripDur) { if (p.fDuration >= 2*prevTripDur) {
; // Not part of triplets
} else if (p.fDuration >= 2*prevTripDur) {
p.fDuration = 2*prevTripDur; p.fDuration = 2*prevTripDur;
if (prevTriplets == 1) { if (prevTriplets == 1) {
p.fVisual = prevVisual-1; p.fVisual = prevVisual-1;