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-translator.hh"
18 #include "percent-repeat-iterator.hh"
19 #include "bar-line.hh"
21 #include "score-engraver.hh"
22 #include "translator-group.hh"
25 This acknowledges repeated music with "percent" style. It typesets
30 - BEAT case: Create items for single beat repeats, i.e. c4 / / /
32 - DOUBLE_MEASURE case: attach a % to an appropriate barline.
35 class Slash_repeat_engraver : public Engraver
38 TRANSLATOR_DECLARATIONS(Slash_repeat_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 Item * double_percent_;
54 virtual bool try_music (Music*);
55 virtual void stop_translation_timestep ();
56 virtual void start_translation_timestep ();
57 virtual void process_music ();
60 Slash_repeat_engraver::Slash_repeat_engraver ()
67 Slash_repeat_engraver::try_music (Music * m)
69 Repeated_music * rp = dynamic_cast<Repeated_music*> (m);
72 && rp->get_mus_property ("iterator-ctor")
73 == Percent_repeat_iterator::constructor_proc)
75 body_length_ = rp->body_get_length ();
76 int count = rp->repeat_count ();
78 Moment now = now_mom ();
80 stop_mom_ = start_mom_ + Moment (count) * body_length_;
81 next_moment_ = start_mom_ + body_length_;
83 SCM m = get_property ("measureLength");
85 if (Moment *mp = unsmob_moment (m))
88 if (body_length_ < meas_len
89 && meas_len.main_part_.mod_rat (body_length_.main_part_)
90 == Moment (Rational (0,0)))
97 Global_translator *global =top_engraver();
98 for (int i = 0; i < count; i++)
99 global->add_moment_to_process (next_moment_ + Moment (i) * body_length_);
108 Slash_repeat_engraver::process_music ()
110 if (repeat_ && now_mom () == next_moment_)
112 beat_slash_ = make_item ("RepeatSlash");
113 announce_grob(beat_slash_, repeat_->self_scm());
114 next_moment_ = next_moment_ + body_length_;
116 top_engraver()->add_moment_to_process (next_moment_);
122 Slash_repeat_engraver::start_translation_timestep ()
124 if (stop_mom_ == now_mom ())
131 Slash_repeat_engraver::stop_translation_timestep ()
135 typeset_grob (beat_slash_);
143 ENTER_DESCRIPTION(Slash_repeat_engraver,
144 /* descr */ "Make beat repeats.",
145 /* creats*/ "RepeatSlash",
146 /* accepts */ "repeated-music",
148 /* reads */ "measureLength",