From 93a46a1adf2d7a0bdbf84192f6f1e858c0dfbd56 Mon Sep 17 00:00:00 2001 From: hanwen Date: Tue, 28 Sep 2004 22:35:07 +0000 Subject: [PATCH] (test_moment): robustify. --- ChangeLog | 4 ++++ lily/auto-beam-engraver.cc | 32 ++++++++++++++++++++++++++------ lily/event.cc | 31 +++++++++++++++---------------- 3 files changed, 45 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3ba8dbbb63..8ac2f3abcc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-09-29 Han-Wen Nienhuys + + * lily/auto-beam-engraver.cc (test_moment): robustify. + 2004-09-28 Werner Lemberg * scm/framework-tex.scm (font-load-command): Define proper font diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index d60fdb76a6..13dd0466b6 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -154,10 +154,20 @@ Auto_beam_engraver::test_moment (Direction dir, Moment test_mom) function = scm_list_n (ly_symbol2scm ("begin"), SCM_UNDEFINED); else function = scm_list_n (ly_symbol2scm ("end"), SCM_UNDEFINED); - - Moment one_beat = *unsmob_moment (get_property ("beatLength")); - int num = int ((*unsmob_moment (get_property ("measureLength")) / one_beat).main_part_); - int den = one_beat.den (); + + Moment beat_length (1,4); + if (Moment * m = unsmob_moment (get_property ("beatLength"))) + { + beat_length = *m; + } + Moment measure_length (1,1); + int num = 4; + if (Moment* m = unsmob_moment (get_property ("measureLength"))) + { + num = int ((*m / beat_length).main_part_); + } + + int den = beat_length.den (); SCM time = scm_list_n (scm_int2num (num), scm_int2num (den), SCM_UNDEFINED); SCM type = scm_list_n (scm_int2num (test_mom.num ()), @@ -212,10 +222,20 @@ Auto_beam_engraver::test_moment (Direction dir, Moment test_mom) We may have to fix this elsewhere (timing translator) r = unsmob_moment (get_property ("measurePosition"))->mod_rat (moment); */ - Moment pos = * unsmob_moment (get_property ("measurePosition")); + Moment pos (0); + if (Moment *m = unsmob_moment (get_property ("measurePosition"))) + { + pos = *m; + } + if (pos < Moment (0)) { - Moment length = * unsmob_moment (get_property ("measureLength")); + Moment length(1); + + if ( Moment *m = unsmob_moment (get_property ("measureLength"))) + { + length = *m; + } pos = length - pos; } r = pos.main_part_.mod_rat (moment.main_part_); diff --git a/lily/event.cc b/lily/event.cc index ba190b0f99..aad0bd2110 100644 --- a/lily/event.cc +++ b/lily/event.cc @@ -33,24 +33,23 @@ Event::compress (Moment m) void Event::transpose (Pitch delta) { - /* - TODO: should change music representation such that - _all_ pitch values are transposed automatically. - */ - - Pitch *p = unsmob_pitch (get_property ("pitch")); - if (!p) - return ; - - Pitch np = p->transposed (delta); - - if (abs (np.get_alteration ()) > DOUBLE_SHARP) + for (SCM s = this->get_property_alist (true); scm_is_pair (s); s = ly_cdr (s)) { - warning (_f ("Transposition by %s makes alteration larger than two", - delta.to_string ())); - } + SCM entry = ly_car (s); + SCM val = ly_cdr (entry); - set_property ("pitch", np.smobbed_copy ()); + if (Pitch * p = unsmob_pitch (val)) + { + Pitch transposed = p->transposed (delta); + scm_set_cdr_x (entry, transposed.smobbed_copy ()); + + if (abs (transposed.get_alteration ()) > DOUBLE_SHARP) + { + warning (_f ("Transposition by %s makes alteration larger than two", + delta.to_string ())); + } + } + } } Pitch -- 2.39.5