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 ("element"));
22 Repeated_music::alternatives ()const
24 return get_mus_property ("elements");
28 Repeated_music::Repeated_music (SCM l)
31 set_mus_property ("type", ly_symbol2scm ("repeated-music"));
36 Repeated_music::to_relative_octave (Pitch p)
39 p = body ()->to_relative_octave (p);
43 for (SCM s = alternatives (); gh_pair_p (s); s = ly_cdr (s))
44 unsmob_music (ly_car (s))->to_relative_octave (p);
51 Repeated_music::transpose (Pitch p)
54 body ()->transpose (p);
56 Music_sequence::transpose_list (get_mus_property ("elements"), p);
60 Repeated_music::compress (Moment p)
63 body ()->compress (p);
65 Music_sequence::compress_list (alternatives (), p);
69 Repeated_music::alternatives_length_mom (bool fold) const
75 return Music_sequence::maximum_length (alternatives ());
80 SCM p = alternatives ();
81 while (gh_pair_p (p) && done < repeat_count ())
83 m = m + unsmob_music (ly_car (p))->length_mom ();
85 if (repeat_count () - done < scm_ilength (alternatives ()))
92 Sum all duration of all available alternatives. This is for the case
93 of volta repeats, where the alternatives are iterated just as they
96 Repeated_music::alternatives_volta_length_mom () const
102 SCM p = alternatives ();
103 while (gh_pair_p (p))
105 m = m + unsmob_music (ly_car (p))->length_mom ();
113 Length of the body in THIS. Disregards REPEAT-COUNT.
116 Repeated_music::body_length_mom () const
121 m = body ()->length_mom ();
127 Repeated_music::repeat_count () const
129 return gh_scm2int (get_mus_property ("repeat-count"));
133 MAKE_SCHEME_CALLBACK (Repeated_music,unfolded_music_length, 1);
134 MAKE_SCHEME_CALLBACK (Repeated_music,folded_music_length, 1);
135 MAKE_SCHEME_CALLBACK (Repeated_music,volta_music_length, 1);
138 Repeated_music::unfolded_music_length (SCM m)
140 Repeated_music* r = dynamic_cast<Repeated_music*> (unsmob_music (m));
142 Moment l = Moment (r->repeat_count ()) * r->body_length_mom () + r->alternatives_length_mom (false);
143 return l.smobbed_copy ();
147 Repeated_music::folded_music_length (SCM m)
149 Repeated_music* r = dynamic_cast<Repeated_music*> (unsmob_music (m));
151 Moment l = r->body_length_mom () + r->alternatives_length_mom (true);
152 return l.smobbed_copy ();
156 Repeated_music::volta_music_length (SCM m)
158 Repeated_music* r = dynamic_cast<Repeated_music*> (unsmob_music (m));
159 Moment l = r->body_length_mom () + r->alternatives_volta_length_mom ();
160 return l.smobbed_copy ();
163 ADD_MUSIC (Repeated_music);
165 Repeated_music::Repeated_music ()
168 set_mus_property ("type", ly_symbol2scm ("repeated-music"));