X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fcompletion-note-heads-engraver.cc;h=3002d48bb91eca7253e1bfaaa9967d5c4b000b60;hb=1794c5a634ce0bf7f4a08c6d20ec163e7e991de6;hp=b116cb50b4bc9e41c6031fdc89fc330f4f6f83c9;hpb=7c83ac2d86066ca8f41260d37e792e166ad5dbb6;p=lilypond.git diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc index b116cb50b4..3002d48bb9 100644 --- a/lily/completion-note-heads-engraver.cc +++ b/lily/completion-note-heads-engraver.cc @@ -1,7 +1,20 @@ /* - completion-note-heads-engraver.cc -- Completion_heads_engraver + This file is part of LilyPond, the GNU music typesetter. - (c) 1997--2007 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include @@ -32,12 +45,13 @@ struct Pending_tie { Moment when_; Stream_event* tie_event_; - Pending_tie() { tie_event_ = 0; } + Pending_tie () : tie_event_ (0) {} }; -int compare(Pending_tie const &a, Pending_tie const &b) +static int +compare (Pending_tie const &a, Pending_tie const &b) { - return compare(a.when_, b.when_); + return compare (a.when_, b.when_); } @@ -60,19 +74,18 @@ class Completion_heads_engraver : public Engraver { vector notes_; vector prev_notes_; - // Must remember notes for explicit ties. vector tie_note_candidates_; vector tie_note_candidate_events_; vector ties_; PQueue pending_ties_; vector note_events_; - Stream_event *current_tie_event_; Moment note_end_mom_; bool is_first_; Rational left_to_do_; Rational do_nothing_until_; + Rational factor_; Moment next_barline_moment (); Item *make_note_head (Stream_event*); @@ -174,22 +187,33 @@ 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) + */ + if (factor_.denominator () == 1 && factor_ > Rational (1, 1)) + note_dur = Duration (left_to_do_, false); + else + 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 (); + if (factor_.denominator () == 1 && factor_ > Rational (1, 1)) + note_dur = Duration (nb.main_part_, false); + else + 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++) { @@ -200,7 +224,6 @@ Completion_heads_engraver::process_music () event = event->clone (); SCM pits = note_events_[i]->get_property ("pitch"); - event->set_property ("pitch", pits); event->set_property ("duration", note_dur.smobbed_copy ()); event->set_property ("length", Moment (note_dur.get_length ()).smobbed_copy ()); @@ -290,18 +313,17 @@ ADD_TRANSLATOR (Completion_heads_engraver, /* doc */ "This engraver replaces @code{Note_heads_engraver}. It plays" " some trickery to break long notes and automatically tie them" - " into the next measure.", - + " into the next measure." + , /* create */ "NoteHead " - "Dots " - "Tie ", - + "Tie " + , /* read */ "middleCPosition " "measurePosition " - "measureLength ", - + "measureLength " + , /* write */ "completionBusy " );