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 "note-head.hh"
15 #include "engraver-group-engraver.hh"
16 #include "musical-request.hh"
21 This acknowledges repeated music with "tremolo" style. It typesets
26 - perhaps use engraver this to steer other engravers? That would
27 create dependencies between engravers, which is bad.
29 - create dots if appropriate.
33 class Chord_tremolo_engraver : public Engraver
37 VIRTUAL_COPY_CONS(Translator);
38 Chord_tremolo_engraver();
40 Repeated_music * repeat_;
42 /// moment (global time) where beam started.
46 /// location within measure where beam started.
47 Moment beam_start_location_;
52 Beam * finished_beam_p_;
55 virtual void do_removal_processing();
56 virtual void do_process_music();
57 virtual bool do_try_music (Music*);
58 virtual void acknowledge_element (Score_element_info);
59 virtual void do_pre_move_processing();
60 virtual void do_post_move_processing();
63 Chord_tremolo_engraver::Chord_tremolo_engraver()
65 beam_p_ = finished_beam_p_ = 0;
71 Chord_tremolo_engraver::do_try_music (Music * m)
73 Repeated_music * rp = dynamic_cast<Repeated_music*> (m);
74 if (rp && rp->type_ == "tremolo" && !repeat_)
76 Moment l = rp->body_length_mom ();
78 start_mom_ = now_mom ();
79 stop_mom_ = start_mom_ + l;
81 // ugh. should generate dots, triplet beams.
82 note_head_i_ = l.den () <? 4;
89 Chord_tremolo_engraver::do_process_music ()
91 if (repeat_ && !beam_p_)
94 beam_p_->set_elt_property ("chord-tremolo", SCM_BOOL_T);
97 SCM smp = get_property ("measurePosition");
98 Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
99 beam_start_location_ = mp;
100 announce_element (Score_element_info (beam_p_, repeat_));
106 Chord_tremolo_engraver::do_removal_processing ()
111 repeat_->warning (_ ("unterminated chord tremolo"));
112 finished_beam_p_ = beam_p_;
118 Chord_tremolo_engraver::typeset_beam ()
120 if (finished_beam_p_)
122 typeset_element (finished_beam_p_);
123 finished_beam_p_ = 0;
129 Chord_tremolo_engraver::acknowledge_element (Score_element_info info)
133 if (Stem* s = dynamic_cast<Stem *> (info.elem_l_))
135 int f = s->flag_i ();
136 f = (f > 2) ? f - 2 : 1;
137 s->set_beaming (f, LEFT);
138 s->set_beaming (f, RIGHT);
141 URG: this sets the direction of the Stem s.
144 Stem:: type_i () ->first_head ()->get_direction () ->
145 directional_element (me).set (d);
148 don't understand this comment.
151 SCM d = s->get_elt_property ("direction");
152 if (s->type_i () != 1)
154 int gap_i =s->flag_i () - ((s->type_i () >? 2) - 2);
155 beam_p_->set_elt_property ("beam-gap", gh_int2scm(gap_i));
157 s->set_elt_property ("direction", d);
159 if (Rhythmic_req* r = dynamic_cast <Rhythmic_req *> (info.req_l_))
161 beam_p_->add_stem (s);
162 Moment stem_location = now_mom () -
163 start_mom_ + beam_start_location_;
167 String s = _ ("stem must have Rhythmic structure");
169 info.req_l_->warning (s);
174 if (Note_head *nh = dynamic_cast<Note_head*> (info.elem_l_))
176 nh->set_elt_property ("duration-log", gh_int2scm (intlog2 (note_head_i_)));
183 Chord_tremolo_engraver::do_post_move_processing ()
185 if (beam_p_ && stop_mom_ == now_mom ())
187 finished_beam_p_ = beam_p_;
196 Chord_tremolo_engraver::do_pre_move_processing ()
201 ADD_THIS_TRANSLATOR(Chord_tremolo_engraver);