2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "engraver-group.hh"
23 #include "international.hh"
25 #include "stream-event.hh"
26 #include "time-signature.hh"
29 #include "translator.icc"
32 generate time_signatures.
34 class Time_signature_engraver : public Engraver
36 Item *time_signature_;
37 SCM last_time_fraction_;
41 virtual void derived_mark () const;
42 void stop_translation_timestep ();
43 void process_music ();
45 TRANSLATOR_DECLARATIONS (Time_signature_engraver);
46 DECLARE_TRANSLATOR_LISTENER (time_signature);
50 Time_signature_engraver::derived_mark () const
52 scm_gc_mark (last_time_fraction_);
53 scm_gc_mark (time_cause_);
56 Time_signature_engraver::Time_signature_engraver ()
59 time_cause_ = SCM_EOL;
60 last_time_fraction_ = SCM_BOOL_F;
63 IMPLEMENT_TRANSLATOR_LISTENER (Time_signature_engraver, time_signature);
65 Time_signature_engraver::listen_time_signature (Stream_event *ev)
67 time_cause_ = ev->self_scm ();
71 Time_signature_engraver::process_music ()
73 SCM fr = get_property ("timeSignatureFraction");
75 && last_time_fraction_ != fr
78 int den = scm_to_int (scm_cdr (fr));
79 if (den != (1 << intlog2 (den)))
82 Todo: should make typecheck?
84 OTOH, Tristan Keuris writes 8/20 in his Intermezzi.
86 warning (_f ("strange time signature found: %d/%d",
87 int (scm_to_int (scm_car (fr))),
91 time_signature_ = make_item ("TimeSignature", time_cause_);
92 time_signature_->set_property ("fraction", fr);
94 if (last_time_fraction_ == SCM_BOOL_F)
95 time_signature_->set_property ("break-visibility",
96 get_property ("implicitTimeSignatureVisibility"));
98 last_time_fraction_ = fr;
103 Time_signature_engraver::stop_translation_timestep ()
106 time_cause_ = SCM_EOL;
109 #include "translator.icc"
111 ADD_TRANSLATOR (Time_signature_engraver,
113 "Create a @ref{TimeSignature} whenever"
114 " @code{timeSignatureFraction} changes.",
120 "implicitTimeSignatureVisibility "
121 "timeSignatureFraction ",