3 timing-translator.cc -- implement Timing_translator
5 source file of the GNU LilyPond music typesetter
7 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
10 #include "timing-translator.hh"
11 #include "command-request.hh"
12 #include "translator-group.hh"
13 #include "global-translator.hh"
15 Timing_translator::Timing_translator ()
17 default_grouping_ = Rhythmic_grouping (MInterval (0, 1), 4); // ugh
21 Timing_translator::do_try_request(Request*r)
23 Command_req * c = r->command();
24 if (!(c && c->timing()))
26 for (int i=0; i < timing_req_l_arr_.size (); i++)
28 if (timing_req_l_arr_[i]->equal_b(r))
30 if (timing_req_l_arr_[i]->name() == r->name())
32 r->warning (_("conflicting timing request"));
37 timing_req_l_arr_.push(c->timing());
42 Timing_translator::meter_req_l() const
44 Meter_change_req *m_l=0;
45 for (int i=0; !m_l && i < timing_req_l_arr_.size (); i++)
47 m_l=timing_req_l_arr_[i]->meterchange();
53 Timing_translator::do_process_requests()
55 for (int i=0; i < timing_req_l_arr_.size (); i++)
57 Timing_req * tr_l = timing_req_l_arr_[i];
58 Meter_change_req *m_l = tr_l->meterchange();
61 int b_i= m_l->beats_i_;
62 int o_i = m_l->one_beat_i_;
63 if (! time_.allow_meter_change_b())
64 tr_l->warning (_("Meter change not allowed here"));
67 time_.set_meter (b_i, o_i);
69 Rhythmic_grouping (MInterval (0,Moment (b_i, o_i)), b_i);
72 else if (tr_l->partial())
74 Moment m = tr_l->partial()->duration_;
75 String error = time_.try_set_partial_str (m);
76 if (error.length_i ())
78 tr_l->warning (error);
83 else if (tr_l->barcheck())
85 if (time_.whole_in_measure_)
87 tr_l ->warning (_("Barcheck failed"));
89 time_.whole_in_measure_ = 0; // resync
90 time_.error_b_ = true;
94 else if (tr_l->cadenza())
96 time_.set_cadenza (tr_l->cadenza()->on_b_);
98 else if (tr_l->measuregrouping())
101 parse_grouping (tr_l->measuregrouping()->beat_i_arr_,
102 tr_l->measuregrouping()->elt_length_arr_);
110 Timing_translator::do_pre_move_processing()
112 timing_req_l_arr_.set_size (0);
113 Global_translator *global_l =
114 daddy_trans_l_->ancestor_l (100)->global_l (); // ugh 100.
116 if (!time_.cadenza_b_)
117 global_l->add_moment_to_process (time_.next_bar_moment ());
120 IMPLEMENT_IS_TYPE_B1(Timing_translator, Translator);
121 ADD_THIS_TRANSLATOR(Timing_translator);
124 Timing_translator::do_creation_processing()
126 time_.when_ = now_moment ();
130 Timing_translator::do_post_move_processing()
132 time_.add (now_moment () - time_.when_);
136 Timing_translator::do_print () const
140 default_grouping_.print ();