2 repeated-music.cc -- implement Repeated_music
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "repeated-music.hh"
11 #include "music-list.hh"
12 #include "musical-pitch.hh"
15 Repeated_music::Repeated_music(Music
*beg
, int times
, Music_sequence
* alts
)
20 alternatives_p_
= alts
;
23 alts
->music_p_list_p_
->truncate (times
);
26 Repeated_music::Repeated_music (Repeated_music
const &s
)
29 repeats_i_
= s
.repeats_i_
;
31 volta_fold_b_
= s
.volta_fold_b_
;
33 repeat_body_p_
= s
.repeat_body_p_
? s
.repeat_body_p_
->clone () : 0;
34 alternatives_p_
= s
.alternatives_p_
35 ? dynamic_cast<Music_sequence
*> (s
.alternatives_p_
->clone ()):0;
38 Repeated_music::~Repeated_music ()
40 delete repeat_body_p_
;
41 delete alternatives_p_
;
45 Repeated_music::do_print () const
48 DEBUG_OUT
<< "Fold = " << fold_b_
<< " reps: " << repeats_i_
;
51 repeat_body_p_
->print();
54 alternatives_p_
->print();
59 Repeated_music::to_relative_octave (Musical_pitch p
)
62 p
= repeat_body_p_
->to_relative_octave (p
);
65 p
= alternatives_p_
->do_relative_octave (p
, false);
72 Repeated_music::transpose (Musical_pitch p
)
75 repeat_body_p_
->transpose (p
);
78 alternatives_p_
->transpose (p
);
82 Repeated_music::compress (Moment p
)
85 repeat_body_p_
->compress (p
);
88 alternatives_p_
->compress (p
);
92 Repeated_music::alternatives_length_mom () const
94 if (!alternatives_p_
)
98 return alternatives_p_
->maximum_length ();
102 Cons
<Music
> *p
= alternatives_p_
->music_p_list_p_
->head_
;
103 while (p
&& done
< repeats_i_
)
105 m
= m
+ p
->car_
->length_mom ();
108 || repeats_i_
- done
< alternatives_p_
->length_i ())
115 Repeated_music::length_mom () const
121 m
+= repeat_body_p_
->length_mom ();
125 Moment beg
= (repeat_body_p_
) ? repeat_body_p_
->length_mom () : Rational(0);
127 beg
*= Rational (repeats_i_
);
131 m
+= alternatives_length_mom ();