2 music-sequence.cc -- implement Music_sequence
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "music-list.hh"
15 Music_sequence::truncate (int k
)
17 SCM l
= get_mus_property ("elements");
26 for (; gh_pair_p (s
) && k
--; s
= gh_cdr (s
))
31 gh_set_cdr_x (s
, SCM_EOL
);
34 set_mus_property ("elements", l
);
38 Music_sequence::music_list ()const
40 return get_mus_property ("elements");
44 Ugh this sucks. Linear. do not use.
47 Music_sequence::append_music (Music
*m
)
49 set_mus_property ("elements",
50 gh_append2( music_list(), gh_cons (m
->self_scm (), SCM_EOL
)));
51 scm_unprotect_object (m
->self_scm ());
54 Music_sequence::Music_sequence(SCM l
)
60 Music_sequence::transpose (Pitch rq
)
62 for (SCM s
= music_list (); gh_pair_p (s
); s
= gh_cdr (s
))
63 unsmob_music (gh_car (s
))->transpose (rq
);
70 Music_sequence::cumulative_length () const
73 for (SCM s
= music_list (); gh_pair_p (s
); s
= gh_cdr (s
))
74 last
+= unsmob_music (gh_car (s
))->length_mom ();
79 Music_sequence::to_relative_octave (Pitch p
)
81 return do_relative_octave (p
, false);
86 Music_sequence::maximum_length () const
89 for (SCM s
= music_list (); gh_pair_p (s
); s
= gh_cdr (s
))
90 dur
= dur
>? unsmob_music (gh_car (s
))->length_mom ();
95 Music_sequence::length_i () const
97 return scm_ilength (music_list ());
101 Music_sequence::do_relative_octave (Pitch p
, bool ret_first
)
107 for (SCM s
= music_list (); gh_pair_p (s
); s
= gh_cdr (s
))
109 last
= unsmob_music (gh_car (s
))->to_relative_octave (last
);
121 Music_sequence::compress (Moment m
)
123 for (SCM s
= music_list (); gh_pair_p (s
); s
= gh_cdr (s
))
124 unsmob_music (gh_car (s
))->compress (m
);