(process_acknowledged_grobs):
[lilypond.git] / lily / music-sequence.cc
blob90e99ef8cd782e8be391ea43a610e7b57a3c29a3
1 /*
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>
8 */
9 #include "music-list.hh"
10 #include "warn.hh"
11 #include "pitch.hh"
12 #include "input.hh"
14 SCM
15 Music_sequence::music_list ()const
17 return get_mus_property ("elements");
21 Ugh this sucks. Linear. do not use.
23 void
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 ( )
32 : Music ()
36 void
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);
43 Moment
44 Music_sequence::cumulative_length (SCM l)
46 Moment cumulative;
47 Moment last_len;
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;
57 last_len = l;
60 last_len.grace_part_ = Rational (0);
61 cumulative += last_len;
63 return cumulative;
66 Moment
67 Music_sequence::maximum_length (SCM l)
69 Moment dur = 0;
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 ();
74 dur = dur >? l;
77 return dur;
80 Pitch
81 music_list_to_relative (SCM l,Pitch p, bool ret_first)
83 Pitch first = p;
84 int count=0;
86 Pitch last = p;
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);
92 if (!count ++)
93 first = last;
97 return (ret_first)? first : last;
101 void
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);
110 Moment
111 Music_sequence::minimum_start (SCM l)
113 Moment m;
115 for (SCM s = l; gh_pair_p (s); s = ly_cdr (s))
117 m = m <? unsmob_music (ly_car (s))->start_mom ();
119 return m;
122 Moment
123 Music_sequence::first_start (SCM l)
125 Moment m;
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 ())
133 return s;
135 return m;