2 time-signature-engraver.cc -- implement Time_signature_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "time-signature.hh"
12 #include "engraver.hh"
13 #include "engraver-group-engraver.hh"
17 generate time_signatures.
19 class Time_signature_engraver : public Engraver
21 Item *time_signature_;
22 SCM last_time_fraction_;
25 virtual void stop_translation_timestep ();
26 virtual void process_music ();
28 TRANSLATOR_DECLARATIONS (Time_signature_engraver);
32 Time_signature_engraver::Time_signature_engraver ()
35 last_time_fraction_ = SCM_BOOL_F;
39 Time_signature_engraver::process_music ()
42 not rigorously safe, since the value might get GC'd and
43 reallocated in the same spot */
44 SCM fr = get_property ("timeSignatureFraction");
46 && last_time_fraction_ != fr
49 int den = scm_to_int (scm_cdr (fr));
50 if (den != (1 << intlog2 (den)))
53 Todo: should make typecheck?
55 OTOH, Tristan Keuris writes 8/20 in his Intermezzi.
57 warning (_f ("Found strange time signature %d/%d.",
59 scm_to_int (scm_car (fr))
64 last_time_fraction_ = fr;
65 time_signature_ = make_item ("TimeSignature",SCM_EOL);
66 time_signature_->set_property ("fraction",fr);
71 Time_signature_engraver::stop_translation_timestep ()
77 ENTER_DESCRIPTION (Time_signature_engraver,
78 /* descr */ "Create a TimeSignature whenever @code{timeSignatureFraction} changes",
79 /* creats*/ "TimeSignature",