X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fevent.cc;h=69125b035d3a8f3c0bb757748bced5d8da6b509d;hb=dcf803f51a8621e64670930f89e9e02d845fe598;hp=75948dac04d13e376988b7d4b7b23346c2f1a83d;hpb=10f0e1d58eda7e8d5f3e7d5613ca2d976620e434;p=lilypond.git diff --git a/lily/event.cc b/lily/event.cc index 75948dac04..69125b035d 100644 --- a/lily/event.cc +++ b/lily/event.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1996--2003 Han-Wen Nienhuys + (c) 1996--2004 Han-Wen Nienhuys */ #include "event.hh" @@ -13,7 +13,7 @@ Moment Event::get_length () const { - Duration *d = unsmob_duration (get_mus_property ("duration")); + Duration *d = unsmob_duration (get_property ("duration")); if (!d) { Moment m ; @@ -25,9 +25,9 @@ Event::get_length () const void Event::compress (Moment m) { - Duration *d = unsmob_duration (get_mus_property ("duration")); + Duration *d = unsmob_duration (get_property ("duration")); if (d) - set_mus_property ("duration", d ->compressed (m.main_part_).smobbed_copy ()); + set_property ("duration", d ->compressed (m.main_part_).smobbed_copy ()); } void @@ -38,7 +38,7 @@ Event::transpose (Pitch delta) _all_ pitch values are transposed automatically. */ - Pitch *p = unsmob_pitch (get_mus_property ("pitch")); + Pitch *p = unsmob_pitch (get_property ("pitch")); if (!p) return ; @@ -50,18 +50,32 @@ Event::transpose (Pitch delta) delta.to_string ())); } - set_mus_property ("pitch", np.smobbed_copy ()); + set_property ("pitch", np.smobbed_copy ()); } Pitch Event::to_relative_octave (Pitch last) { - Pitch *old_pit = unsmob_pitch (get_mus_property ("pitch")); + Pitch *old_pit = unsmob_pitch (get_property ("pitch")); if (old_pit) { Pitch new_pit = *old_pit; new_pit = new_pit.to_relative_octave (last); - set_mus_property ("pitch", new_pit.smobbed_copy ()); + + SCM check = get_property ("absolute-octave"); + if (scm_is_number (check) && + new_pit.get_octave () != scm_to_int (check)) + { + Pitch expected_pit (scm_to_int (check), + new_pit.get_notename (), + new_pit.get_alteration ()); + origin ()->warning (_f ("octave check failed; expected %s, found: %s", + expected_pit.to_string (), + new_pit.to_string ())); + new_pit = expected_pit; + } + + set_property ("pitch", new_pit.smobbed_copy ()); return new_pit; } @@ -73,15 +87,16 @@ Event::Event () { } -ADD_MUSIC(Event); -LY_DEFINE(ly_music_duration_length, "ly:music-duration-length", 1, 0,0, +ADD_MUSIC (Event); + +LY_DEFINE (ly_music_duration_length, "ly:music-duration-length", 1, 0,0, (SCM mus), "Extract the duration field from @var{mus}, and return the length.") { - Music* m = unsmob_music(mus); - SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "Music"); + Music* m = unsmob_music (mus); + SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__, "Music"); - Duration *d = unsmob_duration (m->get_mus_property ("duration")); + Duration *d = unsmob_duration (m->get_property ("duration")); Moment l ; @@ -90,24 +105,24 @@ LY_DEFINE(ly_music_duration_length, "ly:music-duration-length", 1, 0,0, l = d->get_length (); } else - programming_error("Music has no duration"); - return l.smobbed_copy(); + programming_error ("Music has no duration"); + return l.smobbed_copy (); } -LY_DEFINE(ly_music_duration_compress, "ly:music-duration-compress", 2, 0,0, - (SCM mus, SCM factor), - "Extract the duration field from @var{mus}, and compress it.") +LY_DEFINE (ly_music_duration_compress, "ly:music-duration-compress", 2, 0,0, + (SCM mus, SCM fact), + "Compress @var{mus} by factor @var{fact}, which is a @code{Moment}.") { - Music* m = unsmob_music(mus); - Moment * f = unsmob_moment (factor); - SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "Music"); - SCM_ASSERT_TYPE(f, factor, SCM_ARG2, __FUNCTION__, "Moment"); + Music* m = unsmob_music (mus); + Moment * f = unsmob_moment (fact); + SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__, "Music"); + SCM_ASSERT_TYPE (f, fact, SCM_ARG2, __FUNCTION__, "Moment"); - Duration *d = unsmob_duration (m->get_mus_property ("duration")); + Duration *d = unsmob_duration (m->get_property ("duration")); if (d) - m->set_mus_property ("duration", d->compressed (f->main_part_).smobbed_copy()); + m->set_property ("duration", d->compressed (f->main_part_).smobbed_copy ()); return SCM_UNSPECIFIED; } @@ -120,39 +135,39 @@ LY_DEFINE(ly_music_duration_compress, "ly:music-duration-compress", 2, 0,0, TODO: this should use ly:pitch. */ -LY_DEFINE(ly_transpose_key_alist, "ly:transpose-key-alist", - 2, 0,0, (SCM l, SCM pitch), - "Make a new key alist of @var{l} transposed by pitch @var{pitch}") +LY_DEFINE (ly_transpose_key_alist, "ly:transpose-key-alist", + 2, 0, 0, (SCM l, SCM pit), + "Make a new key alist of @var{l} transposed by pitch @var{pit}") { SCM newlist = SCM_EOL; - Pitch *p = unsmob_pitch (pitch); + Pitch *p = unsmob_pitch (pit); - for (SCM s = l; gh_pair_p (s); s = ly_cdr (s)) + for (SCM s = l; ly_c_pair_p (s); s = ly_cdr (s)) { SCM key = ly_caar (s); SCM alter = ly_cdar (s); - if (gh_pair_p (key)) + if (ly_c_pair_p (key)) { - Pitch orig (gh_scm2int (ly_car (key)), - gh_scm2int (ly_cdr (key)), - gh_scm2int (alter)); + Pitch orig (scm_to_int (ly_car (key)), + scm_to_int (ly_cdr (key)), + scm_to_int (alter)); orig =orig.transposed (*p); - SCM key = gh_cons (scm_int2num (orig.get_octave ()), + SCM key = scm_cons (scm_int2num (orig.get_octave ()), scm_int2num (orig.get_notename ())); - newlist = gh_cons (gh_cons (key, scm_int2num (orig.get_alteration ())), + newlist = scm_cons (scm_cons (key, scm_int2num (orig.get_alteration ())), newlist); } - else if (gh_number_p (key)) + else if (scm_is_number (key)) { - Pitch orig (0, gh_scm2int (key), gh_scm2int (alter)); + Pitch orig (0, scm_to_int (key), scm_to_int (alter)); orig = orig.transposed (*p); key =scm_int2num (orig.get_notename ()); - alter = scm_int2num (orig.get_alteration()); - newlist = gh_cons (gh_cons (key, alter), newlist); + alter = scm_int2num (orig.get_alteration ()); + newlist = scm_cons (scm_cons (key, alter), newlist); } } return scm_reverse_x (newlist, SCM_EOL); @@ -161,11 +176,11 @@ LY_DEFINE(ly_transpose_key_alist, "ly:transpose-key-alist", void Key_change_ev::transpose (Pitch p) { - SCM pa = get_mus_property ("pitch-alist"); + SCM pa = get_property ("pitch-alist"); - set_mus_property ("pitch-alist", ly_transpose_key_alist (pa, p.smobbed_copy())); - Pitch tonic = *unsmob_pitch (get_mus_property ("tonic")); - set_mus_property ("tonic", + set_property ("pitch-alist", ly_transpose_key_alist (pa, p.smobbed_copy ())); + Pitch tonic = *unsmob_pitch (get_property ("tonic")); + set_property ("tonic", tonic.smobbed_copy ()); } @@ -173,14 +188,14 @@ bool alist_equal_p (SCM a, SCM b) { for (SCM s = a; - gh_pair_p (s); s = ly_cdr (s)) + ly_c_pair_p (s); s = ly_cdr (s)) { SCM key = ly_caar (s); SCM val = ly_cdar (s); SCM l = scm_assoc (key, b); if (l == SCM_BOOL_F - || !gh_equal_p ( ly_cdr (l), val)) + || !ly_c_equal_p ( ly_cdr (l), val)) return false; }