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 "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);
36 Repeated_music * repeat_;
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 Repeated_music * rp = dynamic_cast<Repeated_music*> (m);
68 && rp->get_property ("iterator-ctor")
69 == Percent_repeat_iterator::constructor_proc)
71 body_length_ = rp->body_get_length ();
72 int count = rp->repeat_count ();
74 Moment now = now_mom ();
76 stop_mom_ = start_mom_ + Moment (count) * body_length_;
77 next_moment_ = start_mom_ + body_length_;
79 SCM m = get_property ("measureLength");
81 if (Moment *mp = unsmob_moment (m))
84 if (body_length_ < meas_len
85 && meas_len.main_part_.mod_rat (body_length_.main_part_)
86 == Moment (Rational (0,0)))
93 Global_context *global =get_global_context ();
94 for (int i = 0; i < count; i++)
95 global->add_moment_to_process (next_moment_ + Moment (i) * body_length_);
104 Slash_repeat_engraver::process_music ()
106 if (repeat_ && now_mom () == next_moment_)
108 beat_slash_ = make_item ("RepeatSlash", repeat_->self_scm ());
109 next_moment_ = next_moment_ + body_length_;
111 get_global_context ()->add_moment_to_process (next_moment_);
117 Slash_repeat_engraver::start_translation_timestep ()
119 if (stop_mom_ == now_mom ())
126 Slash_repeat_engraver::stop_translation_timestep ()
134 ENTER_DESCRIPTION (Slash_repeat_engraver,
135 /* descr */ "Make beat repeats.",
136 /* creats*/ "RepeatSlash",
137 /* accepts */ "repeated-music",
139 /* reads */ "measureLength",