+1.3.86.jcn1
+===========
+
+* Fixed chord iteration.
+
+1.3.85.jcn5
+===========
+
+* Modified part-combiner to use new get_music ()/next () music iterator
+ functionality.
+
+1.3.85.jcn4
+===========
+
+* Added clone () to music iterators, so that we can do next () on a copy.
+
+1.3.85.jcn3
+===========
+
+* Added get_music () and next () to music iterators.
+
1.3.85.hwn2
===========
MAJOR_VERSION=1
MINOR_VERSION=3
PATCH_LEVEL=86
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=jcn1
# use the above to send patches: MY_PATCH_LEVEL is always empty for a
# released version.
#include "music-wrapper-iterator.hh"
#include "direction.hh"
-class Auto_change_iterator : public Music_wrapper_iterator
+class Auto_change_iterator : public Music_wrapper_iterator
{
- Direction where_dir_;
+public:
+ VIRTUAL_COPY_CONS (Music_iterator);
+ Auto_change_iterator ();
- void change_to (Music_iterator* , String, String);
protected:
virtual void do_process_and_next (Moment);
-public:
- Auto_change_iterator ();
+
+private:
+ Direction where_dir_;
+ void change_to (Music_iterator* , String, String);
};
#endif /* AUTO_CHANGE_ITERATOR_HH */
class Change_iterator : public Music_iterator
{
- void error (String);
-
-protected:
- virtual void do_process_and_next (Moment);
-
public:
+ VIRTUAL_COPY_CONS (Music_iterator);
/*
CTOR is public
*/
+
+protected:
+ virtual void do_process_and_next (Moment);
+
+private:
+ void error (String);
};
#endif
class Chord_tremolo_iterator : public Music_iterator
{
- Moment factor_;
- Music_iterator * child_iter_p_;
-
public:
+ VIRTUAL_COPY_CONS (Music_iterator);
Chord_tremolo_iterator ();
protected:
virtual void do_print () const;
virtual void do_process_and_next (Moment) ;
virtual Music_iterator *try_music_in_children (Music *) const;
+
+private:
+ Moment factor_;
+ Music_iterator * child_iter_p_;
};
*/
class Folded_repeat_iterator : public Music_iterator
{
- Music_iterator * main_iter_p_;
- Music_iterator * alternative_iter_p_;
- int count_;
- Moment main_length_mom_;
public:
+ VIRTUAL_COPY_CONS (Music_iterator);
Folded_repeat_iterator ();
~Folded_repeat_iterator ();
virtual void do_process_and_next (Moment);
virtual Music_iterator *try_music_in_children (Music *) const;
+
+private:
+ Music_iterator * main_iter_p_;
+ Music_iterator * alternative_iter_p_;
+ int count_;
+ Moment main_length_mom_;
};
#endif /* FOLDED_REPEAT_ITERATOR_HH */
class Grace_iterator : public Music_wrapper_iterator
{
public:
+ VIRTUAL_COPY_CONS (Music_iterator);
~Grace_iterator ();
virtual void construct_children () ;
virtual void do_process_and_next (Moment);
class Interpretation_context_handle
{
- Translator_group * report_to_l_;
- void down ();
- void up (Translator_group*);
public:
~Interpretation_context_handle ();
Interpretation_context_handle ();
+ Interpretation_context_handle* clone () const;
void set_translator (Translator_group*);
bool try_music (Music *);
void operator =(Interpretation_context_handle const&);
Interpretation_context_handle (Interpretation_context_handle const&);
Translator_group * report_to_l () const;
+
+private:
+ Translator_group * report_to_l_;
+ void down ();
+ void up (Translator_group*);
};
#endif /* INTERPRETATION_CONTEXT_HANDLE_HH */
class Lyric_combine_music_iterator : public Music_iterator
{
- Music_iterator * music_iter_p_;
- Music_iterator * lyric_iter_p_;
-
+public:
+ VIRTUAL_COPY_CONS (Music_iterator);
+ Lyric_combine_music_iterator ();
+
protected:
virtual void construct_children ();
virtual Moment next_moment () const;
virtual bool ok () const;
virtual void do_print () const;
virtual ~Lyric_combine_music_iterator ();
-public:
- Lyric_combine_music_iterator ();
+
+private:
+ Music_iterator * music_iter_p_;
+ Music_iterator * lyric_iter_p_;
};
#endif /* LYRIC_COMBINE_MUSIC_ITERATOR_HH */
The state of an iterator would be the intersection of the particular music
construct with one point in musical time.
*/
-class Music_iterator {
- Interpretation_context_handle handle_;
-
-protected:
- Music * music_l_;
-
- /// ugh. JUNKME
- bool first_b_;
-
- /**
- Do the actual printing. This should be overriden in derived classes. It
- is called by #print#, in the public interface
- */
- virtual void do_print() const;
-
- /**
- Find a bottom notation context to deliver requests to.
- */
- virtual Translator_group* get_req_translator_l();
-
- /**
- Get an iterator for MUS, inheriting the translation unit from THIS.
- */
- Music_iterator* get_iterator_p (Music *mus) const;
-
- /** Do the actual move. This should be overriden in derived
- classes. It is called by #process_and_next#, the public interface
- */
- virtual void do_process_and_next (Moment until);
-
-
- virtual Music_iterator* try_music_in_children (Music *) const;
-
+class Music_iterator
+{
public:
+ VIRTUAL_COPY_CONS (Music_iterator);
+
+ Music_iterator ();
+ Music_iterator (Music_iterator const&);
+ virtual ~Music_iterator ();
/**
Do the reporting. Will try MUSIC_L_ in its own translator first,
/**
The translation unit that we this iterator is reporting to now.
*/
- Translator_group*report_to_l() const;
+ Translator_group*report_to_l () const;
void set_translator (Translator_group*);
static Music_iterator* static_get_iterator_p (Music * mus);
void init_translator (Music *, Translator_group *);
- Music_iterator();
-
/// Find the next interesting point in time.
- virtual Moment next_moment() const;
+ virtual Moment next_moment () const;
///Are we finished with this piece of music?
- virtual bool ok() const;
-
- virtual ~Music_iterator();
+ virtual bool ok () const;
+ virtual Music* get_music ();
+ virtual bool next ();
///Report all musical information that occurs between now and UNTIL
void process_and_next (Moment until);
Construct sub-iterators, and set the translator to
report to.
*/
- virtual void construct_children();
- void print() const;
+ virtual void construct_children ();
+ void print () const;
+
+protected:
+ Music * music_l_;
+
+ /// ugh. JUNKME
+ bool first_b_;
+
+ /**
+ Do the actual printing. This should be overriden in derived classes. It
+ is called by #print#, in the public interface
+ */
+ virtual void do_print () const;
+
+ /**
+ Find a bottom notation context to deliver requests to.
+ */
+ virtual Translator_group* get_req_translator_l ();
+
+ /**
+ Get an iterator for MUS, inheriting the translation unit from THIS.
+ */
+ Music_iterator* get_iterator_p (Music *) const;
+
+ /** Do the actual move. This should be overriden in derived
+ classes. It is called by #process_and_next#, the public interface
+ */
+ virtual void do_process_and_next (Moment until);
+
+ virtual Music_iterator* try_music_in_children (Music *) const;
+
+private:
+ Interpretation_context_handle handle_;
};
#endif // MUSIC_ITERATOR_HH
class Music_wrapper_iterator : public Music_iterator
{
public:
+ VIRTUAL_COPY_CONS (Music_iterator);
Music_wrapper_iterator ();
+ Music_wrapper_iterator (Music_wrapper_iterator const&);
~Music_wrapper_iterator ();
virtual void construct_children () ;
virtual Moment next_moment () const;
virtual bool ok () const;
+ virtual Music* get_music ();
+ virtual bool next ();
protected:
virtual void do_print () const;
class Part_combine_music_iterator : public Music_iterator
{
public:
+ VIRTUAL_COPY_CONS (Music_iterator);
Part_combine_music_iterator ();
protected:
Music_iterator * first_iter_p_;
Music_iterator * second_iter_p_;
- Moment now_;
Moment first_until_;
Moment second_until_;
-
- bool combined_b_;
};
#endif /* PART_COMBINE_MUSIC_ITERATOR_HH */
class Property_iterator : public Music_iterator
{
public:
+ VIRTUAL_COPY_CONS (Music_iterator);
// construction
protected:
virtual void do_process_and_next (Moment);
class Push_property_iterator : public Music_iterator
{
+public:
+ VIRTUAL_COPY_CONS (Music_iterator);
protected:
virtual void do_process_and_next (Moment);
};
class Pop_property_iterator : public Music_iterator
{
+public:
+ VIRTUAL_COPY_CONS (Music_iterator);
protected:
virtual void do_process_and_next (Moment);
};
/**
Walk through a Request_chord
*/
-class Request_chord_iterator : public Music_iterator {
+class Request_chord_iterator : public Music_iterator
+{
Request_chord * elt_l () const;
/**
cache elt_l ()->length_mom ().
bool last_b_;
public:
+ VIRTUAL_COPY_CONS (Music_iterator);
Request_chord_iterator ();
+ Request_chord_iterator (Request_chord_iterator const&);
+ virtual bool next ();
+ virtual bool ok () const;
protected:
virtual void do_process_and_next (Moment);
virtual Moment next_moment() const;
virtual void construct_children();
- virtual bool ok() const;
virtual void do_print() const;
};
-/*
- request-iterator.hh -- declare Request_iterator
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#ifndef REQUEST_ITERATOR_HH
-#define REQUEST_ITERATOR_HH
-
-#include "music-iterator.hh"
-
-class Simple_music_iterator : public Music_iterator
-{
-public:
-protected:
- virtual void do_process_and_next (Moment );
-};
-
-#endif /* REQUEST_ITERATOR_HH */
-
class Sequential_music_iterator : public Music_iterator
{
public:
+ VIRTUAL_COPY_CONS (Music_iterator);
Sequential_music_iterator ();
+ Sequential_music_iterator (Sequential_music_iterator const&);
virtual ~Sequential_music_iterator ();
virtual void construct_children ();
virtual Moment next_moment () const;
virtual bool ok () const;
+ virtual Music* get_music ();
+ virtual bool next ();
protected:
virtual void do_print() const;
--- /dev/null
+/*
+ simple-music-iterator.hh -- declare Simple_music_iterator
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ */
+
+#ifndef SIMPLE_MUSIC_ITERATOR_HH
+#define SIMPLE_MUSIC_ITERATOR_HH
+
+#include "music-iterator.hh"
+
+class Simple_music_iterator : public Music_iterator
+{
+public:
+ VIRTUAL_COPY_CONS (Music_iterator);
+ Simple_music_iterator ();
+ Simple_music_iterator (Simple_music_iterator const &);
+
+protected:
+ virtual void do_process_and_next (Moment );
+};
+
+#endif /* SIMPLE_MUSIC_ITERATOR_HH */
+
#ifndef SIMULTANEOUS_MUSIC_ITERATOR_HH
#define SIMULTANEOUS_MUSIC_ITERATOR_HH
+
#include "music-iterator.hh"
#include "cons.hh"
class Simultaneous_music_iterator : public Music_iterator
{
public:
+ VIRTUAL_COPY_CONS (Music_iterator);
+ Simultaneous_music_iterator ();
+ Simultaneous_music_iterator (Simultaneous_music_iterator const&);
+ virtual ~Simultaneous_music_iterator ();
/// make a new context for every child.
bool separate_contexts_b_;
-
- Simultaneous_music_iterator ();
- virtual ~Simultaneous_music_iterator ();
+ int cursor_i_;
virtual void construct_children ();
virtual Moment next_moment () const;
virtual bool ok () const;
+ virtual bool next ();
+ virtual Music* get_music ();
protected:
virtual void do_print () const;
class Time_scaled_music_iterator : public Music_wrapper_iterator
{
public:
+ VIRTUAL_COPY_CONS (Music_iterator);
// construction
protected:
virtual void do_process_and_next (Moment);
class Unfolded_repeat_iterator : public Music_iterator
{
public:
+ VIRTUAL_COPY_CONS (Music_iterator);
/**
How often have we done the body (assuming bodies are interspersed.)?
*/
#include "interpretation-context-handle.hh"
#include "translator-group.hh"
+Interpretation_context_handle::Interpretation_context_handle()
+{
+ report_to_l_ =0;
+}
+
+Interpretation_context_handle::Interpretation_context_handle (Interpretation_context_handle const&s)
+{
+ report_to_l_ =0;
+ if (s.report_to_l_)
+ up (s.report_to_l_ );
+}
+
+Interpretation_context_handle*
+Interpretation_context_handle::clone () const
+{
+ Interpretation_context_handle* handle = new Interpretation_context_handle;
+ handle->report_to_l_ = this->report_to_l_;
+ return handle;
+}
+
+Interpretation_context_handle::~Interpretation_context_handle ()
+{
+ if (report_to_l_)
+ down ();
+}
+
void
Interpretation_context_handle::up (Translator_group*t)
{
return report_to_l_->try_music (m);
}
-Interpretation_context_handle::Interpretation_context_handle (Interpretation_context_handle const&s)
-{
- report_to_l_ =0;
- if (s.report_to_l_)
- up (s.report_to_l_ );
-}
-
void
Interpretation_context_handle::operator = (Interpretation_context_handle const &s)
{
return report_to_l_;
}
-Interpretation_context_handle::Interpretation_context_handle()
-{
- report_to_l_ =0;
-}
-
-Interpretation_context_handle::~Interpretation_context_handle ()
-{
- if (report_to_l_)
- down ();
-}
#include "part-combine-music.hh"
#include "part-combine-music-iterator.hh"
#include "request.hh"
-#include "request-iterator.hh"
+#include "simple-music-iterator.hh"
#include "output-property.hh"
#include "chord-tremolo-iterator.hh"
+Music_iterator::Music_iterator ()
+{
+ first_b_ = true;
+}
+
+Music_iterator::Music_iterator (Music_iterator const& src)
+{
+ first_b_ = src.first_b_;
+ handle_ = *src.handle_.clone ();
+ music_l_ = src.music_l_;
+}
+
+Music_iterator::~Music_iterator()
+{
+}
+
void
Music_iterator::do_print() const
{
{
}
-Music_iterator::~Music_iterator()
-{
-}
-
Moment
Music_iterator::next_moment() const
{
}
bool
-Music_iterator::ok() const
+Music_iterator::ok () const
{
return first_b_;
}
+Music*
+Music_iterator::get_music ()
+{
+ if (ok ())
+ return music_l_;
+ return 0;
+}
+
+bool
+Music_iterator::next ()
+{
+ first_b_ = false;
+ return ok ();
+}
+
Music_iterator*
Music_iterator::static_get_iterator_p (Music *m)
{
return p;
}
-Music_iterator::Music_iterator()
-{
- first_b_ = true;
-}
-
Music_iterator*
Music_iterator::try_music (Music *m) const
{
child_iter_p_ =0;
}
+Music_wrapper_iterator::Music_wrapper_iterator (Music_wrapper_iterator const &src)
+ : Music_iterator (src)
+{
+ child_iter_p_ = src.child_iter_p_->clone ();
+}
+Music_wrapper_iterator::~Music_wrapper_iterator ()
+{
+ delete child_iter_p_;
+}
void
Music_wrapper_iterator::do_print () const
get_iterator_p (dynamic_cast<Music_wrapper const*> (music_l_)->element ());
}
-Music_wrapper_iterator::~Music_wrapper_iterator ()
-{
- delete child_iter_p_;
-}
-
-
bool
Music_wrapper_iterator::ok () const
{
Music_iterator::do_process_and_next (m);
}
+Music*
+Music_wrapper_iterator::get_music ()
+{
+ return child_iter_p_->get_music ();
+}
+
+bool
+Music_wrapper_iterator::next ()
+{
+ return child_iter_p_->next ();
+}
Moment
Music_wrapper_iterator::next_moment () const
#include "part-combine-music-iterator.hh"
#include "translator-group.hh"
#include "musical-request.hh"
+#include "music-sequence.hh"
#include "warn.hh"
Part_combine_music_iterator::Part_combine_music_iterator ()
{
- combined_b_ = true;
-
- now_ = 0;
first_iter_p_ = 0;
second_iter_p_ = 0;
first_until_ = 0;
error (_f ("none of these in my family: `%s'", to_id.ch_C ()));
}
-Pitch_interrogate_req* first_spanish_inquisition; // nobody expects it
-Pitch_interrogate_req* second_spanish_inquisition; // won't strike twice
-
-Rhythm_interrogate_req* first_rhythmic_inquisition;
-Rhythm_interrogate_req* second_rhythmic_inquisition;
-
void
Part_combine_music_iterator::do_process_and_next (Moment m)
{
Part_combine_music const * p = dynamic_cast<Part_combine_music const* > (music_l_);
- now_ = next_moment ();
+ Moment now = next_moment ();
- /*
- Hmm, shouldn't we check per iterator if next_moment < m?
- */
+ Array<Musical_pitch> first_pitches;
+ Array<Duration> first_durations;
if (first_iter_p_->ok ())
- first_iter_p_->process_and_next (m);
-
- if (second_iter_p_->ok ())
- second_iter_p_->process_and_next (m);
-
- Music_iterator::do_process_and_next (m);
-
- /*
- TODO:
-
- * Maybe we need a Skip_engraver?
-
- (check): can this all be handled now?
-
- Maybe different modes exist?
-
- * Wind instruments (Flute I/II)
- * Hymnals:
-
-
- Rules for Hymnals/SATB (John Henckel <henckel@iname.com>):
-
- 1. if S and A differ by less than a third, the stems should be up/down.
- 2. else if S and A have different values, the stems should be up/down.
- 3. else if A sings "la" or higher, both S and A stems should be down.
- 4. else both stems should be up
-
- * This may get really tricky: combining voices/staffs: string instruments
+ {
+ Music_iterator* i = first_iter_p_->clone ();
+ Moment until = i->next_moment ();
+
+ /* Urg, silly first_b_ stuff */
+ if (now && i->next ())
+ until = i->next_moment ();
+
+ /* How about a 'now_moment ()' for iterators? */
+ for (; i->ok () && i->next_moment () == until; i->next ())
+ {
+ if (Music_sequence* m = dynamic_cast<Music_sequence *> (i->get_music ()))
+ {
+ for (SCM s = m->music_list (); gh_pair_p (s); s = gh_cdr (s))
+ {
+ Music *u = unsmob_music (gh_car (s));
+ if (Melodic_req *r = dynamic_cast<Melodic_req *> (u))
+ first_pitches.push (r->pitch_);
+ if (Rhythmic_req *r = dynamic_cast<Rhythmic_req *> (u))
+ first_durations.push (r->duration_);
+ }
+ }
+ }
+ }
- */
-
- if (!first_spanish_inquisition)
- first_spanish_inquisition = new Pitch_interrogate_req;
- first_iter_p_->try_music (first_spanish_inquisition);
+ Array<Musical_pitch> second_pitches;
+ Array<Duration> second_durations;
+ if (second_iter_p_->ok ())
+ {
+ Music_iterator* i = second_iter_p_->clone ();
+ Moment until = i->next_moment ();
+
+ /* Urg, silly second_b_ stuff */
+ if (now && i->next ())
+ until = i->next_moment ();
+
+ /* How about a 'now_moment ()' for iterators? */
+ for (; i->ok () && i->next_moment () == until; i->next ())
+ {
+ if (Music_sequence* m = dynamic_cast<Music_sequence *> (i->get_music ()))
+ {
+ for (SCM s = m->music_list (); gh_pair_p (s); s = gh_cdr (s))
+ {
+ Music *u = unsmob_music (gh_car (s));
+ if (Melodic_req *r = dynamic_cast<Melodic_req *> (u))
+ second_pitches.push (r->pitch_);
+ if (Rhythmic_req *r = dynamic_cast<Rhythmic_req *> (u))
+ second_durations.push (r->duration_);
+ }
+ }
+ }
+ }
- if (!second_spanish_inquisition)
- second_spanish_inquisition = new Pitch_interrogate_req;
- second_iter_p_->try_music (second_spanish_inquisition);
-
- Array<Musical_pitch>* first_pitches = &first_spanish_inquisition->pitch_arr_;
- Array<Musical_pitch>* second_pitches = &second_spanish_inquisition->pitch_arr_;
-
- if (!first_rhythmic_inquisition)
- first_rhythmic_inquisition = new Rhythm_interrogate_req;
- first_iter_p_->try_music (first_rhythmic_inquisition);
-
- if (!second_rhythmic_inquisition)
- second_rhythmic_inquisition = new Rhythm_interrogate_req;
- second_iter_p_->try_music (second_rhythmic_inquisition);
-
- Array<Duration>* first_durations = &first_rhythmic_inquisition->duration_arr_;
- Array<Duration>* second_durations = &second_rhythmic_inquisition->duration_arr_;
-
SCM interval = SCM_BOOL_F;
- if (first_pitches->size () && second_pitches->size ())
+ if (first_pitches.size () && second_pitches.size ())
{
- first_pitches->sort (Musical_pitch::compare);
- second_pitches->sort (Musical_pitch::compare);
- interval = gh_int2scm (first_pitches->top ().steps ()
- - (*second_pitches)[0].steps ());
+ first_pitches.sort (Musical_pitch::compare);
+ second_pitches.sort (Musical_pitch::compare);
+ interval = gh_int2scm (first_pitches.top ().steps ()
+ - second_pitches[0].steps ());
}
- if (first_durations->size ())
+ if (first_durations.size ())
{
- first_durations->sort (Duration::compare);
- Moment new_until = now_ + first_durations->top ().length_mom ();
+ first_durations.sort (Duration::compare);
+ Moment new_until = now + first_durations.top ().length_mom ();
if (new_until > first_until_)
first_until_ = new_until;
}
- if (second_durations->size ())
+ if (second_durations.size ())
{
- second_durations->sort (Duration::compare);
- Moment new_until = now_ + second_durations->top ().length_mom ();
+ second_durations.sort (Duration::compare);
+ Moment new_until = now + second_durations.top ().length_mom ();
if (new_until > second_until_)
second_until_ = new_until;
}
+#if 0 /* DEBUG */
+ printf ("now: %s\n", now.str ().ch_C ());
+ printf ("first: ");
+ for (int i = 0; i < first_pitches.size (); i++)
+ {
+ printf ("%s, ", first_pitches[i].str ().ch_C ());
+ }
+ printf ("\nsecond: ");
+ for (int i = 0; i < second_pitches.size (); i++)
+ {
+ printf ("%s, ", second_pitches[i].str ().ch_C ());
+ }
+ printf ("\n");
+#endif
+
Translator_group * fir = first_iter_p_->report_to_l ();
Translator_group * sir = second_iter_p_->report_to_l ();
- bool solo_b = (first_pitches->empty () != second_pitches->empty ())
- && !(first_until_ > now_ && second_until_ > now_);
+ bool solo_b = (first_pitches.empty () != second_pitches.empty ())
+ && !(first_until_ > now && second_until_ > now);
- bool unirhythm_b = !solo_b && !compare (first_durations, second_durations);
- bool unison_b = unirhythm_b && !first_pitches->empty ()
- &&!compare (first_pitches, second_pitches);
- bool unisilence_b = unirhythm_b && first_pitches->empty ();
+ bool unirhythm_b = !solo_b && !compare (&first_durations, &second_durations);
+ bool unison_b = unirhythm_b && !first_pitches.empty ()
+ &&!compare (&first_pitches, &second_pitches);
+ bool unisilence_b = unirhythm_b && first_pitches.empty ();
Translator_group * fd = fir->find_create_translator_l (p->what_str_, "one");
Translator_group * sd = sir->find_create_translator_l (p->what_str_, "two");
split_interval_b = true;
}
- /*
- Hmm, maybe we should set/check combined_b_ against
+ bool combined_b = first_iter_p_->report_to_l ()->daddy_trans_l_
+ == second_iter_p_->report_to_l ()->daddy_trans_l_;
- first_iter_p_->report_to_l () == second_iter_p_->report_to_l ()
-
- ?
- */
-
- String to_id = combined_b_ ? "one" : "two";
- if ((!unirhythm_b && combined_b_)
- || (split_interval_b && combined_b_)
- || (solo_b && combined_b_)
- /*|| (unisilence_b && combined_b_) */
+ String to_id = combined_b ? "one" : "two";
+ if ((!unirhythm_b && combined_b)
+ || (split_interval_b && combined_b)
+ || (solo_b && combined_b)
+ /*|| (unisilence_b && combined_b) */
|| ((unirhythm_b || unison_b || unisilence_b)
- && !combined_b_ && !split_interval_b && !solo_b))
+ && !combined_b && !split_interval_b && !solo_b))
{
- combined_b_ = !combined_b_;
- to_id = combined_b_ ? "one" : "two";
+ combined_b = !combined_b;
+ to_id = combined_b ? "one" : "two";
change_to (second_iter_p_, p->what_str_, to_id);
}
- if (!combined_b_)
+ if (!combined_b)
sir = second_iter_p_->report_to_l ();
SCM b = unirhythm_b ? SCM_BOOL_T : SCM_BOOL_F;
sd->set_property ("unison", b);
b = solo_b ? SCM_BOOL_T : SCM_BOOL_F;
- if (first_pitches->size ())
+ if (first_pitches.size ())
{
fd->set_property ("solo", b);
sd->set_property ("solo", SCM_BOOL_F);
}
- if (second_pitches->size ())
+ if (second_pitches.size ())
{
fd->set_property ("solo", SCM_BOOL_F);
sd->set_property ("solo", b);
}
- first_pitches->clear ();
- second_pitches->clear ();
- first_durations->clear ();
- second_durations->clear ();
+ /*
+ Hmm, shouldn't we check per iterator if next_moment < m?
+ */
+ if (first_iter_p_->ok ())
+ first_iter_p_->process_and_next (m);
+
+ if (second_iter_p_->ok ())
+ second_iter_p_->process_and_next (m);
+
+ Music_iterator::do_process_and_next (m);
}
Music_iterator*
#include "music-list.hh"
#include "request.hh"
+Request_chord_iterator::Request_chord_iterator ()
+{
+ last_b_ = false;
+}
+Request_chord_iterator::Request_chord_iterator (Request_chord_iterator const &src)
+ : Music_iterator (src)
+{
+ last_b_ = src.last_b_;
+ elt_length_mom_ = src.elt_length_mom_;
+}
void
Request_chord_iterator::construct_children()
return (Request_chord*) music_l_;
}
-Request_chord_iterator::Request_chord_iterator ()
-{
- last_b_ = false;
-}
-
-
bool
Request_chord_iterator::ok() const
{
#endif
}
+bool
+Request_chord_iterator::next ()
+{
+ if (first_b_)
+ first_b_ = false;
+ else
+ last_b_ = true;
+ return ok ();
+}
+
void
-Request_chord_iterator::do_process_and_next (Moment mom)
+Request_chord_iterator::do_process_and_next (Moment)
{
+ // URG
if (first_b_)
{
- for (SCM s = dynamic_cast<Music_sequence *> (music_l_)->music_list (); gh_pair_p (s); s = gh_cdr (s))
+ for (SCM s = dynamic_cast<Music_sequence *> (get_music ())->music_list (); gh_pair_p (s); s = gh_cdr (s))
{
Music *mus = unsmob_music (gh_car (s));
if (Request * req_l = dynamic_cast<Request*> (mus))
mus->origin ()->warning (_f ("Huh? Not a Request: `%s'",
classname (mus)));
}
- first_b_ = false;
}
- if (mom >= elt_length_mom_)
- last_b_ = true;
+ next ();
}
-/*
- request-iterator.cc -- implement Simple_music_iterator
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-#include "request-iterator.hh"
-#include "music.hh"
-#include "input.hh"
-
-void
-Simple_music_iterator::do_process_and_next (Moment m)
-{
- if (first_b_)
- {
- bool g= try_music (music_l_);
- if (!g)
- music_l_->origin ()->warning (_f ("Junking music: `%s'", classname(music_l_)));
-
- first_b_ = false;
- }
- Music_iterator::do_process_and_next (m);
-}
#include "music-list.hh"
#include "request-chord-iterator.hh"
+Sequential_music_iterator::Sequential_music_iterator ()
+{
+ cursor_ = 0;
+ here_mom_ = 0;
+ iter_p_ =0;
+}
-void
-Sequential_music_iterator::do_print() const
+Sequential_music_iterator::Sequential_music_iterator (Sequential_music_iterator const &src)
+ : Music_iterator (src)
+{
+ cursor_ = src.cursor_;
+ here_mom_ = src.here_mom_;
+ iter_p_ = src.iter_p_->clone ();
+}
+
+Sequential_music_iterator::~Sequential_music_iterator()
{
if (iter_p_)
- iter_p_->print();
+ {
+ if (iter_p_->ok ())
+ music_l_->origin ()->warning (_ ("Must stop before this music ends"));
+ delete iter_p_;
+ iter_p_ = 0;
+ }
}
-Sequential_music_iterator::Sequential_music_iterator ()
+void
+Sequential_music_iterator::do_print() const
{
- cursor_ = 0;
- here_mom_ = 0;
- iter_p_ =0;
+ if (iter_p_)
+ iter_p_->print();
}
void
set_translator (child_report);
}
-Sequential_music_iterator::~Sequential_music_iterator()
+Music*
+Sequential_music_iterator::get_music ()
{
- if (iter_p_)
+ if (ok ())
+ return unsmob_music (gh_car (cursor_));
+
+ return 0;
+}
+
+bool
+Sequential_music_iterator::next ()
+{
+ if (ok ())
{
+ bool b = false;
if (iter_p_->ok ())
- music_l_->origin ()->warning (_ ("Must stop before this music ends"));
- delete iter_p_;
- iter_p_ = 0;
+ b = iter_p_->next ();
+ if (!b)
+ {
+ set_sequential_music_translator ();
+ leave_element ();
+ if (gh_pair_p (cursor_))
+ start_next_element ();
+ b = ok ();
+ }
+ return b;
}
+ return false;
}
+/*
+ This should use get_music () and next ()
+ */
void
Sequential_music_iterator::do_process_and_next (Moment until)
{
- if (!iter_p_)
- return;
-
- while (1)
+ if (ok ())
{
- Moment local_until = until - here_mom_;
- while (iter_p_->ok())
- {
- Moment here = iter_p_->next_moment();
- if (here != local_until)
- goto loopexit;
-
- iter_p_->process_and_next (local_until);
- }
-
- if (!iter_p_->ok())
+ while (1)
{
- set_sequential_music_translator();
- leave_element();
+ Moment local_until = until - here_mom_;
+ while (iter_p_->ok ())
+ {
+ Moment here = iter_p_->next_moment ();
+ if (here != local_until)
+ return Music_iterator::do_process_and_next (until);
+
+ iter_p_->process_and_next (local_until);
+ }
- if (gh_pair_p (cursor_))
- start_next_element();
- else
- goto loopexit;
+ if (!iter_p_->ok ())
+ {
+ set_sequential_music_translator ();
+ leave_element ();
+
+ if (gh_pair_p (cursor_))
+ start_next_element ();
+ else
+ return Music_iterator::do_process_and_next (until);
+ }
}
}
-
-loopexit:
-
- Music_iterator::do_process_and_next (until);
}
Moment
--- /dev/null
+/*
+ simple-music-iterator.cc -- implement Simple_music_iterator
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ */
+
+#include "simple-music-iterator.hh"
+#include "music.hh"
+#include "input.hh"
+
+Simple_music_iterator::Simple_music_iterator ()
+ : Music_iterator ()
+{
+}
+
+Simple_music_iterator::Simple_music_iterator (Simple_music_iterator const &src)
+ : Music_iterator (src)
+{
+}
+
+void
+Simple_music_iterator::do_process_and_next (Moment m)
+{
+ if (ok ())
+ {
+ bool b = try_music (get_music ());
+ if (!b)
+ music_l_->origin ()->warning (_f ("Junking music: `%s'",
+ classname (music_l_)));
+
+ }
+ Music_iterator::do_process_and_next (m);
+}
Simultaneous_music_iterator::Simultaneous_music_iterator ()
{
separate_contexts_b_ = false;
+ cursor_i_ = 0;
+}
+
+Simultaneous_music_iterator::Simultaneous_music_iterator (Simultaneous_music_iterator const& src)
+ : Music_iterator (src)
+{
+ cursor_i_ = src.cursor_i_;
+ separate_contexts_b_ = src.separate_contexts_b_;
+ for (Cons<Music_iterator> *p = children_p_list_.head_; p; p = p->next_)
+ {
+ Music_iterator *i = p->car_;
+ children_p_list_.append (new Killing_cons<Music_iterator> (i->clone (), 0));
+ }
}
Simultaneous_music_iterator::~Simultaneous_music_iterator ()
children_p_list_.junk ();
}
+bool
+Simultaneous_music_iterator::next ()
+{
+ if (cursor_i_ < children_p_list_.size_i ())
+ cursor_i_++;
+ return cursor_i_ < children_p_list_.size_i ();
+}
+
+Music*
+Simultaneous_music_iterator::get_music ()
+{
+ if (cursor_i_ < children_p_list_.size_i ())
+ {
+ Cons<Music_iterator> *p = children_p_list_.head_;
+ for (int i = 0; i <= cursor_i_ && p; i++)
+ p = p->next_;
+ if (p)
+ return p->car_->get_music ();
+ }
+ return 0;
+}
+
void
Simultaneous_music_iterator::construct_children()
{
Translator_group::~Translator_group ()
{
- assert (removable_b());
+
+ //assert (removable_b());
}