+pl6.jcn1
+ - repeat/alternative music layout
+********
+1.1.6
pl5.szmulewicz1
- rtti stuff
MAJOR_VERSION=1
MINOR_VERSION=1
PATCH_LEVEL=6
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=jcn1
# use the above to send patches: MY_PATCH_LEVEL is always empty for a
# released version.
--- /dev/null
+% a'' b c d \repeat 2 { { c c c c } } \alternative { { e e e e } { e e e g } } c c c c
+a'' b c d \repeat 2 { { c c c c } } \alternative { { e e e e } } c c c c
#include "command-request.hh"
#include "time-description.hh"
#include "engraver-group.hh"
+#include "repeated-music.hh"
Bar_engraver::Bar_engraver()
{
return true;
}
+ else if (Repeated_music * m = dynamic_cast<Repeated_music *> (r_l))
+ {
+ if (bar_req_l_ && bar_req_l_->equal_b (b)) // huh?
+ return false;
+ bar_req_l_ = new Bar_req ("|:");
+ return true;
+ }
return false;
#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 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 Request_column;
struct Engraver;
struct Relative_octave_music;
+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;
class Music_wrapper_iterator : public Music_iterator
{
- Music_iterator *child_iter_p_;
- Music_wrapper *music_wrapper_l();
public:
Music_wrapper_iterator ();
- ~Music_wrapper_iterator ();
+
+protected:
+ virtual ~Music_wrapper_iterator ();
+
virtual void do_print () const;
virtual void construct_children () ;
virtual void do_process_and_next (Moment) ;
virtual Moment next_moment () const;
+
+protected:
+ virtual Music_wrapper *music_wrapper_l () const;
virtual bool ok () const;
-
+
+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 "voice-iterator.hh"
+
+class Repeated_music_iterator : public virtual Music_wrapper_iterator, public virtual Sequential_music_iterator
+{
+public:
+ Repeated_music_iterator();
+
+protected:
+ ~Repeated_music_iterator ();
+
+ virtual Music_wrapper *music_wrapper_l () const;
+ virtual Sequential_music* sequential_music_l() const;
+ virtual bool ok () const;
+ virtual void do_process_and_next (Moment);
+ virtual void construct_children ();
+ virtual void start_next_element ();
+ virtual void leave_element ();
+};
+
+
+#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_wrapper* repeat_p_;
+ Sequential_music* alternative_p_;
+
+ Repeated_music (Music_wrapper *, 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 */
+
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
+*/
+#ifndef SEQUENTIAL_MUSIC_ITER_HH
+#define SEQUENTIAL_MUSIC_ITER_HH
#include "music-iterator.hh"
#include "pcursor.hh"
class Sequential_music_iterator : public Music_iterator
{
- Moment here_mom_;
- PCursor<Music*> *cursor_p_;
- Music_iterator * iter_p_;
- void start_next_element();
- void leave_element();
- void set_Sequential_music_translator();
-protected:
- Sequential_music * sequential_music_l() const;
public:
Sequential_music_iterator ();
protected:
+ virtual ~Sequential_music_iterator();
+
+ virtual Sequential_music* sequential_music_l() const;
virtual void do_print() const;
virtual void construct_children();
- ~Sequential_music_iterator();
virtual void do_process_and_next (Moment);
virtual Moment next_moment() const;
virtual bool ok() const;
+ virtual void start_next_element();
+ virtual void leave_element();
+
+private:
+ Moment here_mom_;
+ PCursor<Music*> *cursor_p_;
+ Music_iterator * iter_p_;
+ void set_Sequential_music_translator();
};
-#endif // Sequential_music_ITER_HH
+#endif // SEQUENTIAL_MUSIC_ITER_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
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 ())
}
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 {
+ Music_wrapper *w= new Music_wrapper ($4);
+ Sequential_music* s = (Sequential_music*)$6;
+ $$ = new Repeated_music (w, $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 {
--- /dev/null
+/*
+ repeated-music-iterator.cc -- implement Repeated_music_iterator
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ */
+
+#include "repeated-music-iterator.hh"
+#include "repeated-music.hh"
+#include "musical-request.hh"
+#include "translator-group.hh"
+#include "command-request.hh"
+
+Repeated_music_iterator::Repeated_music_iterator ()
+{
+}
+
+Repeated_music_iterator::~Repeated_music_iterator ()
+{
+}
+
+void
+Repeated_music_iterator::construct_children ()
+{
+ Music_wrapper_iterator::construct_children ();
+ // Sequential_music_iterator::construct_children ();
+}
+
+void
+Repeated_music_iterator::do_process_and_next (Moment m)
+{
+ if (Music_wrapper_iterator::ok ())
+ Music_wrapper_iterator::do_process_and_next (m);
+// else
+ //Sequential_music_iterator::do_process_and_next (m);
+}
+
+Music_wrapper*
+Repeated_music_iterator::music_wrapper_l () const
+{
+ return ((Repeated_music*)Music_wrapper_iterator::music_l_)->repeat_p_;
+}
+
+bool
+Repeated_music_iterator::ok () const
+{
+ return Music_wrapper_iterator::ok (); // || Sequential_music_iterator:: ok();
+}
+
+Sequential_music*
+Repeated_music_iterator::sequential_music_l () const
+{
+ return ((Repeated_music*)Sequential_music_iterator::music_l_)->alternative_p_;
+}
+
+void
+Repeated_music_iterator::start_next_element ()
+{
+ // Sequential_music_iterator::start_next_element ();
+}
+
+void
+Repeated_music_iterator::leave_element ()
+{
+ // Sequential_music_iterator::leave_element ();
+}
+
--- /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 "music-wrapper.hh"
+#include "music-list.hh"
+
+Repeated_music::Repeated_music (Music_wrapper *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)
+{
+#if 0
+ // urg?
+ repeat_p_ = (Music_wrapper*)(s.repeat_p_) ? s.repeat_p_->clone () : 0;
+ alternative_p_ = (Sequential_music*)(s.alternative_p_) ? s.alternative_p_->clone () : 0;
+#endif
+}
+
+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;
+}