2 time-signature-engraver.cc -- implement Time_signature_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "engraver-group.hh"
12 #include "international.hh"
14 #include "time-signature.hh"
18 generate time_signatures.
20 class Time_signature_engraver : public Engraver
22 Item *time_signature_;
23 SCM last_time_fraction_;
26 virtual void derived_mark () const;
27 void stop_translation_timestep ();
28 void process_music ();
30 TRANSLATOR_DECLARATIONS (Time_signature_engraver);
34 Time_signature_engraver::derived_mark () const
36 scm_gc_mark (last_time_fraction_);
39 Time_signature_engraver::Time_signature_engraver ()
42 last_time_fraction_ = SCM_BOOL_F;
46 Time_signature_engraver::process_music ()
49 not rigorously safe, since the value might get GC'd and
50 reallocated in the same spot */
51 SCM fr = get_property ("timeSignatureFraction");
53 && last_time_fraction_ != fr
56 int den = scm_to_int (scm_cdr (fr));
57 if (den != (1 << intlog2 (den)))
60 Todo: should make typecheck?
62 OTOH, Tristan Keuris writes 8/20 in his Intermezzi.
64 warning (_f ("strange time signature found: %d/%d",
66 int (scm_to_int (scm_car (fr)))));
69 time_signature_ = make_item ("TimeSignature", SCM_EOL);
70 time_signature_->set_property ("fraction", fr);
72 if (last_time_fraction_ == SCM_BOOL_F)
73 time_signature_->set_property ("break-visibility",
74 get_property ("implicitTimeSignatureVisibility"));
76 last_time_fraction_ = fr;
81 Time_signature_engraver::stop_translation_timestep ()
86 #include "translator.icc"
88 ADD_TRANSLATOR (Time_signature_engraver,
89 /* doc */ "Create a @ref{TimeSignature} whenever @code{timeSignatureFraction} changes",
94 "implicitTimeSignatureVisibility "
95 "timeSignatureFraction "