2 music-sequence.cc -- implement Music_sequence
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "music-list.hh"
15 Music_sequence::music_list ()const
17 return get_mus_property ("elements");
21 Ugh this sucks. Linear. do not use.
24 Music_sequence::append_music (Music
*m
)
26 set_mus_property ("elements",
27 gh_append2 (music_list (), gh_cons (m
->self_scm (), SCM_EOL
)));
28 scm_gc_unprotect_object (m
->self_scm ());
31 Music_sequence::Music_sequence (SCM l
)
37 Music_sequence::transpose (Pitch rq
)
39 transpose_list (music_list (), rq
);
43 Music_sequence::transpose_list (SCM l
, Pitch rq
)
45 for (SCM s
= l
; gh_pair_p (s
); s
= ly_cdr (s
))
46 unsmob_music (ly_car (s
))->transpose (rq
);
50 Music_sequence::cumulative_length (SCM l
)
55 for (SCM s
= l
; gh_pair_p (s
); s
= ly_cdr (s
))
57 Moment l
= unsmob_music (ly_car (s
))->length_mom ();
58 if (last_len
.grace_part_
&& l
.main_part_
)
60 last_len
.grace_part_
= Rational (0);
62 cumulative
+= last_len
;
66 last_len
.grace_part_
= Rational (0);
67 cumulative
+= last_len
;
73 Music_sequence::to_relative_octave (Pitch p
)
75 return do_relative_octave (p
, false);
80 Music_sequence::maximum_length (SCM l
)
83 for (SCM s
= l
; gh_pair_p (s
); s
= ly_cdr (s
))
85 Music
* m
= unsmob_music (ly_car (s
));
86 Moment l
= m
->length_mom ();
95 Music_sequence::do_relative_octave (Pitch p
, bool ret_first
)
101 for (SCM s
= music_list (); gh_pair_p (s
); s
= ly_cdr (s
))
103 Music
*m
= unsmob_music (ly_car (s
));
106 programming_error ("Music_sequence should only contain music!");
110 last
= m
->to_relative_octave (last
);
123 Music_sequence::compress (Moment m
)
125 compress_list (music_list (), m
);
129 Music_sequence::compress_list (SCM l
, Moment m
)
131 for (SCM s
= l
; gh_pair_p (s
); s
= ly_cdr (s
))
132 unsmob_music (ly_car (s
))->compress (m
);
135 ADD_MUSIC (Music_sequence
);
137 Music_sequence::Music_sequence ()
144 Music_sequence::minimum_start (SCM l
)
148 for (SCM s
= l
; gh_pair_p (s
); s
= ly_cdr (s
))
150 m
= m
<? unsmob_music (ly_car (s
))->start_mom ();
156 Music_sequence::first_start (SCM l
)
160 for (SCM s
= l
; gh_pair_p (s
); s
= ly_cdr (s
))
162 Music
* mus
= unsmob_music (ly_car (s
));
163 Moment l
= mus
->length_mom ();
164 Moment s
= mus
->start_mom ();
165 if (l
.to_bool () || s
.to_bool ())