2 time-signature-engraver.cc -- implement Time_signature_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "engraver-group.hh"
11 #include "international.hh"
13 #include "time-signature.hh"
17 generate time_signatures.
19 class Time_signature_engraver : public Engraver
21 Item *time_signature_;
22 SCM last_time_fraction_;
25 virtual void derived_mark () const;
26 void stop_translation_timestep ();
27 void process_music ();
29 TRANSLATOR_DECLARATIONS (Time_signature_engraver);
33 Time_signature_engraver::derived_mark () const
35 scm_gc_mark (last_time_fraction_);
38 Time_signature_engraver::Time_signature_engraver ()
41 last_time_fraction_ = SCM_BOOL_F;
45 Time_signature_engraver::process_music ()
48 not rigorously safe, since the value might get GC'd and
49 reallocated in the same spot */
50 SCM fr = get_property ("timeSignatureFraction");
52 && last_time_fraction_ != fr
55 int den = scm_to_int (scm_cdr (fr));
56 if (den != (1 << intlog2 (den)))
59 Todo: should make typecheck?
61 OTOH, Tristan Keuris writes 8/20 in his Intermezzi.
63 warning (_f ("strange time signature found: %d/%d",
65 scm_to_int (scm_car (fr))));
68 last_time_fraction_ = fr;
69 time_signature_ = make_item ("TimeSignature", SCM_EOL);
70 time_signature_->set_property ("fraction", fr);
75 Time_signature_engraver::stop_translation_timestep ()
80 #include "translator.icc"
82 ADD_TRANSLATOR (Time_signature_engraver,
83 /* doc */ "Create a TimeSignature whenever @code{timeSignatureFraction} changes",
84 /* create */ "TimeSignature",