(readPostTable): ugh. Kludge: nglyphs in maxp
[lilypond.git] / lily / time-signature-engraver.cc
blob77fd444f129f399ab70f0277491f6811668341e8
1 /*
2 time-signature-engraver.cc -- implement Time_signature_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "time-signature.hh"
10 #include "warn.hh"
11 #include "engraver-group-engraver.hh"
12 #include "misc.hh"
14 /**
15 generate time_signatures.
17 class Time_signature_engraver : public Engraver
19 Item *time_signature_;
20 SCM last_time_fraction_;
22 protected:
23 virtual void stop_translation_timestep ();
24 virtual void process_music ();
25 public:
26 TRANSLATOR_DECLARATIONS (Time_signature_engraver);
29 Time_signature_engraver::Time_signature_engraver ()
31 time_signature_ = 0;
32 last_time_fraction_ = SCM_BOOL_F;
35 void
36 Time_signature_engraver::process_music ()
39 not rigorously safe, since the value might get GC'd and
40 reallocated in the same spot */
41 SCM fr = get_property ("timeSignatureFraction");
42 if (!time_signature_
43 && last_time_fraction_ != fr
44 && scm_is_pair (fr))
46 int den = scm_to_int (scm_cdr (fr));
47 if (den != (1 << intlog2 (den)))
50 Todo: should make typecheck?
52 OTOH, Tristan Keuris writes 8/20 in his Intermezzi.
54 warning (_f ("strange time signature found: %d/%d",
55 den,
56 scm_to_int (scm_car (fr))));
59 last_time_fraction_ = fr;
60 time_signature_ = make_item ("TimeSignature", SCM_EOL);
61 time_signature_->set_property ("fraction", fr);
65 void
66 Time_signature_engraver::stop_translation_timestep ()
68 time_signature_ = 0;
71 ADD_TRANSLATOR (Time_signature_engraver,
72 /* descr */ "Create a TimeSignature whenever @code{timeSignatureFraction} changes",
73 /* creats*/ "TimeSignature",
74 /* accepts */ "",
75 /* acks */ "",
76 /* reads */ "",
77 /* write */ "");