X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fcompletion-note-heads-engraver.cc;h=59b47ab5252a244e6c715cbbcc51ea8827fbed06;hb=74e906db27770282e2d3c180298e5968ebff9360;hp=3e507ec8862723aecca477bdc09517ed3432d3c8;hpb=e18531db1f79fb685fbd16d6a2a67bf4b6c09915;p=lilypond.git diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc index 3e507ec886..59b47ab525 100644 --- a/lily/completion-note-heads-engraver.cc +++ b/lily/completion-note-heads-engraver.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 1997--2010 Han-Wen Nienhuys + Copyright (C) 1997--2011 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -87,6 +87,8 @@ class Completion_heads_engraver : public Engraver Rational left_to_do_; Rational do_nothing_until_; + Rational factor_; + Moment next_barline_moment (); Item *make_note_head (Stream_event*); @@ -187,22 +189,25 @@ Completion_heads_engraver::process_music () Duration note_dur; Duration *orig = 0; if (left_to_do_) - note_dur = Duration (left_to_do_, false); + { + /* + note that note_dur may be strictly less than left_to_do_ + (say, if left_to_do_ == 5/8) + */ + note_dur = Duration (left_to_do_ / factor_, false).compressed (factor_); + } else { orig = unsmob_duration (note_events_[0]->get_property ("duration")); note_dur = *orig; + factor_ = note_dur.factor (); + left_to_do_ = orig->get_length (); } Moment nb = next_barline_moment (); if (nb.main_part_ && nb < note_dur.get_length ()) - { - note_dur = Duration (nb.main_part_, false); - - do_nothing_until_ = now.main_part_ + note_dur.get_length (); - } + note_dur = Duration (nb.main_part_ / factor_, false).compressed (factor_); - if (orig) - left_to_do_ = orig->get_length (); + do_nothing_until_ = now.main_part_ + note_dur.get_length (); for (vsize i = 0; left_to_do_ && i < note_events_.size (); i++) { @@ -213,11 +218,14 @@ Completion_heads_engraver::process_music () event = event->clone (); SCM pits = note_events_[i]->get_property ("pitch"); + Duration appearance = note_dur; + if (factor_.denominator () == 1 && factor_ > Rational (1, 1)) + appearance = Duration (note_dur.get_length (), false); event->set_property ("pitch", pits); - event->set_property ("duration", note_dur.smobbed_copy ()); - event->set_property ("length", Moment (note_dur.get_length ()).smobbed_copy ()); - event->set_property ("duration-log", scm_from_int (note_dur.duration_log ())); + event->set_property ("duration", appearance.smobbed_copy ()); + event->set_property ("length", Moment (appearance.get_length ()).smobbed_copy ()); + event->set_property ("duration-log", scm_from_int (appearance.duration_log ())); Item *note = make_note_head (event); if (need_clone)