2 lyric-combine-music-iterator.cc -- implement Lyric_combine_music_iterator
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "lyric-combine-music.hh"
13 #include "note-head.hh"
15 #include "music-iterator.hh"
17 class Lyric_combine_music_iterator
: public Music_iterator
20 Lyric_combine_music_iterator ();
21 Lyric_combine_music_iterator (Lyric_combine_music_iterator
const&src
);
22 DECLARE_SCHEME_CALLBACK (constructor
, ());
24 virtual void construct_children ();
25 virtual Moment
pending_moment () const;
26 virtual void do_quit ();
27 virtual void process (Moment
);
28 virtual Music_iterator
*try_music_in_children (Music
*) const;
30 virtual bool ok () const;
31 virtual void derived_mark () const;
32 virtual void derived_substitute (Context
*,Context
*) ;
34 bool get_busy_status ()const ;
37 Music_iterator
* music_iter_
;
38 Music_iterator
* lyric_iter_
;
43 melisma_busy (Context
* tr
)
45 SCM melisma_properties
= tr
->get_property ("melismaBusyProperties");
48 for (; gh_pair_p (melisma_properties
);
49 melisma_properties
= gh_cdr (melisma_properties
))
50 busy
= busy
|| to_boolean (tr
->internal_get_property (gh_car (melisma_properties
)));
61 Music
*melisma_playing_req
;
63 Lyric_combine_music_iterator::Lyric_combine_music_iterator ()
71 = make_music_by_name (ly_symbol2scm ("BusyPlayingEvent"));
73 = make_music_by_name (ly_symbol2scm ("MelismaPlayingEvent"));
78 Lyric_combine_music_iterator::pending_moment () const
80 Moment musnext
= music_iter_
->pending_moment ();
85 Lyric_combine_music_iterator::ok () const
87 return music_iter_
->ok ();
91 Lyric_combine_music_iterator::derived_mark ()const
94 scm_gc_mark (music_iter_
->self_scm ());
96 scm_gc_mark (lyric_iter_
->self_scm ());
100 Lyric_combine_music_iterator::derived_substitute (Context
*f
,Context
* t
)
103 music_iter_
->substitute_outlet (f
,t
);
105 lyric_iter_
->substitute_outlet (f
,t
);
109 Lyric_combine_music_iterator::construct_children ()
111 Lyric_combine_music
const * m
= dynamic_cast<Lyric_combine_music
const*> (get_music ());
113 music_iter_
= unsmob_iterator (get_iterator (m
->get_music ()));
114 lyric_iter_
= unsmob_iterator (get_iterator (m
->get_lyrics ()));
118 Lyric_combine_music_iterator::get_busy_status () const
121 We have to use both the event and the busyGrobs queue. The
122 busyGrobs queue doesn't contain any notes that have started this
124 if (try_music (busy_req
))
127 Context
* tr
= music_iter_
->get_outlet ();
129 SCM grobs
= tr
->get_property ("busyGrobs");
130 Moment now
= tr
->now_mom ();
131 for (; gh_pair_p (grobs
); grobs
= gh_cdr (grobs
))
133 SCM grob
= gh_cdar (grobs
);
134 Moment end
=*unsmob_moment (gh_caar (grobs
));
138 This is slightly ugh: we are now confunding the frontend
139 (iterators) and the backend (note heads) */
141 && Note_head::has_interface (unsmob_grob (grob
)))
150 Lyric_combine_music_iterator::melisma_busy ()
153 We can not read the property, since music_iter_->get_outlet () might
154 not be the context that sets the melisma properties, but rather a
157 return music_iter_
->try_music (melisma_playing_req
);
161 Lyric_combine_music_iterator::process (Moment m
)
163 Moment my_next
= music_iter_
->pending_moment ();
167 music_iter_
->process (m
);
169 if (get_busy_status () && !melisma_busy () && lyric_iter_
->ok ())
171 Moment m
= lyric_iter_
->pending_moment ();
172 lyric_iter_
->process (m
);
177 Lyric_combine_music_iterator::do_quit ()
180 music_iter_
->quit ();
182 lyric_iter_
->quit ();
186 Lyric_combine_music_iterator::try_music_in_children (Music
*m
) const
188 Music_iterator
* i
= music_iter_
->try_music (m
);
192 return lyric_iter_
->try_music (m
);
196 IMPLEMENT_CTOR_CALLBACK (Lyric_combine_music_iterator
);