2 music-sequence.cc -- implement Music_sequence
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2003 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 ( )
37 transpose_music_list (SCM l
, Pitch rq
)
39 for (SCM s
= l
; gh_pair_p (s
); s
= ly_cdr (s
))
40 unsmob_music (ly_car (s
))->transpose (rq
);
44 Music_sequence::cumulative_length (SCM l
)
49 for (SCM s
= l
; gh_pair_p (s
); s
= ly_cdr (s
))
51 Moment l
= unsmob_music (ly_car (s
))->get_length ();
52 if (last_len
.grace_part_
&& l
.main_part_
)
54 last_len
.grace_part_
= Rational (0);
56 cumulative
+= last_len
;
60 last_len
.grace_part_
= Rational (0);
61 cumulative
+= last_len
;
67 Music_sequence::maximum_length (SCM l
)
70 for (SCM s
= l
; gh_pair_p (s
); s
= ly_cdr (s
))
72 Music
* m
= unsmob_music (ly_car (s
));
73 Moment l
= m
->get_length ();
81 music_list_to_relative (SCM l
,Pitch p
, bool ret_first
)
87 for (SCM s
= l
; gh_pair_p (s
); s
= ly_cdr (s
))
89 if (Music
*m
= unsmob_music (ly_car (s
)))
91 last
= m
->to_relative_octave (last
);
97 return (ret_first
)? first
: last
;
102 compress_music_list (SCM l
, Moment m
)
104 for (SCM s
= l
; gh_pair_p (s
); s
= ly_cdr (s
))
105 unsmob_music (ly_car (s
))->compress (m
);
108 ADD_MUSIC (Music_sequence
);
111 Music_sequence::minimum_start (SCM l
)
115 for (SCM s
= l
; gh_pair_p (s
); s
= ly_cdr (s
))
117 m
= m
<? unsmob_music (ly_car (s
))->start_mom ();
123 Music_sequence::first_start (SCM l
)
127 for (SCM s
= l
; gh_pair_p (s
); s
= ly_cdr (s
))
129 Music
* mus
= unsmob_music (ly_car (s
));
130 Moment l
= mus
->get_length ();
131 Moment s
= mus
->start_mom ();
132 if (l
.to_bool () || s
.to_bool ())