2 repeated-music.cc -- implement Repeated_music
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "repeated-music.hh"
11 #include "music-list.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(SCM l)
30 set_mus_property ("type", ly_symbol2scm ("repeated-music"));
35 Repeated_music::to_relative_octave (Pitch p)
38 p = body ()->to_relative_octave (p);
42 for (SCM s = alternatives ()->music_list (); gh_pair_p (s); s = gh_cdr (s))
43 unsmob_music (gh_car (s))->to_relative_octave (p);
50 Repeated_music::transpose (Pitch p)
53 body ()->transpose (p);
56 alternatives ()->transpose (p);
60 Repeated_music::compress (Moment p)
63 body ()->compress (p);
66 alternatives ()->compress (p);
70 Repeated_music::alternatives_length_mom (bool fold) const
72 if (!alternatives () )
76 return alternatives ()->maximum_length ();
81 SCM p = alternatives ()->music_list ();
82 while (gh_pair_p (p) && done < repeat_count ())
84 m = m + unsmob_music (gh_car (p))->length_mom ();
86 if (repeat_count () - done < alternatives ()->length_i ())
93 Sum all duration of all available alternatives. This is for the case
94 of volta repeats, where the alternatives are iterated just as they
97 Repeated_music::alternatives_volta_length_mom () const
103 SCM p = alternatives ()->music_list ();
104 while (gh_pair_p (p))
106 m = m + unsmob_music (gh_car (p))->length_mom ();
113 Repeated_music::body_length_mom () const
118 m = body ()->length_mom ();
124 Repeated_music::repeat_count () const
126 return gh_scm2int (get_mus_property ("repeat-count"));
130 MAKE_SCHEME_CALLBACK(Repeated_music,unfolded_music_length, 1);
131 MAKE_SCHEME_CALLBACK(Repeated_music,folded_music_length, 1);
132 MAKE_SCHEME_CALLBACK(Repeated_music,volta_music_length, 1);
135 Repeated_music::unfolded_music_length (SCM m)
137 Repeated_music* r = dynamic_cast<Repeated_music*> (unsmob_music (m));
139 Moment l = Moment (r->repeat_count ()) * r->body_length_mom () + r->alternatives_length_mom (false);
140 return l.smobbed_copy ();
144 Repeated_music::folded_music_length (SCM m)
146 Repeated_music* r = dynamic_cast<Repeated_music*> (unsmob_music (m));
148 Moment l = r->body_length_mom () + r->alternatives_length_mom (true);
149 return l.smobbed_copy ();
153 Repeated_music::volta_music_length (SCM m)
155 Repeated_music* r = dynamic_cast<Repeated_music*> (unsmob_music (m));
156 Moment l = r->body_length_mom () + r->alternatives_volta_length_mom ();
157 return l.smobbed_copy ();