2 new-chord-tremolo-engraver.cc -- implement Chord_tremolo_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "engraver.hh"
12 #include "repeated-music.hh"
14 #include "rhythmic-head.hh"
15 #include "engraver-group-engraver.hh"
16 #include "musical-request.hh"
19 #include "note-head.hh"
22 #include "chord-tremolo-iterator.hh"
25 This acknowledges repeated music with "tremolo" style. It typesets
30 - perhaps use engraver this to steer other engravers? That would
31 create dependencies between engravers, which is bad.
33 - create dots if appropriate.
35 - create TremoloBeam iso Beam?
38 class Chord_tremolo_engraver : public Engraver
42 VIRTUAL_COPY_CONS(Translator);
43 Chord_tremolo_engraver();
45 Repeated_music * repeat_;
47 /// moment (global time) where beam started.
51 /// location within measure where beam started.
52 Moment beam_start_location_;
57 Spanner * finished_beam_p_;
60 virtual void do_removal_processing();
61 void deprecated_process_music();
62 virtual bool try_music (Music*);
63 virtual void acknowledge_grob (Grob_info);
64 virtual void stop_translation_timestep();
65 virtual void start_translation_timestep();
66 virtual void create_grobs ();
69 Chord_tremolo_engraver::Chord_tremolo_engraver()
71 beam_p_ = finished_beam_p_ = 0;
77 Chord_tremolo_engraver::try_music (Music * m)
79 Repeated_music * rp = dynamic_cast<Repeated_music*> (m);
81 && rp->get_mus_property ("type") == Chord_tremolo_iterator::constructor_cxx_function
84 Moment l = rp->body_length_mom ();
86 start_mom_ = now_mom ();
87 stop_mom_ = start_mom_ + l;
89 // ugh. should generate dots, triplet beams.
90 note_head_i_ = l.den () <? 4;
97 Chord_tremolo_engraver::create_grobs ()
99 deprecated_process_music ();
103 Chord_tremolo_engraver::deprecated_process_music ()
105 if (repeat_ && !beam_p_)
107 beam_p_ = new Spanner (get_property ("Beam"));
108 Beam::set_interface (beam_p_);
109 beam_p_->set_grob_property ("chord-tremolo", SCM_BOOL_T);
112 SCM smp = get_property ("measurePosition");
113 Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
114 beam_start_location_ = mp;
115 announce_grob (beam_p_, repeat_);
121 Chord_tremolo_engraver::do_removal_processing ()
126 repeat_->origin ()->warning (_ ("unterminated chord tremolo"));
128 finished_beam_p_ = beam_p_;
137 Chord_tremolo_engraver::typeset_beam ()
139 if (finished_beam_p_)
141 typeset_grob (finished_beam_p_);
142 finished_beam_p_ = 0;
148 Chord_tremolo_engraver::acknowledge_grob (Grob_info info)
152 if (Stem::has_interface (info.elem_l_))
154 Grob * s = info.elem_l_;
155 int f = Stem::flag_i (s);
156 f = (f > 2) ? f - 2 : 1;
157 Stem::set_beaming (s, f, LEFT);
158 Stem::set_beaming (s, f, RIGHT);
161 URG: this sets the direction of the Stem s.
164 Stem:: type_i () ->first_head ()->get_direction () ->
165 Directional_element_interface::set (me, d);
168 don't understand this comment.
171 SCM d = s->get_grob_property ("direction");
172 if (Stem::type_i (s ) != 1)
174 int gap_i =Stem::flag_i (s ) - ((Stem::type_i (s ) >? 2) - 2);
175 beam_p_->set_grob_property ("beam-gap", gh_int2scm(gap_i));
177 s->set_grob_property ("direction", d);
179 if (dynamic_cast <Rhythmic_req *> (info.req_l_))
181 Beam::add_stem (beam_p_, s);
185 String s = _ ("stem must have Rhythmic structure");
187 info.req_l_->origin ()->warning (s);
192 if (Note_head::has_interface (info.elem_l_))
194 info.elem_l_->set_grob_property ("duration-log", gh_int2scm (intlog2 (note_head_i_)));
201 Chord_tremolo_engraver::start_translation_timestep ()
203 if (beam_p_ && stop_mom_ == now_mom ())
205 finished_beam_p_ = beam_p_;
214 Chord_tremolo_engraver::stop_translation_timestep ()
219 ADD_THIS_TRANSLATOR(Chord_tremolo_engraver);