X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fmusic-sequence.cc;h=7ab62470b567bc5fad37a004329749d7fa7d00a2;hb=9564d2844d109d0730cf850bbeb7768bb4d721d1;hp=c57e18353a568dc34d9b6bccf3037b6c3a933878;hpb=a6a4b3fc2009f17a1a48cca0c11bfd3f38645937;p=lilypond.git diff --git a/lily/music-sequence.cc b/lily/music-sequence.cc index c57e18353a..7ab62470b5 100644 --- a/lily/music-sequence.cc +++ b/lily/music-sequence.cc @@ -1,15 +1,28 @@ /* - music-sequence.cc -- implement Music_sequence + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 1998--2012 Han-Wen Nienhuys - (c) 1998--2008 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 "music-sequence.hh" #include "warn.hh" #include "program-option.hh" +#include "duration.hh" +#include "moment.hh" #include "music.hh" #include "input.hh" @@ -30,7 +43,7 @@ Music_sequence::cumulative_length (SCM l) { Moment l = unsmob_music (scm_car (s))->get_length (); if (last_len.grace_part_ && l.main_part_) - last_len.grace_part_ = Rational (0); + last_len.grace_part_ = Rational (0); cumulative += last_len; last_len = l; } @@ -49,12 +62,12 @@ Music_sequence::maximum_length (SCM l) { Music *m = unsmob_music (scm_car (s)); if (!m) - programming_error ("Music sequence should have music elements"); + programming_error ("Music sequence should have music elements"); else - { - Moment l = m->get_length (); - dur = max (dur, l); - } + { + Moment l = m->get_length (); + dur = max (dur, l); + } } return dur; @@ -68,6 +81,21 @@ Music_sequence::maximum_length_callback (SCM m) return maximum_length (me->get_property ("elements")).smobbed_copy (); } +MAKE_SCHEME_CALLBACK (Music_sequence, event_chord_length_callback, 1); +SCM +Music_sequence::event_chord_length_callback (SCM m) +{ + Music *me = unsmob_music (m); + Duration *d = unsmob_duration (me->get_property ("duration")); + // Preset duration is used in chord repetitions. + if (d) + { + Moment mom = d->get_length (); + return mom.smobbed_copy (); + } + return maximum_length (me->get_property ("elements")).smobbed_copy (); +} + MAKE_SCHEME_CALLBACK (Music_sequence, cumulative_length_callback, 1); SCM Music_sequence::cumulative_length_callback (SCM m) @@ -102,11 +130,11 @@ music_list_to_relative (SCM l, Pitch p, bool ret_first) for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) { if (Music *m = unsmob_music (scm_car (s))) - { - last = m->to_relative_octave (last); - if (!count++) - first = last; - } + { + last = m->to_relative_octave (last); + if (!count++) + first = last; + } } return (ret_first) ? first : last; @@ -132,17 +160,15 @@ Music_sequence::minimum_start (SCM l) Moment Music_sequence::first_start (SCM l) { - Moment m; for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) { Music *mus = unsmob_music (scm_car (s)); - Moment l = mus->get_length (); - Moment s = mus->start_mom (); - if (l.to_bool () || s.to_bool ()) - return s; + Moment start = mus->start_mom (); + if (mus->get_length ().to_bool () || start.to_bool ()) + return start; } - return m; + return Moment (); } MAKE_SCHEME_CALLBACK (Music_sequence, simultaneous_relative_callback, 2); @@ -164,7 +190,7 @@ Music_sequence::simultaneous_relative_callback (SCM music, SCM pitch) Pitch retval_1_8 = music_list_to_relative (copied, p, true); if (retval_1_8 != retval) - lily_1_8_compatibility_used = true; + lily_1_8_compatibility_used = true; retval = retval_1_8; } @@ -179,6 +205,5 @@ Music_sequence::event_chord_relative_callback (SCM music, SCM pitch) Music *me = unsmob_music (music); Pitch p = *unsmob_pitch (pitch); return music_list_to_relative (me->get_property ("elements"), - p, true).smobbed_copy (); + p, true).smobbed_copy (); } -