2 repeated-music.cc -- implement Repeated_music
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "repeated-music.hh"
11 #include "music-list.hh"
12 #include "musical-pitch.hh"
16 Repeated_music::body ()const
18 return unsmob_music (get_mus_property ("body"));
22 Repeated_music::alternatives ()const
24 return dynamic_cast<Music_sequence*> (unsmob_music (get_mus_property ("alternatives")));
27 Repeated_music::Repeated_music(Music *beg, int times, Music_sequence * alts)
29 set_mus_property ("body", beg->self_scm ());
35 alts->truncate (times);
36 set_mus_property ("alternatives", alts->self_scm ());
40 Repeated_music::Repeated_music (Repeated_music const &s)
43 repeats_i_ = s.repeats_i_;
45 volta_fold_b_ = s.volta_fold_b_;
51 Repeated_music::do_print () const
54 DEBUG_OUT << "Fold = " << fold_b_ << " reps: " << repeats_i_;
60 alternatives ()->print();
65 Repeated_music::to_relative_octave (Musical_pitch p)
68 p = body ()->to_relative_octave (p);
70 Musical_pitch last = p ;
72 for (SCM s = alternatives ()->music_list (); gh_pair_p (s); s = gh_cdr (s))
73 unsmob_music (gh_car (s))->to_relative_octave (p);
80 Repeated_music::transpose (Musical_pitch p)
83 body ()->transpose (p);
86 alternatives ()->transpose (p);
90 Repeated_music::compress (Moment p)
93 body ()->compress (p);
96 alternatives ()->compress (p);
100 Repeated_music::alternatives_length_mom () const
102 if (!alternatives () )
106 return alternatives ()->maximum_length ();
111 SCM p = alternatives ()->music_list ();
112 while (gh_pair_p (p) && done < repeats_i_)
114 m = m + unsmob_music (gh_car (p))->length_mom ();
117 || repeats_i_ - done < alternatives ()->length_i ())
124 Repeated_music::body_length_mom () const
129 m = body ()->length_mom ();
130 if (!fold_b_ && !volta_fold_b_)
131 m *= Rational (repeats_i_);
137 Repeated_music::length_mom () const
139 return body_length_mom () + alternatives_length_mom ();