2 Sequential_music_iterator.cc -- implement Sequential_music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 #include "grace-iterator.hh"
9 #include "translator-group.hh"
11 #include "sequential-music-iterator.hh"
12 #include "music-list.hh"
13 #include "request-chord-iterator.hh"
15 Sequential_music_iterator::Sequential_music_iterator ()
22 Sequential_music_iterator::Sequential_music_iterator (Sequential_music_iterator const &src)
23 : Music_iterator (src)
25 cursor_ = src.cursor_;
26 here_mom_ = src.here_mom_;
28 iter_p_ = src.iter_p_->clone ();
33 Sequential_music_iterator::~Sequential_music_iterator()
39 music_l_->origin ()->warning (_ ("Must stop before this music ends"));
46 Sequential_music_iterator::construct_children()
48 cursor_ = dynamic_cast<Music_sequence const*> (music_l_)->music_list ();
50 while (gh_pair_p (cursor_ ))
52 iter_p_ = get_iterator_p (unsmob_music (gh_car (cursor_)));
62 cursor_ = gh_cdr (cursor_);
66 move to context of child iterator if it is deeper down in the
71 Sequential_music_iterator::descend_to_child ()
74 Translator_group * child_report = child_report = iter_p_->report_to_l ();
75 if (dynamic_cast<Grace_iterator*> (iter_p_))
76 child_report = child_report->daddy_trans_l_;
78 if (report_to_l()->depth_i () < child_report->depth_i ())
79 set_translator (child_report);
86 Hier staat in feite: haal alle muziek op (startend op tijd HERE) tot
87 je iets met lengte L > 0 tegenkomt. Aangezien de preconditie is dat
88 UNTIL het eerstvolgende event is, weet je (per definitie)
92 en iets wat hierna komt (op tijd T) komt dus na tijd
94 HERE + L >= HERE + (UNTIL - HERE) = UNTIL
96 Dus als je een L>0 tegenkomt, wil je de rest niet meer. Aangezien
97 alles wat tot nu toe hebt gespaard op HERE begint, is dat precies wat
100 Misschien kan je deze comment erbij stoppen, en moeten we de
101 eigenschappen van het muziek datatype wat formaliseren, zodat deze
102 redenering helderder is.
106 Sequential_music_iterator::get_music (Moment until)const
109 if (until < pending_moment ())
113 Music_iterator * iter = iter_p_->clone ();
116 SCM nm = iter->get_music (until - here_mom_);
117 s = gh_append2 (nm, s);
120 for (SCM i = nm; gh_pair_p(i); i = gh_cdr (i))
121 m = m >? unsmob_music (gh_car (i))->length_mom ();
125 curs = gh_cdr (curs);
127 if (!gh_pair_p (curs) || m > Moment (0))
131 iter = get_iterator_p (unsmob_music (gh_car (curs)));
137 Skip events till UNTIL. We don't do any other side effects (such as
138 moving descending to child iterator contexts, because they might
139 depend on \context specs and \translator changes being executed
143 Sequential_music_iterator::skip (Moment until)
148 Moment l =iter_p_->music_length_mom ();
149 if (l >= until - here_mom_)
150 iter_p_->skip (until - here_mom_);
155 here_mom_ = here_mom_ + l;
159 curs = gh_cdr (curs);
161 if (!gh_pair_p (curs))
164 iter_p_ = get_iterator_p (unsmob_music (gh_car (curs)));
169 Sequential_music_iterator::process (Moment until)
173 iter_p_->process (until - here_mom_);
176 if the iter is still OK, there must be events left that have
184 here_mom_ += iter_p_->music_length_mom ();
190 cursor_ = gh_cdr (cursor_);
192 if (!gh_pair_p (cursor_))
197 iter_p_ = get_iterator_p (unsmob_music (gh_car (cursor_)));
204 Sequential_music_iterator::pending_moment() const
206 return iter_p_->pending_moment() + here_mom_;
211 Sequential_music_iterator::ok() const
217 Sequential_music_iterator::try_music_in_children (Music *m) const
219 return iter_p_ ? iter_p_->try_music (m) : 0;