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")));
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 ()->music_list (); 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);
57 alternatives ()->transpose (p);
61 Repeated_music::compress (Moment p)
64 body ()->compress (p);
67 alternatives ()->compress (p);
71 Repeated_music::alternatives_length_mom (bool fold) const
77 return alternatives ()->maximum_length ();
82 SCM p = alternatives ()->music_list ();
83 while (gh_pair_p (p) && done < repeat_count ())
85 m = m + unsmob_music (ly_car (p))->length_mom ();
87 if (repeat_count () - done < alternatives ()->length_i ())
94 Sum all duration of all available alternatives. This is for the case
95 of volta repeats, where the alternatives are iterated just as they
98 Repeated_music::alternatives_volta_length_mom () const
100 if (!alternatives ())
104 SCM p = alternatives ()->music_list ();
105 while (gh_pair_p (p))
107 m = m + unsmob_music (ly_car (p))->length_mom ();
115 Length of the body in THIS. Disregards REPEAT-COUNT.
118 Repeated_music::body_length_mom () const
123 m = body ()->length_mom ();
129 Repeated_music::repeat_count () const
131 return gh_scm2int (get_mus_property ("repeat-count"));
135 MAKE_SCHEME_CALLBACK (Repeated_music,unfolded_music_length, 1);
136 MAKE_SCHEME_CALLBACK (Repeated_music,folded_music_length, 1);
137 MAKE_SCHEME_CALLBACK (Repeated_music,volta_music_length, 1);
140 Repeated_music::unfolded_music_length (SCM m)
142 Repeated_music* r = dynamic_cast<Repeated_music*> (unsmob_music (m));
144 Moment l = Moment (r->repeat_count ()) * r->body_length_mom () + r->alternatives_length_mom (false);
145 return l.smobbed_copy ();
149 Repeated_music::folded_music_length (SCM m)
151 Repeated_music* r = dynamic_cast<Repeated_music*> (unsmob_music (m));
153 Moment l = r->body_length_mom () + r->alternatives_length_mom (true);
154 return l.smobbed_copy ();
158 Repeated_music::volta_music_length (SCM m)
160 Repeated_music* r = dynamic_cast<Repeated_music*> (unsmob_music (m));
161 Moment l = r->body_length_mom () + r->alternatives_volta_length_mom ();
162 return l.smobbed_copy ();
165 ADD_MUSIC (Repeated_music);
167 Repeated_music::Repeated_music ()
170 set_mus_property ("type", ly_symbol2scm ("repeated-music"));