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 ());
39 scm_unprotect_object (beg->self_scm ());
40 scm_unprotect_object (alts->self_scm ());
43 Repeated_music::Repeated_music (Repeated_music const &s)
46 repeats_i_ = s.repeats_i_;
48 volta_fold_b_ = s.volta_fold_b_;
54 Repeated_music::do_print () const
57 DEBUG_OUT << "Fold = " << fold_b_ << " reps: " << repeats_i_;
63 alternatives ()->print();
68 Repeated_music::to_relative_octave (Musical_pitch p)
71 p = body ()->to_relative_octave (p);
73 Musical_pitch last = p ;
75 for (SCM s = alternatives ()->music_list (); gh_pair_p (s); s = gh_cdr (s))
76 unsmob_music (gh_car (s))->to_relative_octave (p);
83 Repeated_music::transpose (Musical_pitch p)
86 body ()->transpose (p);
89 alternatives ()->transpose (p);
93 Repeated_music::compress (Moment p)
96 body ()->compress (p);
99 alternatives ()->compress (p);
103 Repeated_music::alternatives_length_mom () const
105 if (!alternatives () )
109 return alternatives ()->maximum_length ();
114 SCM p = alternatives ()->music_list ();
115 while (gh_pair_p (p) && done < repeats_i_)
117 m = m + unsmob_music (gh_car (p))->length_mom ();
120 || repeats_i_ - done < alternatives ()->length_i ())
127 Repeated_music::body_length_mom () const
132 m = body ()->length_mom ();
133 if (!fold_b_ && !volta_fold_b_)
134 m *= Rational (repeats_i_);
140 Repeated_music::length_mom () const
142 return body_length_mom () + alternatives_length_mom ();