2 slash-repeat-engraver.cc -- implement Chord_tremolo_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "repeated-music.hh"
11 #include "global-context.hh"
16 #include "percent-repeat-iterator.hh"
17 #include "bar-line.hh"
18 #include "score-engraver.hh"
21 This acknowledges repeated music with "percent" style. It typesets
26 - BEAT case: Create items for single beat repeats, i.e. c4 / / /
28 - DOUBLE_MEASURE case: attach a % to an appropriate barline.
31 class Slash_repeat_engraver : public Engraver
34 TRANSLATOR_DECLARATIONS (Slash_repeat_engraver);
38 /// moment (global time) where beam started.
42 /// location within measure where beam started.
43 Moment beam_start_location_;
48 Item * double_percent_;
50 virtual bool try_music (Music*);
51 virtual void stop_translation_timestep ();
52 virtual void start_translation_timestep ();
53 virtual void process_music ();
56 Slash_repeat_engraver::Slash_repeat_engraver ()
63 Slash_repeat_engraver::try_music (Music * m)
65 if (m->is_mus_type ("repeated-music")
67 && m->get_property ("iterator-ctor")
68 == Percent_repeat_iterator::constructor_proc)
70 body_length_ = Repeated_music::body_get_length (m);
71 int count = Repeated_music::repeat_count (m);
73 Moment now = now_mom ();
75 stop_mom_ = start_mom_ + Moment (count) * body_length_;
76 next_moment_ = start_mom_ + body_length_;
78 Moment meas_len = robust_scm2moment (m->get_property ("measureLength"), Moment (0));
79 if (body_length_ < meas_len
80 && meas_len.main_part_.mod_rat (body_length_.main_part_)
81 == Moment (Rational (0,0)))
88 Global_context *global = get_global_context ();
89 for (int i = 0; i < count; i++)
90 global->add_moment_to_process (next_moment_ + Moment (i) * body_length_);
99 Slash_repeat_engraver::process_music ()
101 if (repeat_ && now_mom () == next_moment_)
103 beat_slash_ = make_item ("RepeatSlash", repeat_->self_scm ());
104 next_moment_ = next_moment_ + body_length_;
106 get_global_context ()->add_moment_to_process (next_moment_);
112 Slash_repeat_engraver::start_translation_timestep ()
114 if (stop_mom_ == now_mom ())
121 Slash_repeat_engraver::stop_translation_timestep ()
129 ADD_TRANSLATOR (Slash_repeat_engraver,
130 /* descr */ "Make beat repeats.",
131 /* creats*/ "RepeatSlash",
132 /* accepts */ "repeated-music",
134 /* reads */ "measureLength",