2 slash-repeat-engraver.cc -- implement Chord_tremolo_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "engraver.hh"
11 #include "repeated-music.hh"
12 #include "engraver-group-engraver.hh"
13 #include "global-context.hh"
18 #include "percent-repeat-iterator.hh"
19 #include "bar-line.hh"
21 #include "score-engraver.hh"
26 This acknowledges repeated music with "percent" style. It typesets
31 - BEAT case: Create items for single beat repeats, i.e. c4 / / /
33 - DOUBLE_MEASURE case: attach a % to an appropriate barline.
36 class Slash_repeat_engraver : public Engraver
39 TRANSLATOR_DECLARATIONS(Slash_repeat_engraver);
41 Repeated_music * repeat_;
43 /// moment (global time) where beam started.
47 /// location within measure where beam started.
48 Moment beam_start_location_;
53 Item * double_percent_;
55 virtual bool try_music (Music*);
56 virtual void stop_translation_timestep ();
57 virtual void start_translation_timestep ();
58 virtual void process_music ();
61 Slash_repeat_engraver::Slash_repeat_engraver ()
68 Slash_repeat_engraver::try_music (Music * m)
70 Repeated_music * rp = dynamic_cast<Repeated_music*> (m);
73 && rp->get_mus_property ("iterator-ctor")
74 == Percent_repeat_iterator::constructor_proc)
76 body_length_ = rp->body_get_length ();
77 int count = rp->repeat_count ();
79 Moment now = now_mom ();
81 stop_mom_ = start_mom_ + Moment (count) * body_length_;
82 next_moment_ = start_mom_ + body_length_;
84 SCM m = get_property ("measureLength");
86 if (Moment *mp = unsmob_moment (m))
89 if (body_length_ < meas_len
90 && meas_len.main_part_.mod_rat (body_length_.main_part_)
91 == Moment (Rational (0,0)))
98 Global_context *global =get_global_context ();
99 for (int i = 0; i < count; i++)
100 global->add_moment_to_process (next_moment_ + Moment (i) * body_length_);
109 Slash_repeat_engraver::process_music ()
111 if (repeat_ && now_mom () == next_moment_)
113 beat_slash_ = make_item ("RepeatSlash");
114 announce_grob(beat_slash_, repeat_->self_scm());
115 next_moment_ = next_moment_ + body_length_;
117 get_global_context ()->add_moment_to_process (next_moment_);
123 Slash_repeat_engraver::start_translation_timestep ()
125 if (stop_mom_ == now_mom ())
132 Slash_repeat_engraver::stop_translation_timestep ()
136 typeset_grob (beat_slash_);
144 ENTER_DESCRIPTION(Slash_repeat_engraver,
145 /* descr */ "Make beat repeats.",
146 /* creats*/ "RepeatSlash",
147 /* accepts */ "repeated-music",
149 /* reads */ "measureLength",