+#include "input.hh"
+#include "international.hh"
+#include "listener.hh"
+#include "music-iterator.hh"
+#include "music.hh"
+
+/*
+ This iterator is hairy. It tracks both lyric and melody contexts,
+ and has a complicated communication route, reading/writing
+ properties in both.
+
+ In the future, this should rather be done with
+
+ \interpretAsMelodyFor { MUSIC } { LYRICS LYRICS LYRICS }
+
+ This can run an interpret step on MUSIC, generating a stream. Then
+ the stream can be perused at leisure to apply durations to all of
+ the LYRICS.
+*/
+
+class Lyric_combine_music_iterator : public Music_iterator
+{
+public:
+ Lyric_combine_music_iterator ();
+ Lyric_combine_music_iterator (Lyric_combine_music_iterator const &src);
+ DECLARE_SCHEME_CALLBACK (constructor, ());
+protected:
+ virtual void construct_children ();
+ virtual Moment pending_moment () const;
+ virtual void do_quit ();
+ virtual void process (Moment);
+ virtual bool run_always ()const;
+ virtual bool ok () const;
+ virtual void derived_mark () const;
+ virtual void derived_substitute (Context *, Context *);
+ void set_music_context (Context *to);
+private:
+ bool start_new_syllable () const;
+ Context *find_voice ();
+ DECLARE_LISTENER (set_busy);
+ DECLARE_LISTENER (check_new_context);
+
+ bool music_found_;
+ Context *lyrics_context_;
+ Context *music_context_;
+ SCM lyricsto_voice_name_;
+
+ Moment busy_moment_;
+ Moment pending_grace_moment_;
+
+ Music_iterator *lyric_iter_;
+};
+
+Lyric_combine_music_iterator::Lyric_combine_music_iterator ()
+{
+ music_found_ = false;
+ pending_grace_moment_.set_infinite (1);
+ lyric_iter_ = 0;
+ music_context_ = 0;
+ lyrics_context_ = 0;
+ busy_moment_.set_infinite (-1);
+}