2 event.cc -- implement Event
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
13 Event::get_length () const
15 Duration *d = unsmob_duration (get_property ("duration"));
21 return d->get_length ();
25 Event::compress (Moment m)
27 Duration *d = unsmob_duration (get_property ("duration"));
29 set_property ("duration", d ->compressed (m.main_part_).smobbed_copy ());
34 Event::to_relative_octave (Pitch last)
36 Pitch *old_pit = unsmob_pitch (get_property ("pitch"));
39 Pitch new_pit = *old_pit;
40 new_pit = new_pit.to_relative_octave (last);
42 SCM check = get_property ("absolute-octave");
43 if (scm_is_number (check) &&
44 new_pit.get_octave () != scm_to_int (check))
46 Pitch expected_pit (scm_to_int (check),
47 new_pit.get_notename (),
48 new_pit.get_alteration ());
49 origin ()->warning (_f ("octave check failed; expected %s, found: %s",
50 expected_pit.to_string (),
51 new_pit.to_string ()));
52 new_pit = expected_pit;
55 set_property ("pitch", new_pit.smobbed_copy ());
70 Key_change_ev::transpose (Pitch p)
72 SCM pa = get_property ("pitch-alist");
73 set_property ("pitch-alist", ly_transpose_key_alist (pa, p.smobbed_copy ()));
79 alist_equal_p (SCM a, SCM b)
82 scm_is_pair (s); s = scm_cdr (s))
84 SCM key = scm_caar (s);
85 SCM val = scm_cdar (s);
86 SCM l = scm_assoc (key, b);
89 || !ly_c_equal_p ( scm_cdr (l), val))
95 ADD_MUSIC (Key_change_ev);