*** empty log message ***
[lilypond.git] / lily / time-signature-engraver.cc
blob60c9a63411d1671618ce9be588a97ff06ae62f4b
1 /*
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>
7 */
9 #include "time-signature.hh"
10 #include "warn.hh"
12 #include "engraver.hh"
13 #include "engraver-group-engraver.hh"
14 #include "misc.hh"
16 /**
17 generate time_signatures.
19 class Time_signature_engraver : public Engraver
21 Item *time_signature_;
22 SCM last_time_fraction_;
24 protected:
25 virtual void stop_translation_timestep ();
26 virtual void process_music ();
27 public:
28 TRANSLATOR_DECLARATIONS (Time_signature_engraver);
32 Time_signature_engraver::Time_signature_engraver ()
34 time_signature_ = 0;
35 last_time_fraction_ = SCM_BOOL_F;
38 void
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");
45 if (!time_signature_
46 && last_time_fraction_ != fr
47 && ly_c_pair_p (fr))
49 int den = ly_scm2int (ly_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.",
58 den,
59 ly_scm2int (ly_car (fr))
60 ));
64 last_time_fraction_ = fr;
65 time_signature_ = make_item ("TimeSignature",SCM_EOL);
66 time_signature_->set_property ("fraction",fr);
70 void
71 Time_signature_engraver::stop_translation_timestep ()
73 time_signature_ = 0;
77 ENTER_DESCRIPTION (Time_signature_engraver,
78 /* descr */ "Create a TimeSignature whenever @code{timeSignatureFraction} changes",
79 /* creats*/ "TimeSignature",
80 /* accepts */ "",
81 /* acks */ "",
82 /* reads */ "",
83 /* write */ "");