]> git.donarmstrong.com Git - lilypond.git/blob - lily/event.cc
* lily/sequential-music.cc: remove file.
[lilypond.git] / lily / event.cc
1 /*
2   event.cc -- implement Event
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "event.hh"
10 #include "warn.hh"
11
12 MAKE_SCHEME_CALLBACK(Event,length_callback,1);
13 SCM
14 Event::length_callback (SCM m)
15 {
16   Music* me = unsmob_music (m);
17   Duration *d = unsmob_duration (me->get_property ("duration"));
18
19   Moment mom;
20   if (d)
21     {
22       mom = d->get_length ();
23     }
24   return mom.smobbed_copy();
25 }
26
27
28 Pitch
29 Event::to_relative_octave (Pitch last)
30 {
31   Pitch *old_pit = unsmob_pitch (get_property ("pitch"));
32   if (old_pit)
33     {
34       Pitch new_pit = *old_pit;
35       new_pit = new_pit.to_relative_octave (last);
36
37       SCM check = get_property ("absolute-octave");
38       if (scm_is_number (check) &&
39           new_pit.get_octave () != scm_to_int (check))
40         {
41           Pitch expected_pit (scm_to_int (check),
42                               new_pit.get_notename (),
43                               new_pit.get_alteration ());
44           origin ()->warning (_f ("octave check failed; expected %s, found: %s",
45                                   expected_pit.to_string (),
46                                   new_pit.to_string ()));
47           new_pit = expected_pit;
48         }
49       
50       set_property ("pitch", new_pit.smobbed_copy ());
51   
52       return new_pit;
53     }
54   return last;
55 }
56   
57 Event::Event (SCM i)
58   : Music (i)
59 {
60   if (!ly_c_procedure_p (length_callback_))
61     {
62       length_callback_ = length_callback_proc;
63     }
64 }
65
66 ADD_MUSIC (Event);
67
68 Key_change_ev::Key_change_ev (SCM x)
69   : Event (x)
70 {
71 }
72 void
73 Key_change_ev::transpose (Pitch p)
74 {
75   SCM pa = get_property ("pitch-alist");
76   set_property ("pitch-alist", ly_transpose_key_alist (pa, p.smobbed_copy ()));
77
78   Event::transpose (p);
79 }
80
81 ADD_MUSIC (Key_change_ev);