#include "command-request.hh"
#include "time-description.hh"
#include "engraver-group.hh"
+#include "repeated-music.hh"
Bar_engraver::Bar_engraver()
{
-Compressed_music_iterator::Compressed_music_iterator ()
-{
- Bracket_req pr;
- pr.spantype = Span_req::START;
- // pr.plet_i_ = 1;
- start_req_p_ = new Bracket_req (pr);
- pr.spantype = Span_req::STOP;
- stop_req_p_ =new Bracket_req (pr);
-}
-
-Compressed_music_iterator::~Compressed_music_iterator ()
-{
- delete start_req_p_;
- delete stop_req_p_;
-}
-
-Compressed_music *
-Compressed_music_iterator::compressed_l () const
-{
- return (Compressed_music*) music_l_;
-}
-
-void
-Compressed_music_iterator::construct_children ()
-{
- /*
- start_req_p_->plet_i_ = compressed_l ()->den_i_;
- stop_req_p_->plet_i_ = compressed_l ()->den_i_;
- */
- Music_wrapper_iterator::construct_children ();
-}
-
void
Compressed_music_iterator::do_process_and_next (Moment m)
{
if (first_b_)
{
- bool success = report_to_l ()->try_music (compressed_l ());
+ bool success = report_to_l ()->try_music (dynamic_cast<Compressed_music const*> (music_l_));
if (!success)
music_l_->warning ( _("No one to print a tuplet start bracket"));
}
class Compressed_music_iterator : public Music_wrapper_iterator
{
-public:
- Bracket_req* start_req_p_;
- Bracket_req* stop_req_p_;
-
- Compressed_music_iterator();
- ~Compressed_music_iterator ();
+public:
+ // construction
+protected:
virtual void do_process_and_next (Moment);
- virtual void construct_children ();
- Compressed_music *compressed_l ()const;
};
#define LILY_PROTO_HH
#include "proto.hh"
-
struct Absolute_dynamic_req;
struct Abbreviation;
-struct Abbreviation_req;
+struct Abbreviation_beam;
struct Abbreviation_beam_req;
struct Abbreviation_beam_engraver;
-struct Axis_group_element;
-struct Axis_group;
-struct Translator_group;
-struct Translator;
-struct Abbreviation_beam;
+struct Abbreviation_req;
+struct Atom;
struct Audio_element;
struct Audio_column;
struct Audio_item;
struct Audio_time_signature;
struct Audio_note;
struct Audio_note_off;
-struct Performance;
struct Audio_staff;
struct Audio_tempo;
-struct Atom;
+struct Axis_group_element;
+struct Axis_group;
struct Bar;
struct Bar_column_engraver;
struct Bar_column;
struct Dynamic_req;
struct Element_group;
struct Element_group_item;
+struct Engraver;
struct Engraver_group_engraver;
struct Extender;
struct Extender_req;
struct My_lily_lexer;
struct Measure_grouping_req;
struct Melodic_req;
-struct Time_signature;
-struct Time_signature_change_req;
-struct Time_signature_engraver;
-struct Time_signature_performer;
struct Midi_def;
struct Midi_duration;
struct Midi_header;
struct Paper_score;
struct Paper_stream;
struct Partial_measure_req;
+struct Performance;
struct Performer;
struct Plet;
struct Plet_engraver;
struct Plet_req;
struct Plet_spanner;
-struct Rational;
struct Piano_brace;
struct Performer;
struct Performer_group_performer;
struct Property_iterator;
+struct Rational;
struct Request;
struct Request_column;
-struct Engraver;
struct Relative_octave_music;
+struct Repeat_engraver;
+struct Repeated_music;
+struct Repeated_music_iterator;
struct Rest;
struct Rest_collision;
struct Rest_collision_engraver;
struct Stem_beam_engraver;
struct Stem_req;
struct String;
-struct Atom;
struct Symtable;
struct Symtables;
struct Super_element;
struct Tie_engraver;
struct Tie_req;
struct Time_description;
+struct Time_signature;
+struct Time_signature_change_req;
+struct Time_signature_engraver;
+struct Time_signature_performer;
+struct Translator;
+struct Translator_group;
struct Timing_req;
struct Vertical_brace;
struct Vertical_spanner;
struct Vertical_group_spanner;
struct Vertical_align_spanner;
struct Vertical_align_engraver;
+struct Volta_spanner;
struct Align_element;
struct Sequential_music;
struct Request_chord;
/*
- music-wrapper-iterator.hh -- declare
+ music-wrapper-iterator.hh -- declare Music_wrapper_iterator
source file of the GNU LilyPond music typesetter
#include "music.hh"
#include "music-iterator.hh"
+/**
+ The iterator for a #Music_wrapper#. Since #Music_wrapper# essentially
+ does nothing, this iterator creates a child iterator and delegates
+ all work to that child.
+ */
class Music_wrapper_iterator : public Music_iterator
{
- Music_iterator *child_iter_p_;
- Music_wrapper *music_wrapper_l();
public:
Music_wrapper_iterator ();
~Music_wrapper_iterator ();
- virtual void do_print () const;
+
virtual void construct_children () ;
- virtual void do_process_and_next (Moment) ;
virtual Moment next_moment () const;
virtual bool ok () const;
-
+
+protected:
+ Music_wrapper *music_wrapper_l () const;
+ virtual void do_print () const;
+ virtual void do_process_and_next (Moment) ;
+
+private:
+ Music_iterator *child_iter_p_;
};
#endif /* MUSIC_WRAPPER_ITERATOR_HH */
--- /dev/null
+/*
+ repeated-music-iterator.hh -- declare Repeated_music_iterator
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ */
+
+#ifndef REPEATED_MUSIC_ITERATOR_HH
+#define REPEATED_MUSIC_ITERATOR_HH
+
+#include "music-wrapper-iterator.hh"
+#include "sequential-music-iterator.hh"
+
+class Repeated_music_iterator : public Music_iterator
+{
+public:
+ Repeated_music_iterator ();
+ ~Repeated_music_iterator ();
+
+ virtual void construct_children ();
+ virtual Moment next_moment () const;
+ virtual bool ok () const;
+
+protected:
+ virtual Repeated_music* repeated_music_l () const;
+ virtual void do_print () const;
+ virtual void do_process_and_next (Moment);
+
+private:
+ Music_iterator* repeat_iter_p_;
+ Sequential_music_iterator* alternative_iter_p_;
+};
+
+#endif /* REPEATED_MUSIC_ITERATOR_HH */
+
--- /dev/null
+/*
+ repeated-music.hh -- declare Repeated_music
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ */
+
+#ifndef REPEATED_MUSIC_HH
+#define REPEATED_MUSIC_HH
+
+#include "music-list.hh"
+
+/**
+ Repeats and voltas
+ */
+class Repeated_music : public Music
+{
+public:
+ int repeats_i_;
+ Music* repeat_p_;
+// Music_list* alternative_p_;
+ Sequential_music* alternative_p_;
+
+// Repeated_music (Music*, int n, Music_list*);
+ Repeated_music (Music*, int n, Sequential_music*);
+ Repeated_music (Repeated_music const& s);
+ virtual ~Repeated_music ();
+
+ virtual void do_print () const;
+ virtual void transpose (Musical_pitch p);
+ virtual Moment duration () const;
+
+ VIRTUAL_COPY_CONS(Music);
+};
+
+#endif /* REPEATED_MUSIC_HH */
+
--- /dev/null
+/*
+ Sequential_music-iter.hh -- declare Sequential_music_iterator
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#ifndef SEQUENTIAL_MUSIC_ITER_HH
+#define SEQUENTIAL_MUSIC_ITER_HH
+
+#include "music-iterator.hh"
+#include "pcursor.hh"
+
+/** Sequential_music iteration: walk each element in turn, and
+ construct an iterator for every element.
+
+ */
+class Sequential_music_iterator : public Music_iterator
+{
+public:
+ Sequential_music_iterator ();
+ ~Sequential_music_iterator ();
+
+ virtual void construct_children ();
+ virtual Moment next_moment () const;
+ virtual bool ok () const;
+
+protected:
+ Sequential_music * sequential_music_l() const;
+
+ virtual void do_print() const;
+ virtual void do_process_and_next (Moment);
+
+private:
+ Moment here_mom_;
+ PCursor<Music*> *cursor_p_;
+ Music_iterator * iter_p_;
+
+ /*
+ perhaps these can be virtual and protected iso. private?
+ */
+ void start_next_element();
+ void leave_element();
+ void set_Sequential_music_translator();
+};
+
+#endif // SEQUENTIAL_MUSIC_ITER_HH
#include "debug.hh"
#include "music-list.hh"
#include "music-iterator.hh"
-#include "voice-iterator.hh"
+#include "sequential-music-iterator.hh"
#include "property-iterator.hh"
#include "chord-iterator.hh"
#include "request-iterator.hh"
#include "music-wrapper-iterator.hh"
#include "compressed-music-iterator.hh"
#include "compressed-music.hh"
-
-
-
-
-
+#include "repeated-music.hh"
+#include "repeated-music-iterator.hh"
void
Music_iterator::do_print() const
{
-
}
void
p = new Compressed_music_iterator;
else if (dynamic_cast<Music_wrapper const *> (m))
p = new Music_wrapper_iterator;
+ else if (dynamic_cast<Repeated_music const *> (m))
+ p = new Repeated_music_iterator;
+ else
+ assert (0);
p->music_l_ = m;
if (m->translator_type_str_.length_i ())
return p;
}
-void
-Music_iterator::inherit_info(Music_iterator const *)
-{
-}
Music_iterator*
Music_iterator::get_iterator_p (Music const*m) const
{
Music_iterator*p = static_get_iterator_p (m, report_to_l());
- p->inherit_info (this);
p->construct_children();
return p;
}
}
Music_wrapper*
-Music_wrapper_iterator::music_wrapper_l ()
+Music_wrapper_iterator::music_wrapper_l () const
{
return (Music_wrapper*) music_l_;
}
+
bool
Music_wrapper_iterator::ok () const
{
#include "debug.hh"
#include "musical-pitch.hh"
+Music::Music()
+{
+}
+
+void
+Music::compress (Moment)
+{
+}
+
+void
+Music::do_print() const
+{
+}
+
Moment
Music::duration () const
{
#endif
}
-void
-Music::transpose (Musical_pitch )
-{
-
-}
-
-void
-Music::do_print() const
-{
-}
-
-
-
-
-
-
-
-Music::Music()
-{
-}
-
Musical_pitch
Music::to_relative_octave (Musical_pitch m)
{
return m;
}
-void
-Music::compress (Moment)
+void
+Music::transpose (Musical_pitch )
{
}
+
static Keyword_ent the_key_tab[]={
{"absdynamic", ABSDYNAMIC},
{"accepts", ACCEPTS},
+ {"alternative", ALTERNATIVE},
{"bar", BAR},
{"cadenza", CADENZA},
{"clef", CLEF},
{"cm", CM_T},
{"consists", CONSISTS},
{"duration", DURATION},
-// {"_", EXTENDER},
{"font", FONT},
{"grouping", GROUPING},
{"header", HEADER},
{"pt", PT_T},
{"relative", RELATIVE},
{"remove", REMOVE},
+ {"repeat", REPEAT},
{"scm", SCM_T},
{"scmfile", SCMFILE},
{"score", SCORE},
#include "relative-music.hh"
#include "transposed-music.hh"
#include "compressed-music.hh"
+#include "repeated-music.hh"
// mmm
Mudela_version oldest_version ("1.0.7");
%token ABSDYNAMIC
%token ACCEPTS
+%token ALTERNATIVE
%token BAR
%token BEAMPLET
%token CADENZA
%token PT_T
%token RELATIVE
%token REMOVE
+%token REPEAT
%token SCM_T
%token SCMFILE
%token SCORE
%type <i> open_plet_parens close_plet_parens
%type <i> sub_quotes sup_quotes
%type <music> simple_element request_chord command_element Simple_music Composite_music
+%type <music> Alternative_music Repeated_music
%type <i> abbrev_type
%type <i> int unsigned
%type <i> script_dir
| Composite_music
;
+Alternative_music: {
+ Music_list* m = new Music_list;
+ $$ = new Sequential_music (m);
+ }
+ | ALTERNATIVE '{' Music_list '}' {
+ $$ = new Sequential_music ($3);
+ }
+ ;
+
+Repeated_music: REPEAT unsigned '{' Music '}' Alternative_music {
+ // s/r conflicts -> '{' '}'
+ Sequential_music* s = (Sequential_music*)$6;
+ $$ = new Repeated_music ($4, $2, s);
+ }
+ ;
+
Sequential_music: '{' Music_list '}' {
$$ = new Sequential_music ($2);
}
$$ = new Compressed_music ($2, $4, $5);
}
+ | Repeated_music { $$ = $1; }
| Simultaneous_music { $$ = $1; }
| Sequential_music { $$ = $1; }
| TRANSPOSE musical_pitch Music {
#include "translation-property.hh"
#include "translator-group.hh"
+/**
+ There is no real processing to a property: just lookup the
+ translation unit, and set the property.
+ */
void
Property_iterator::do_process_and_next (Moment m)
{
- if (property_l()->var_str_.length_i ())
- report_to_l ()->set_property (property_l()->var_str_, property_l()->value_);
+ Translation_property const * prop = dynamic_cast<Translation_property const*> (music_l_);
+ if (prop->var_str_.length_i ())
+ report_to_l ()->set_property (prop->var_str_, prop->value_);
Music_iterator::do_process_and_next (m);
}
-
-
-Translation_property*
-Property_iterator::property_l () const
-{
- return (Translation_property*) music_l_;
-}
--- /dev/null
+/*
+ repeated-music.cc -- implement Repeated_music
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ */
+
+#include "repeated-music.hh"
+#include "musical-pitch.hh"
+
+//Repeated_music::Repeated_music (Music* r, int n, Music_list* a)
+Repeated_music::Repeated_music (Music* r, int n, Sequential_music* a)
+{
+ repeats_i_ = n;
+ repeat_p_ = r;
+ alternative_p_ = a;
+}
+
+Repeated_music::~Repeated_music ()
+{
+ delete repeat_p_;
+ delete alternative_p_;
+}
+
+Repeated_music::Repeated_music (Repeated_music const& s)
+ : Music (s)
+{
+ repeat_p_ = (s.repeat_p_) ? s.repeat_p_->clone () : 0;
+ // urg?
+// alternative_p_ = (Sequential_music*)(s.alternative_p_) ? s.alternative_p_->clone () : 0;
+}
+
+void
+Repeated_music::do_print () const
+{
+ if (repeat_p_)
+ repeat_p_->print ();
+ if (alternative_p_)
+ alternative_p_->print ();
+}
+
+void
+Repeated_music::transpose (Musical_pitch p)
+{
+ if (repeat_p_)
+ repeat_p_->transpose (p);
+ if (alternative_p_)
+ alternative_p_->transpose (p);
+}
+
+Moment
+Repeated_music::duration () const
+{
+ Moment m;
+ if (repeat_p_)
+ m += repeat_p_->duration ();
+ if (alternative_p_)
+ m += alternative_p_->duration ();
+ return m;
+}
+
--- /dev/null
+/*
+ Sequential_music_iterator.cc -- implement Sequential_music_iterator
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#include "translator-group.hh"
+#include "debug.hh"
+#include "sequential-music-iterator.hh"
+#include "music-list.hh"
+
+
+void
+Sequential_music_iterator::do_print() const
+{
+ if (iter_p_)
+ iter_p_->print();
+}
+
+Sequential_music_iterator::Sequential_music_iterator ()
+{
+ cursor_p_ = 0;
+ here_mom_ = 0;
+ iter_p_ =0;
+}
+
+Sequential_music*
+Sequential_music_iterator::sequential_music_l () const
+{
+ return (Sequential_music *)music_l_;
+}
+
+void
+Sequential_music_iterator::construct_children()
+{
+ cursor_p_ = new PCursor<Music*> (sequential_music_l ()->music_p_list_p_->top ());
+
+ while (cursor_p_->ok())
+ {
+ start_next_element();
+ if (!iter_p_->ok())
+ {
+ leave_element();
+ }
+ else
+ {
+ set_Sequential_music_translator();
+ break;
+ }
+ }
+}
+
+void
+Sequential_music_iterator::leave_element()
+{
+ delete iter_p_;
+ iter_p_ =0;
+ Moment elt_time = cursor_p_->ptr()->duration ();
+ here_mom_ += elt_time;
+ cursor_p_->next();
+}
+
+void
+Sequential_music_iterator::start_next_element()
+{
+ assert (!iter_p_);
+ iter_p_ = get_iterator_p ( cursor_p_->ptr());
+}
+
+void
+Sequential_music_iterator::set_Sequential_music_translator()
+{
+ if (iter_p_->report_to_l()->depth_i () > report_to_l ()->depth_i ())
+ set_translator (iter_p_->report_to_l());
+}
+
+Sequential_music_iterator::~Sequential_music_iterator()
+{
+ delete cursor_p_;
+ assert (! iter_p_);
+}
+
+
+
+
+void
+Sequential_music_iterator::do_process_and_next (Moment until)
+{
+ while (1)
+ {
+ 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())
+ {
+ leave_element();
+
+ if (cursor_p_->ok())
+ {
+ start_next_element();
+ set_Sequential_music_translator();
+ }
+ else
+ {
+ goto loopexit;
+ }
+ }
+ }
+
+loopexit:
+
+ Music_iterator::do_process_and_next (until);
+}
+
+Moment
+Sequential_music_iterator::next_moment() const
+{
+ return iter_p_->next_moment() + here_mom_;
+}
+
+bool
+Sequential_music_iterator::ok() const
+{
+ return iter_p_;
+}
+
for (int i= started_span_p_arr_.size ();
i < compressed_music_arr_.size (); i++)
{
- Plet_spanner* glep = new Plet_spanner ();
+ Plet_spanner* glep = new Plet_spanner;
started_span_p_arr_.push (glep);
Text_def *t = new Text_def;