]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/musical-request.cc (music-duration-length,
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 25 Sep 2002 23:21:49 +0000 (23:21 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 25 Sep 2002 23:21:49 +0000 (23:21 +0000)
music-duration-compress): new functions.

* lily/ : Remove Note_req, Rest_req, Busy_playing_req. Changes
throughout. Warning doesn't work yet.

* lily/translator-group.cc (try_music_on_nongroup_children):
new implementation: store candidate acceptors in a hashTable.

40 files changed:
ChangeLog
lily/accidental-engraver.cc
lily/ambitus-engraver.cc
lily/auto-beam-engraver.cc
lily/auto-change-iterator.cc
lily/beam-engraver.cc
lily/chord-name-engraver.cc
lily/command-request.cc
lily/completion-note-heads-engraver.cc
lily/custos-engraver.cc
lily/engraver-group-engraver.cc
lily/figured-bass-engraver.cc
lily/grob-pitch-tuple.cc
lily/include/grob-pitch-tuple.hh
lily/include/lily-proto.hh
lily/include/music-constructor.hh
lily/include/music.hh
lily/include/musical-request.hh
lily/main.cc
lily/mensural-ligature-engraver.cc
lily/music.cc
lily/musical-request.cc
lily/new-accidental-engraver.cc
lily/note-heads-engraver.cc
lily/note-name-engraver.cc
lily/note-performer.cc
lily/parser.yy
lily/part-combine-music-iterator.cc
lily/porrectus-engraver.cc
lily/request-chord.cc
lily/rest-engraver.cc
lily/stem-engraver.cc
lily/tab-note-heads-engraver.cc
lily/tie-engraver.cc
lily/tie-performer.cc
lily/translator-group.cc
lily/type-swallow-translator.cc
lily/voice-devnull-engraver.cc
scm/music-property-description.scm
scm/music-types.scm

index b417f0b136e734432ab859f2b157c52c67428d78..8f7e1bdd78260cea59e00241357d3b1d3663657c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2002-09-26  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+       * lily/musical-request.cc (music-duration-length,
+       music-duration-compress): new functions.
+
+       * lily/ : Remove Note_req, Rest_req, Busy_playing_req. Changes
+       throughout. Warning doesn't work yet.
+
+       * lily/translator-group.cc (try_music_on_nongroup_children):
+       new implementation: store candidate acceptors in a hashTable.
+
 2002-09-25  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
        * scm/music-types.scm (music-descriptions): change name to
index 96d90b21b6f2590c86f59596564ceef0c737b924..4549a30547e3f03cc62a4cdc83de6502c91064bf 100644 (file)
@@ -32,7 +32,7 @@ tweakable.
 
 struct Accidental_entry {
   bool done_;
-  Note_req * melodic_;
+  Music * melodic_;
   Grob * accidental_;
   Translator_group *origin_;
   Grob*  head_;
@@ -125,7 +125,7 @@ calculates the number of accidentals on basis of the current local key sig
 
 */
 static int
-number_accidentals (SCM sig, Note_req * note, Pitch *pitch, SCM curbarnum, SCM lazyness, 
+number_accidentals (SCM sig, Music * note, Pitch *pitch, SCM curbarnum, SCM lazyness, 
                    bool ignore_octave_b)
 {
   int n = pitch->notename_;
@@ -171,7 +171,7 @@ number_accidentals (SCM sig, Note_req * note, Pitch *pitch, SCM curbarnum, SCM l
 }
 
 static int
-number_accidentals (Note_req * note, Pitch *pitch, Translator_group * origin, 
+number_accidentals (Music * note, Pitch *pitch, Translator_group * origin, 
                    SCM accidentals, SCM curbarnum)
 {
   int number = 0;
@@ -249,7 +249,7 @@ Accidental_engraver::process_acknowledged_grobs ()
            continue;
          accidentals_[i].done_  = true;
          Grob * support = accidentals_[i].head_;
-         Note_req * note = accidentals_[i].melodic_;
+         Music * note = accidentals_[i].melodic_;
          Translator_group * origin = accidentals_[i].origin_;
 
          Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch"));
@@ -428,9 +428,11 @@ Accidental_engraver::stop_translation_timestep ()
 void
 Accidental_engraver::acknowledge_grob (Grob_info info)
 {
-  Note_req * note =  dynamic_cast <Note_req *> (info.music_cause ());
+  Music * note =  info.music_cause ();
 
-  if (note && Rhythmic_head::has_interface (info.grob_))
+  if (note
+      && note->is_mus_type("note-event")
+      && Rhythmic_head::has_interface (info.grob_))
     {
       Accidental_entry entry ;
       entry.head_ = info.grob_;
index d0086505d1fc2abf281f4f7a90e88c36ef7df32e..eda824188c15116bba0d4751cbbcdad76f3bdf84 100644 (file)
@@ -136,8 +136,8 @@ Ambitus_engraver::acknowledge_grob (Grob_info info)
     {
       if (Note_head::has_interface (info.grob_))
        {
-         Note_req *nr = dynamic_cast<Note_req*> (info.music_cause ());
-         if (nr)
+         Music *nr = info.music_cause ();
+         if (nr && nr->is_mus_type ("note-event"))
            {
              Pitch pitch = *unsmob_pitch (nr->get_mus_property ("pitch"));
              if (Pitch::compare (pitch_min, pitch_max) > 0) // already init'd?
index 7a37e5d3e76f1fcdfb7b21bee41d9c4f3aea7b84..aff46accf17cb9ad744149d71ed7e6d9e7fb2db1 100644 (file)
@@ -375,9 +375,8 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info)
   if (Stem::has_interface (info.grob_))
     {
       Item* stem = dynamic_cast<Item *> (info.grob_);
-                                      
-      Rhythmic_req *rhythmic_req = dynamic_cast <Rhythmic_req *> (info.music_cause ());
-      if (!rhythmic_req)
+      Music* m = info.music_cause ();
+      if (!m->is_mus_type ("rhythmic-event"))
        {
          programming_error ("Stem must have rhythmic structure");
          return;
@@ -400,7 +399,7 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info)
          return ;
        }
              
-      int durlog  = unsmob_duration (rhythmic_req->get_mus_property ("duration"))->duration_log ();
+      int durlog  = unsmob_duration (m->get_mus_property ("duration"))->duration_log ();
       
       if (durlog <= 2)
        {
@@ -417,7 +416,7 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info)
        return ;
        
       
-      Moment dur = unsmob_duration (rhythmic_req->get_mus_property ("duration"))->length_mom ();
+      Moment dur = unsmob_duration (m->get_mus_property ("duration"))->length_mom ();
       /* FIXME:
 
        This comment has been here since long:
@@ -453,7 +452,7 @@ Auto_beam_engraver::acknowledge_grob (Grob_info info)
                             durlog - 2);
       stems_->push (stem);
       last_add_mom_ = now;
-      extend_mom_ = (extend_mom_ >? now) + rhythmic_req->length_mom ();
+      extend_mom_ = (extend_mom_ >? now) + m->length_mom ();
     }
 }
 
index 74d345ee1470cbab47e9da292a9ce1d3eb855dfb..a2ab5be5e5af8f3f2f1cd3627ce3a6a0232aa0b7 100644 (file)
@@ -86,11 +86,14 @@ Auto_change_iterator::pending_pitch (Moment m) const
     {
       SCM muses = iter->get_pending_events (m);
       for (SCM s = muses; gh_pair_p (s); s=ly_cdr (s))
-       if (Note_req* nr = dynamic_cast<Note_req*> (unsmob_music (ly_car (s))))
-         {
-           ps.push (*unsmob_pitch (nr->get_mus_property ("pitch")));
-         }
-
+       {
+         Music * m = unsmob_music (ly_car (s));
+         if (m && m->is_mus_type ("note-event"))
+           {
+             ps.push (*unsmob_pitch (m->get_mus_property ("pitch")));
+           }
+       }
+      
       if (ps.size ())
        break;
 
index a126111fba0d5f6155dbb050936e05e4957ff8f5..3d6b29bb7b9b28412f0afb71c4bc925e1bc500c3 100644 (file)
@@ -348,7 +348,7 @@ be printed with flags instead of beams. Only engraves beams when we
 are at grace points in time.
 ",
 /* creats*/       "Beam",
-/* accepts */     "general-music",
+/* accepts */     "beam-event abort-event",
 /* acks  */      "stem-interface rest-interface",
 /* reads */       "beamMelismaBusy beatLength subdivideBeams",
 /* write */       "");
index 10bff134a950ba9b9ff4c0eba01dcbb7663a6ce2..79ad18fc2b4e5108a1b97f567274da28ccb2b238 100644 (file)
@@ -28,7 +28,7 @@ protected:
   virtual bool try_music (Music *);
 
 private:
-  void add_note (Note_req *);
+  void add_note (Music *);
   
   Item* chord_name_;
 
@@ -46,7 +46,7 @@ Chord_name_engraver::Chord_name_engraver ()
 }
 
 void
-Chord_name_engraver::add_note (Note_req* n)
+Chord_name_engraver::add_note (Music * n)
 {
   SCM pitches = ly_car (chord_);
   SCM modifiers = ly_cdr (chord_);
@@ -66,9 +66,12 @@ Chord_name_engraver::add_note (Note_req* n)
 bool
 Chord_name_engraver::try_music (Music* m)
 {
-  if (Note_req* n = dynamic_cast<Note_req*> (m))
+  /*
+    hmm. Should check? 
+   */
+  if (m->is_mus_type ("note-event"))
     {
-      add_note (n);
+      add_note (m);
       return true;
     }
   return false;
@@ -104,10 +107,10 @@ Chord_name_engraver::stop_translation_timestep ()
 }
 
 ENTER_DESCRIPTION(Chord_name_engraver,
-/* descr */       "Catch Note_req's, Tonic_reqs, Inversion_reqs, Bass_req
+/* descr */       "Catch note-events, Tonic_reqs, Inversion_reqs, Bass_req
 and generate the appropriate chordname.",
 /* creats*/       "ChordName",
-/* accepts */     "general-music",
+/* accepts */     "note-event busy-playing-event",
 /* acks  */      "",
 /* reads */       "chordChanges",
 /* write */       "");
index 65add7878c448511d47db91cf5011ab81c655e79..5892d040223739ace21a83255322dbdcd21bc37c 100644 (file)
@@ -102,12 +102,10 @@ Mark_req::do_equal_b (Request const * r) const
                               get_mus_property ("label")) == SCM_BOOL_T;
 }
 
-ADD_MUSIC(Bass_figure_req);
 ADD_MUSIC (Arpeggio_req);
 ADD_MUSIC (Articulation_req);
 ADD_MUSIC (Break_req);
 ADD_MUSIC (Breathing_sign_req);
-ADD_MUSIC (Busy_playing_req);
 ADD_MUSIC (Extender_req);
 ADD_MUSIC (Glissando_req);
 ADD_MUSIC (Hyphen_req);
@@ -116,15 +114,11 @@ ADD_MUSIC (Lyric_req);
 ADD_MUSIC (Mark_req);
 ADD_MUSIC (Melisma_playing_req);
 ADD_MUSIC (Melisma_req);
-ADD_MUSIC (Melodic_req);
-ADD_MUSIC (Note_req);
 ADD_MUSIC (Porrectus_req);
-ADD_MUSIC (Rest_req);
 ADD_MUSIC (Rhythmic_req);
 ADD_MUSIC (Script_req);
 ADD_MUSIC (Skip_req);
 ADD_MUSIC (Span_req);
 ADD_MUSIC (Tempo_req);
 ADD_MUSIC (Text_script_req);
-ADD_MUSIC (Tie_req);
 ADD_MUSIC (Tremolo_req);
index ebae8d888c711bf46bfc5de8eea3307b57c801a3..95fa36461fda819e176a8e25f974b7b7acf69f2b 100644 (file)
@@ -68,9 +68,9 @@ Completion_heads_engraver::initialize ()
 bool
 Completion_heads_engraver::try_music (Music *m) 
 {
-  if (Note_req * n =dynamic_cast <Note_req *> (m))
+  if (m->is_mus_type ("note-event"))
     {
-      note_reqs_.push (n);
+      note_reqs_.push (m);
 
       first_b_ = true;
       Moment musiclen = m->length_mom ();
@@ -86,7 +86,7 @@ Completion_heads_engraver::try_music (Music *m)
       
       return true;
     }
-  else if (dynamic_cast<Busy_playing_req*> (m))
+  else if  (m->is_mus_type ("busy-playing-event"))
     {
       return note_reqs_.size ();
     }
index e8d9a820df48a87011db019439489dafc6c84b2b..6af09938e3dae92472adc174d9b48c68dd53f85c 100644 (file)
@@ -72,9 +72,12 @@ Custos_engraver::acknowledge_grob (Grob_info info)
   Item *item = dynamic_cast <Item *> (info.grob_);
   if (item)
     {
+      Music * m = info.music_cause();
       if (Bar_line::has_interface (info.grob_))
        custos_permitted = true;
-      else if (Note_head::has_interface (info.grob_))
+      else if (Note_head::has_interface (info.grob_)
+              && m
+              && m->is_mus_type ("note-event"))
        {
 
          /*
@@ -85,9 +88,7 @@ Custos_engraver::acknowledge_grob (Grob_info info)
            don't look at the staff-position, since we can't be sure
            whether Clef_engraver already applied a vertical shift.
          */
-         Note_req * nr = dynamic_cast<Note_req*> (info.music_cause ());
-         if (nr)
-           pitches_.push (*unsmob_pitch (nr->get_mus_property ("pitch")));
+           pitches_.push (*unsmob_pitch (m->get_mus_property ("pitch")));
        }
     }
 }
index 403d62048907b6f3f892022a01c04f793d8a3485..50a9e67ddda6453ff61dd71e5362b3d53ec02731 100644 (file)
@@ -65,6 +65,8 @@ acks.
 
 */
 SCM find_acknowledge_engravers (SCM gravlist, SCM meta);
+SCM find_accept_engravers (SCM gravlist, SCM music_descr);
+
 void
 Engraver_group_engraver::acknowledge_grobs ()
 {
@@ -163,7 +165,11 @@ Engraver_group_engraver::process_music ()
 void
 Engraver_group_engraver::initialize ()
 {
-  SCM tab = scm_make_vector (gh_int2scm (61), SCM_BOOL_F); // magic ->
+  /*
+    docme: why bool_f.
+    
+   */
+  SCM tab = scm_make_vector (gh_int2scm (61), SCM_BOOL_F);
   set_property ("acknowledgeHashTable", tab);
 
   Translator_group::initialize ();
@@ -195,6 +201,7 @@ bool engraver_valid (Translator*tr, SCM ifaces)
 }
 
 
+
 SCM
 find_acknowledge_engravers (SCM gravlist, SCM meta_alist)
 {
@@ -211,3 +218,5 @@ find_acknowledge_engravers (SCM gravlist, SCM meta_alist)
 
   return l;
 }
+
+
index 1cf1cc5cf26b62babd4e18f5ec6cd817b6a6cb01..1a4f310e988664c31cf69253890c319352ce619f 100644 (file)
@@ -8,8 +8,8 @@ class Figured_bass_engraver : public Engraver
   
   TRANSLATOR_DECLARATIONS(Figured_bass_engraver);
 protected:
-  Link_array<Bass_figure_req> figures_;
-  Rest_req * rest_req_;
+  Link_array<Music> figures_;
+  Music * rest_req_;
 
   Grob * figure_;
   
@@ -41,14 +41,14 @@ Figured_bass_engraver::stop_translation_timestep ()
 bool
 Figured_bass_engraver::try_music (Music*m)
 {
-  if (Bass_figure_req* bfr = dynamic_cast<Bass_figure_req*> (m))
+  if (m->is_mus_type ("bass-figure-event"))
     {
-      figures_.push (bfr);
+      figures_.push (m);
       return true;
     }
-  else if (Rest_req * r = dynamic_cast<Rest_req*> (m))
+  else if (m->is_mus_type ("rest-event"))
     {
-      rest_req_ = r;
+      rest_req_ = m;
       return true;
     }
   return false;
index 2bfc9942696a99a717b47168b578e1b817d981aa..fc6e450f990cb1de8322e996ee91f9f1abd2c010 100644 (file)
@@ -25,7 +25,7 @@ Grob_pitch_tuple::Grob_pitch_tuple ()
   end_ = 0;
 }
 
-Grob_pitch_tuple::Grob_pitch_tuple (Grob *h, Melodic_req*m, Moment mom)
+Grob_pitch_tuple::Grob_pitch_tuple (Grob *h, Music *m, Moment mom)
 {
   head_ = h;
   pitch_ = *unsmob_pitch (m->get_mus_property ("pitch"));
index e174ed668e02b140010304e56b789ac737fcc91f..ec798c8cf84f6e5591fc0dafa053d3fd0e3e0a4f 100644 (file)
@@ -20,7 +20,7 @@ struct Grob_pitch_tuple {
   Moment end_;
 
   Grob_pitch_tuple ();
-  Grob_pitch_tuple (Grob*, Melodic_req*, Moment);
+  Grob_pitch_tuple (Grob*, Music*, Moment);
   static int pitch_compare (Grob_pitch_tuple const &, Grob_pitch_tuple const &);
   static int time_compare (Grob_pitch_tuple const &, Grob_pitch_tuple const &);  
 };
index e02c5120ab99e7fab56fc732450c82915b5a78f2..3dea8a1b68f434ecf407421cba9d8f6873d50b11 100644 (file)
@@ -123,7 +123,6 @@ class Pitch;
 class Musical_req;
 class My_lily_lexer;
 class Note_performer;
-class Note_req;
 class Output_property;
 class Paper_column;
 class Paper_def;
index 1e9dc262ff0f83419a75313251367db12fc56029..c6a20d7399d81db53cfa54a063fa5fd269f421aa 100644 (file)
@@ -22,7 +22,7 @@ Music * _ ## type ## _ctor ()\
 static void  _ ## type ## _adder () {\
       add_music_ctor (#type, & _ ## type ## _ctor);\
 }\
-ADD_GLOBAL_CTOR (_ ## type ## _adder);
+ADD_SCM_INIT_FUNC( _ ## type ## _adder_prefix,  _ ## type ## _adder);
 
 void add_music_ctor (String, Music* (*) ());
 Music*make_music (String);
index 13e79e65b3d9c19a322d7e0e25f38e941134f7da..a8457dee8b2e1b4860589b5f8133625d3b4a2afa 100644 (file)
@@ -21,6 +21,7 @@
 
 #define get_mus_property(x) internal_get_mus_property(ly_symbol2scm(x))
 #define set_mus_property(x,y) internal_set_mus_property(ly_symbol2scm (x), y)
+#define is_mus_type(x) internal_is_music_type(ly_symbol2scm (x))
 
 /** Music is anything that has duration and supports both time compression and
   transposition.
@@ -42,8 +43,8 @@ public:
 
   SCM internal_get_mus_property (SCM) const;
   void internal_set_mus_property (SCM , SCM val);
-  void add_music_type (SCM);
-  bool is_music_type (SCM) const;
+  SCM get_property_alist (bool mut) const;
+  bool internal_is_music_type (SCM) const;
   
   virtual Pitch to_relative_octave (Pitch);
 
index d9b67bb9b6a4f0a137c1e0aa8fde957b8334ef48..488f080de52b1ba8faa8a8b5b1adfd14ccd66fa0 100644 (file)
@@ -21,7 +21,6 @@
  */
 class Rhythmic_req  : public virtual Request  {
 public:
-  bool do_equal_b (Request const*) const;
   void compress (Moment);
   virtual Moment length_mom () const;
   static int compare (Rhythmic_req const&,Rhythmic_req const&);
@@ -41,7 +40,6 @@ struct Tremolo_req : public Request {
 
 struct Chord_tremolo_notify_req : public Request
 {
-
   Rational factor_;
   VIRTUAL_COPY_CONS(Chord_tremolo_notify_req);
   Chord_tremolo_notify_req();
@@ -64,7 +62,6 @@ public:
   String get_articulation_string ();
 protected:
   virtual bool do_equal_b (Request const*) const;
-
   VIRTUAL_COPY_CONS (Music);
 };
 
@@ -93,24 +90,6 @@ protected:
   VIRTUAL_COPY_CONS (Music);
 };
 
-/*
-   Put a note of specified type, height, and with accidental on the staff.
-    /// force/supress printing of accidental.
-  bool forceacc_b_;
-  /// Cautionary, i.e. parenthesized accidental.
-  bool cautionary_b_;
-
- */
-class Note_req  : public Rhythmic_req, virtual public Melodic_req  {
-public:
-    
-  Note_req ();
-protected:
-
-  bool do_equal_b (Request const*) const;
-  VIRTUAL_COPY_CONS (Music);
-};
-
 /**
 Put a rest on the staff. Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded.
 */
@@ -132,15 +111,6 @@ public:
   VIRTUAL_COPY_CONS (Music);
 };
 
-/** is anyone  playing a note?
-    Used for communication between Music & Lyrics
- */
-class Busy_playing_req : public Request
-{
-public:
-  VIRTUAL_COPY_CONS (Music);
-};
-
 
 
 /**
@@ -173,10 +143,5 @@ public:
   VIRTUAL_COPY_CONS (Music);
 };
 
-class Bass_figure_req:  public Rhythmic_req
-{
-public:
-  VIRTUAL_COPY_CONS(Music);
-};
 
 #endif // MUSICALREQUESTS_HH
index 573409e831c6883bed669034d85281d71b440a68..ff00e7c334f01af596a20410c4f3a5fd09730940 100644 (file)
@@ -340,10 +340,10 @@ main_prog (void *, int, char **)
     dirinfo (stderr);
   
   ly_init_guile ();
+  call_constructors ();
 
   progress_indication ("\n");
 
-  call_constructors ();
   all_fonts_global = new All_font_metrics (global_path.string ());
 
   init_scheme_code_string += ")";
index 0672e9b8d93ac1c2ee8c4e211af95bcb32738a23..4678e9bf26d22873590589bc7124d1a5c950170a 100644 (file)
@@ -341,8 +341,15 @@ Mensural_ligature_engraver::transform_heads ()
     Grob_info info = primitives_[i];
     int duration_log =
       Note_head::get_balltype (dynamic_cast<Item*> (info.grob_));
-    Note_req *nr = dynamic_cast<Note_req*> (info.music_cause ());
-    if (!nr)
+
+    Music * nr = info.music_cause ();
+    
+
+    /*
+
+    ugh. why not simply check for pitch? 
+     */
+    if (!nr->is_mus_type ("note-event"))
       {
        info.music_cause ()->origin ()->warning (_f ("can not determine pitch of ligature primitive -> skipping"));
        i++;
@@ -395,10 +402,8 @@ Mensural_ligature_engraver::transform_heads ()
 
 void set_delta_pitch (Item *primitive, Grob_info info1, Grob_info info2)
 {
-  Note_req *nr1 = dynamic_cast<Note_req*> (info1.music_cause ());
-  Note_req *nr2 = dynamic_cast<Note_req*> (info2.music_cause ());
-  Pitch pitch1 = *unsmob_pitch (nr1->get_mus_property ("pitch"));
-  Pitch pitch2 = *unsmob_pitch (nr2->get_mus_property ("pitch"));
+  Pitch pitch1 = *unsmob_pitch (info1.music_cause ()->get_mus_property ("pitch"));
+  Pitch pitch2 = *unsmob_pitch (info2.music_cause ()->get_mus_property ("pitch"));
   int delta_pitch = (pitch2.steps () - pitch1.steps ());
   primitive->set_grob_property ("delta-pitch", gh_int2scm (delta_pitch));
 }
@@ -510,8 +515,7 @@ Mensural_ligature_engraver::join_primitives ()
   for (int i = 0; i < primitives_.size (); i++)
     {
       Grob_info info = primitives_[i];
-      Note_req *nr = dynamic_cast<Note_req*> (info.music_cause ());
-      Pitch pitch = *unsmob_pitch (nr->get_mus_property ("pitch"));
+      Pitch pitch = *unsmob_pitch (info.music_cause ()->get_mus_property ("pitch"));
       if (i > 0)
         {
          Item *primitive = dynamic_cast<Item*> (info.grob_);
index d87be5881ecd96a30b079f08ba20e81cebe9bd68..159f4310906aefdd90dcfd037ee56e03c15b12f2 100644 (file)
@@ -34,18 +34,10 @@ ly_deep_mus_copy (SCM m)
 
 
 
-void
-Music::add_music_type (SCM sym)
-{
-  assert (gh_symbol_p (sym));
 
-  SCM types= get_mus_property ("types");
-  types = scm_cons (sym, types);
-  set_mus_property ("types", types);
-}
 
 bool
-Music::is_music_type (SCM k)const
+Music::internal_is_music_type (SCM k)const
 {
   SCM ifs = get_mus_property ("types");
 
@@ -66,12 +58,8 @@ Music::Music (Music const &m)
   smobify_self ();
   mutable_property_alist_ = ly_deep_mus_copy (m.mutable_property_alist_);
   set_spot (*m.origin ());
-
-  add_music_type (ly_symbol2scm ("general-music"));
 }
 
-
-
 Music::Music ()
 {
   self_scm_ = SCM_EOL;
@@ -80,6 +68,11 @@ Music::Music ()
   smobify_self ();
 }
 
+SCM
+Music::get_property_alist (bool m) const
+{
+  return (m) ? mutable_property_alist_ : immutable_property_alist_;
+}
 
 SCM
 Music::mark_smob (SCM m)
@@ -91,12 +84,16 @@ Music::mark_smob (SCM m)
 }
 
 void    
-Music::compress (Moment)
+Music::compress (Moment f)
 {
+  SCM l = get_mus_property ("compress-procedure");
+  if (gh_procedure_p (l))
+    {
+      SCM res = gh_call2 (l, self_scm (), f.smobbed_copy());
+    }
 }
 
 
-
 Moment
 Music::length_mom () const
 {
index c4a58d0ed206c40fc26b42302826992738288948..ff1f9ad557cf3d912f2cbf7e290740e1f3c8c4f3 100644 (file)
@@ -16,21 +16,44 @@ Tremolo_req::Tremolo_req ()
 {
 }
 
-bool
-Melodic_req::do_equal_b (Request const* r) const
+LY_DEFINE(music_duration_length, "music-duration-length", 1, 0,0,
+         (SCM mus),
+         "Extract the duration field from @var{mus}, and return the length.")
 {
-  Melodic_req const* m= dynamic_cast <Melodic_req const*> (r);
-  return m; // && !compare (*m, *this);
+  Music* m =   unsmob_music(mus);
+  SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "Music");
+  
+  Duration *d = unsmob_duration (m->get_mus_property ("duration"));
+
+  Moment l ;
+  
+  if (d)
+    {
+      l = d->length_mom ();  
+    }
+  else
+    programming_error("Rhythmic_req has no duration");
+  return l.smobbed_copy();
+  
 }
 
-bool
-Rhythmic_req::do_equal_b (Request const* r) const
-{
-  Rhythmic_req const* rh = dynamic_cast <Rhythmic_req const*> (r);
 
-  return rh; // ;  && !compare (*this, *rh);
+LY_DEFINE(music_duration_compress, "music-duration-compress", 2, 0,0,
+         (SCM mus, SCM factor),
+         "Extract the duration field from @var{mus}, and compress it.")
+{
+  Music* m =   unsmob_music(mus);
+  Moment * f = unsmob_moment (factor);
+  SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "Music");
+  SCM_ASSERT_TYPE(f, factor, SCM_ARG2, __FUNCTION__, "Moment");
+  
+  Duration *d = unsmob_duration (m->get_mus_property ("duration"));
+  if (d)
+    m->set_mus_property ("duration", d->compressed (f->main_part_).smobbed_copy());
+  return SCM_UNSPECIFIED;
 }
 
+  
 Moment
 Rhythmic_req::length_mom () const
 {
@@ -52,17 +75,6 @@ Rhythmic_req::compress (Moment m)
     set_mus_property ("duration", d ->compressed (m.main_part_).smobbed_copy ());
 }
 
-bool
-Note_req::do_equal_b (Request const* r) const
-{
-  Note_req const* n = dynamic_cast<Note_req const*> (r);
-  return n&& Rhythmic_req::do_equal_b (n) && Melodic_req::do_equal_b (n);
-}
-
-
-Note_req::Note_req ()
-{
-}
 
 
 bool
index 0bc51dff5cbcca71334a036af7ee8e293e65c9dc..1e5fd92accd3140c8722d6ccfd55b1bce579f7eb 100644 (file)
@@ -39,7 +39,7 @@ struct New_accidental_entry {
   int number_accidentals_;
   int number_cautionaries_;
   bool different_;
-  Note_req * melodic_;
+  Music * melodic_;
   Grob * accidental_;
   Translator_group *origin_;
   Grob*  head_;
@@ -182,7 +182,7 @@ calculates the number of accidentals on basis of the current local key sig
 
 */
 static int
-number_accidentals (SCM sig, Note_req * note, Pitch *pitch, SCM curbarnum, SCM lazyness, 
+number_accidentals (SCM sig, Music * note, Pitch *pitch, SCM curbarnum, SCM lazyness, 
                    bool ignore_octave_b)
 {
   int n = pitch->notename_;
@@ -228,7 +228,7 @@ number_accidentals (SCM sig, Note_req * note, Pitch *pitch, SCM curbarnum, SCM l
 }
 
 static int
-number_accidentals (Note_req * note, Pitch *pitch, Translator_group * origin, 
+number_accidentals (Music * note, Pitch *pitch, Translator_group * origin, 
                    SCM accidentals, SCM curbarnum)
 {
   int number = 0;
@@ -307,7 +307,7 @@ New_accidental_engraver::process_grobs_first_pass ()
       accidentals_[i].pass_done_  = 1;
 
       Grob * support = accidentals_[i].head_;
-      Note_req * note = accidentals_[i].melodic_;
+      Music * note = accidentals_[i].melodic_;
       Translator_group * origin = accidentals_[i].origin_;
       Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch"));
 
@@ -383,7 +383,7 @@ New_accidental_engraver::process_grobs_second_pass ()
        continue;
       accidentals_[i].pass_done_  = 2;
       Grob * support = accidentals_[i].head_;
-      Note_req * note = accidentals_[i].melodic_;
+      Music * note = accidentals_[i].melodic_;
       Translator_group * origin = accidentals_[i].origin_;
       
       Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch"));
@@ -505,9 +505,11 @@ New_accidental_engraver::stop_translation_timestep ()
 void
 New_accidental_engraver::acknowledge_grob (Grob_info info)
 {
-  Note_req * note =  dynamic_cast <Note_req *> (info.music_cause ());
+  Music * note =  info.music_cause ();
 
-  if (note && Rhythmic_head::has_interface (info.grob_))
+  if (note
+      && note->is_mus_type ("note-event")
+      && Rhythmic_head::has_interface (info.grob_))
     {
       New_accidental_entry entry ;
       entry.head_ = info.grob_;
index 243783adb2590a17d8a1c5b68ed408b1688d5560..7ce9a433de47286248f49960f748ff2b5243e96b 100644 (file)
@@ -23,7 +23,7 @@ class Note_heads_engraver : public Engraver
   Link_array<Item> notes_;
   
   Link_array<Item> dots_;
-  Link_array<Note_req> note_reqs_;
+  Link_array<Music> note_reqs_;
 
 public:
   TRANSLATOR_DECLARATIONS(Note_heads_engraver);
@@ -47,27 +47,25 @@ Note_heads_engraver::Note_heads_engraver()
 bool
 Note_heads_engraver::try_music (Music *m) 
 {
-  if (Note_req * n =dynamic_cast <Note_req *> (m))
+  if (m->is_mus_type ("note-event"))
     {
-      note_reqs_.push (n);
+      note_reqs_.push (m);
       return true;
     }
-  else if (dynamic_cast<Busy_playing_req*> (m))
+  else if (m->is_mus_type ("busy-playing-event"))
+    return note_reqs_.size ();
+  else if (m->is_mus_type ("abort-event"))
     {
-      return note_reqs_.size ();
+      in_ligature = 0;
     }
-  else if (Span_req *req_ = dynamic_cast<Span_req*> (m))
+  else if (m->is_mus_type ("ligature-event"))
     {
-      if (scm_equal_p (req_->get_mus_property ("span-type"),
-                      scm_makfrom0str ("abort")) == SCM_BOOL_T)
-       {
-         in_ligature = 0;
-       }
-      else if (scm_equal_p (req_->get_mus_property ("span-type"),
-                           scm_makfrom0str ("ligature")) == SCM_BOOL_T)
-       {
-         in_ligature = (req_->get_span_dir () == START);
-       }
+      /*
+       Urg ; this is not protocol. We should accept and return
+       true, or ignore.
+      */
+      in_ligature = (m->get_mus_property("span-direction")
+                    == gh_int2scm (START));
     }
   
   return false;
@@ -129,7 +127,6 @@ Note_heads_engraver::stop_translation_timestep ()
       typeset_grob (dots_[i]);
     }
   dots_.clear ();
-  
   note_reqs_.clear ();
 }
 
@@ -140,9 +137,9 @@ Note_heads_engraver::start_translation_timestep ()
 
 
 ENTER_DESCRIPTION(Note_heads_engraver,
-/* descr */       "Generate one or more noteheads from Music of type Note_req.",
-/* creats*/       "NoteHead Dots",
-/* accepts */     "general-music",
+/* descr */       "Generate noteheads (also serves a double functions: makes ligatures.",
+/* creats*/       "NoteHead LigatureHead Dots",
+/* accepts */     "note-event busy-playing-event ligature-event abort-event",
 /* acks  */      "",
 /* reads */       "centralCPosition",
 /* write */       "");
index 0ffa2d00b07354715bd19fbad0fae25c42a4868f..bfd6fafb497576abd80f3e152b9b0025de00df5f 100644 (file)
@@ -16,7 +16,7 @@ class Note_name_engraver : public Engraver
 public:
   TRANSLATOR_DECLARATIONS(Note_name_engraver);
 
-  Link_array<Note_req> reqs_;
+  Link_array<Music> reqs_;
   Link_array<Item> texts_;
   virtual bool  try_music (Music*m);
   virtual void process_acknowledged_grobs ();
@@ -26,9 +26,9 @@ public:
 bool
 Note_name_engraver::try_music (Music *m)
 {
-  if (Note_req *r = dynamic_cast<Note_req* > (m))
+  if (m->is_mus_type ("note-event"))
     {
-      reqs_.push (r);
+      reqs_.push (m);
       return true;
     }
   return false;
index ae8b1adf17cefc37fd5ec515c573546b053850d6..91509a9734c20d7d8861ce74d629802326084ab2 100644 (file)
@@ -28,9 +28,9 @@ protected:
   Global_translator* get_global_translator ();
 
 private:
-  Array<Note_req*> note_reqs_;
-  Array<Audio_note*> notes_;
-  Array<Audio_note*> delayeds_;
+  Link_array<Music> note_reqs_;
+  Link_array<Audio_note> notes_;
+  Link_array<Audio_note> delayeds_;
 };
 
 void 
@@ -46,7 +46,7 @@ Note_performer::create_audio_elements ()
 
       while (note_reqs_.size ())
        {
-         Note_req* n = note_reqs_.pop ();
+         Music* n = note_reqs_.pop ();
          Pitch pit =  * unsmob_pitch (n->get_mus_property ("pitch"));
          Audio_note* p = new Audio_note (pit,  n->length_mom (), transposing_i);
          Audio_element_info info (p, n);
@@ -117,9 +117,9 @@ Note_performer::stop_translation_timestep ()
 bool
 Note_performer::try_music (Music* req)
 {
-  if (Note_req *nr = dynamic_cast <Note_req *> (req))
+  if (req->is_mus_type ("note-event"))
     {
-      note_reqs_.push (nr);
+      note_reqs_.push (req);
       return true;
     }
   return false;
index 1808045c879e18fed56b63915e66eeff55d84e78..f67fa5363dcd89324d77414b955c229060061788 100644 (file)
@@ -1172,9 +1172,8 @@ command_element:
                $1-> set_spot (THIS->here_input ());
        }
        | E_LEFTSQUARE {
-               Music *l = MY_MAKE_MUSIC("SpanEvent");
+               Music *l = MY_MAKE_MUSIC("LigatureEvent");
                l->set_mus_property ("span-direction", gh_int2scm (START));
-               l->set_mus_property ("span-type", scm_makfrom0str ("ligature"));
                l->set_spot (THIS->here_input ());
 
                $$ = MY_MAKE_MUSIC("RequestChord");
@@ -1183,9 +1182,8 @@ command_element:
                $$->set_spot (THIS->here_input ());
        }
        | E_RIGHTSQUARE {
-               Music *l = MY_MAKE_MUSIC("SpanEvent");
+               Music *l = MY_MAKE_MUSIC("LigatureEvent");
                l->set_mus_property ("span-direction", gh_int2scm (STOP));
-               l->set_mus_property ("span-type", scm_makfrom0str ("ligature"));
                l->set_spot (THIS->here_input ());
 
                $$ = MY_MAKE_MUSIC("RequestChord");
index 8f38b48205a31d51ebf419cd4bbebf030742688f..fcc99f05babc9718492fd710f9534d28f28a6ac5 100644 (file)
@@ -153,16 +153,15 @@ get_music_info (Moment m, Music_iterator* iter, SCM *pitches, SCM *durations)
       for (SCM i = iter->get_pending_events (m); gh_pair_p (i); i = ly_cdr (i))
        {
          Music *m = unsmob_music (ly_car (i));
-         if (Melodic_req *r = dynamic_cast<Melodic_req *> (m))
-           *pitches = gh_cons (r->get_mus_property ("pitch"), *pitches);
-         if (Rhythmic_req *r = dynamic_cast<Rhythmic_req *> (m))
+         if (m->is_mus_type ("melodic-event"))
+           *pitches = gh_cons (m->get_mus_property ("pitch"), *pitches);
+         if (m->is_mus_type ("rhythmic-event"))
            {
-             SCM d = r->get_mus_property ("duration");
+             SCM d = m->get_mus_property ("duration");
              if (d == SCM_EOL)
-               r->origin ()->warning ("Rhythmic_req has no duration\n");
-               else
-                 // *durations = gh_cons (r->get_mus_property ("duration"), *durations);
-                 *durations = gh_cons (d, *durations);
+               m->origin ()->warning ("Rhythmic_req has no duration\n");
+             else
+               *durations = gh_cons (d, *durations);
            }
        }
     }
@@ -394,8 +393,7 @@ s      Consider thread switching: threads "one", "two" and "both".
 
   if (!abort_req)
     {
-      abort_req = make_music_by_name (ly_symbol2scm ("SpanEvent"));
-      abort_req->set_mus_property ("span-type", scm_makfrom0str ("abort"));
+      abort_req = make_music_by_name (ly_symbol2scm ("AbortEvent"));
     }
   
   if (combine_b && combine_b != previously_combined_b)
index 578389b1ab6a20ecb30c5db8b26a4ac0d02a02f8..eb5737d1db39343f971f8c67be952df439ce1c40 100644 (file)
@@ -92,12 +92,11 @@ Porrectus_engraver::acknowledge_grob (Grob_info info_)
 {
   if (Rhythmic_head::has_interface (info_.grob_))
     {
-      Note_req *note_req_ = dynamic_cast <Note_req *> (info_.music_cause ());
-      if (!note_req_)
-       return;
-      right_heads_.push (Grob_pitch_tuple (info_.grob_, note_req_,
-                                             now_mom () +
-                                             note_req_->length_mom ()));
+      Music * m = info_.music_cause ();
+      if (m->is_mus_type ("note-event"))
+       right_heads_.push (Grob_pitch_tuple (info_.grob_, m,
+                                            now_mom () +
+                                            m->length_mom ()));
     }
 }
 
index 7d9cb184f4d346f3fac339642746cb218f183672..2cf46c91cdd71afa7fc670858c39013df8934a5c 100644 (file)
@@ -13,14 +13,9 @@ Request_chord::to_relative_octave (Pitch last)
   for (SCM s = music_list (); gh_pair_p (s);  s = ly_cdr (s))
     {
       Music * mus = unsmob_music (ly_car (s));
-      Melodic_req *m= dynamic_cast <Melodic_req *> (mus);
 
-      /*
-       kLudge: rests have pitches now as well.
-       */
-      Rest_req *r = dynamic_cast<Rest_req*> (mus);
-      
-      if (r || m)
+      if (mus->is_mus_type ("melodic-event")
+         || mus->is_mus_type ("rest-event"))
        {
          Pitch *old_pit = unsmob_pitch (mus->get_mus_property ("pitch"));
          if (!old_pit)
index dc617ef3b750b00f202c72f031830b86d4162942..3aabd92441a66a39e004179ce892c1378bf2f8fb 100644 (file)
@@ -15,7 +15,7 @@
 
 class Rest_engraver : public Engraver
 {
-  Rest_req *rest_req_;
+  Music *rest_req_;
   Item * dot_;
   Grob* rest_;
 protected:
@@ -67,8 +67,6 @@ Rest_engraver::process_music ()
     {
       rest_ = new Item (get_property ("Rest"));
 
-
-      
       int durlog  = unsmob_duration (rest_req_->get_mus_property ("duration"))-> duration_log ();
       
       rest_->set_grob_property ("duration-log",
@@ -109,20 +107,18 @@ Rest_engraver::process_music ()
 bool
 Rest_engraver::try_music (Music *m)
 {
-  if (Rest_req *r = dynamic_cast <Rest_req *> (m))
+  if (m->is_mus_type ("rest-event"))
     {
-      rest_req_ = r;
+      rest_req_ = m;
       return true;
-    }  
+    }
   return false;
 }
 
-
-
 ENTER_DESCRIPTION(Rest_engraver,
 /* descr */       "",
 /* creats*/       "Rest Dots",
-/* accepts */     "general-music",
+/* accepts */     "rest-event",
 /* acks  */      "",
 /* reads */       "centralCPosition",
 /* write */       "");
index b18a94074f6abdcf42f235c4e23c744bffe1fb3f..8d08ee0dd8612c6b32bada998085eacffd219188 100644 (file)
@@ -57,9 +57,10 @@ Stem_engraver::acknowledge_grob (Grob_info i)
       /* Reverted to the old method so chord tremolos work again. /MB 
       */
       int duration_log = 0;
-      Rhythmic_req *rhythmic_req = dynamic_cast <Rhythmic_req *> (i.music_cause ()); 
-      if (rhythmic_req)
-       duration_log = unsmob_duration (rhythmic_req->get_mus_property ("duration"))-> duration_log (); 
+
+      Music * m = i.music_cause ();
+      if (m->is_mus_type ("rhythmic-event"))
+       duration_log = unsmob_duration (m->get_mus_property ("duration"))-> duration_log (); 
       
       if (!stem_) 
        {
index 603074d23485f66a8148f026f0c65459e4736054..fb2b29101a89618c44a84f3f29e87db88c16e66b 100644 (file)
@@ -24,8 +24,8 @@ class Tab_note_heads_engraver : public Engraver
   Link_array<Item> notes_;
   
   Link_array<Item> dots_;
-  Link_array<Note_req> note_reqs_;
-  Link_array<String_number_req> tabstring_reqs_;
+  Link_array<Music> note_reqs_;
+  Link_array<Music> tabstring_reqs_;
 public:
   TRANSLATOR_DECLARATIONS(Tab_note_heads_engraver);
 
@@ -45,19 +45,20 @@ Tab_note_heads_engraver::Tab_note_heads_engraver()
 bool
 Tab_note_heads_engraver::try_music (Music *m) 
 {
-  if (Note_req * n =dynamic_cast <Note_req *> (m))
+  if (m->is_mus_type ("note-event"))
     {
-      note_reqs_.push (n);
+      note_reqs_.push (m);
       return true;
     }
-  else if (String_number_req * ts = dynamic_cast<String_number_req*> (m))
+  else if (m->is_mus_type ("string-number-event"))
     {
       while(tabstring_reqs_.size () < note_reqs_.size ()-1)
        tabstring_reqs_.push(0);
-      tabstring_reqs_.push(ts);
+      
+      tabstring_reqs_.push (m);
       return true;
     }
-  else if (dynamic_cast<Busy_playing_req*> (m))
+  else if (m->is_mus_type ("busy-playing-event"))
     {
       return note_reqs_.size ();
     }
@@ -173,7 +174,7 @@ Tab_note_heads_engraver::start_translation_timestep ()
 ENTER_DESCRIPTION(Tab_note_heads_engraver,
 /* descr */       "Generate one or more tablature noteheads from Music of type Note_req.",
 /* creats*/       "TabNoteHead Dots",
-/* accepts */     "general-music",
+/* accepts */     "note-event string-number-event busy-playing-event",
 /* acks  */      "",
 /* reads */       "centralCPosition stringTunings minimumFret tablatureFormat highStringOne stringOneTopmost",
 /* write */       "");
index 2e97956165cb4992da035577fba93419ffbd1159..64d17c63ffa84421325fff861a054e0b46687e71 100644 (file)
@@ -21,7 +21,7 @@
 
 /**
    Manufacture ties.  Acknowledge noteheads, and put them into a
-   priority queue. If we have a Tie_req, connect the notes that finish
+   priority queue. If we have a TieEvent, connect the notes that finish
    just at this time, and note that start at this time.
 
    TODO: Remove the dependency on musical info. We should tie on the
@@ -33,7 +33,7 @@ class Tie_engraver : public Engraver
   Moment end_mom_;
   Moment next_end_mom_;
 
-  Tie_req *req_;
+  Music *req_;
   Link_array<Grob> now_heads_;
   Link_array<Grob> stopped_heads_;
   Link_array<Grob> ties_;
@@ -63,23 +63,16 @@ Tie_engraver::Tie_engraver ()
 
 
 bool
-Tie_engraver::try_music (Music *m)
+Tie_engraver::try_music (Music *mus)
 {
-  if (Tie_req * c = dynamic_cast<Tie_req*> (m))
+  req_ = mus;
+  SCM m = get_property ("automaticMelismata");
+  bool am = gh_boolean_p (m) &&gh_scm2bool (m);
+  if (am)
     {
-      /*      if (end_mom_ > now_mom ())
-       return false;
-      */
-      req_ = c;
-      SCM m = get_property ("automaticMelismata");
-      bool am = gh_boolean_p (m) &&gh_scm2bool (m);
-      if (am)
-       {
-         set_melisma (true);
-       }
-      return true;
+      set_melisma (true);
     }
-  return false;
+  return true;
 }
 
 void
@@ -281,7 +274,7 @@ Tie_engraver::start_translation_timestep ()
 ENTER_DESCRIPTION(Tie_engraver,
 /* descr */       "Generate ties between noteheads of equal pitch.",
 /* creats*/       "Tie TieColumn",
-/* accepts */     "general-music",
+/* accepts */     "tie-event",
 /* acks  */      "rhythmic-head-interface",
 /* reads */       "sparseTies tieMelismaBusy",
 /* write */       "");
index eb7b0f3c7808f40c5253442f71aa25a88d90a80c..d76b71c4d8ebb06c0368943540e6ee7131b9a586 100644 (file)
 #include "performer.hh"
 
 struct CNote_melodic_tuple {
-  Melodic_req *req_ ;
+  Music *req_ ;
   Audio_note *note_;
   Moment end_;
   CNote_melodic_tuple ();
-  CNote_melodic_tuple (Audio_note*, Melodic_req*, Moment);
+  CNote_melodic_tuple (Audio_note*, Music*, Moment);
   static int pitch_compare (CNote_melodic_tuple const &, CNote_melodic_tuple const &);
   static int time_compare (CNote_melodic_tuple const &, CNote_melodic_tuple const &);  
 };
@@ -31,7 +31,7 @@ inline int compare (CNote_melodic_tuple const &a, CNote_melodic_tuple const &b)
 
 /**
    Manufacture ties.  Acknowledge notes, and put them into a
-   priority queue. If we have a Tie_req, connect the notes that finish
+   priority queue. If we have a Music, connect the notes that finish
    just at this time, and note that start at this time.
 
    TODO: should share code with Tie_engraver ?
@@ -43,7 +43,7 @@ public:
 private:
   bool done_;
   PQueue<CNote_melodic_tuple> past_notes_pq_;
-  Tie_req *req_;
+  Music *req_;
   Array<CNote_melodic_tuple> now_notes_;
   Array<CNote_melodic_tuple> stopped_notes_;
   Link_array<Audio_tie> ties_;
@@ -65,7 +65,7 @@ Tie_performer::Tie_performer ()
 }
 
 ENTER_DESCRIPTION (Tie_performer, "", "",
-                  "general-music",
+                  "tie-event",
                   "", "", "");
 
 
@@ -81,11 +81,8 @@ Tie_performer::try_music (Music *m)
 {
   if (!req_)
     {
-      if (Tie_req * c = dynamic_cast<Tie_req*> (m))
-       {
-         req_ = c;
-         return true;
-       }
+      req_ = m;
+      return true;
     }
   return false;
 }
@@ -95,10 +92,9 @@ Tie_performer::acknowledge_audio_element (Audio_element_info i)
 {
   if (Audio_note *nh = dynamic_cast<Audio_note *> (i.elem_))
     {
-      Note_req * m = dynamic_cast<Note_req *> (i.req_);
-      if (!m)
-       return;
-      now_notes_.push (CNote_melodic_tuple (nh, m, now_mom ()+ m->length_mom ()));
+      Music *m = i.req_;
+      if (m->is_mus_type ("note-event"))
+       now_notes_.push (CNote_melodic_tuple (nh, m, now_mom ()+ m->length_mom ()));
     }
 }
 
@@ -201,7 +197,7 @@ CNote_melodic_tuple::CNote_melodic_tuple ()
   end_ = 0;
 }
 
-CNote_melodic_tuple::CNote_melodic_tuple (Audio_note *h, Melodic_req*m, Moment mom)
+CNote_melodic_tuple::CNote_melodic_tuple (Audio_note *h, Music*m, Moment mom)
 {
   note_ = h;
   req_ = m;
index 6768de18c70143865e4660a4ca99119159f5d6ee..957ca17f0b38dc6c01dcb056ab65efe2d653366f 100644 (file)
@@ -14,6 +14,7 @@
 #include "scm-hash.hh"
 #include "translator-def.hh"
 #include "main.hh"
+#include "music.hh"
 
 Translator_group::Translator_group (Translator_group const&s)
   : Translator (s)
@@ -162,18 +163,6 @@ Translator_group::find_create_translator (String n, String id)
   return ret;
 }
 
-bool
-Translator_group::try_music_on_nongroup_children (Music *m)
-{
-  bool hebbes_b =false;
-  
-  for (SCM p = simple_trans_list_; !hebbes_b && gh_pair_p (p); p = ly_cdr (p))
-    {
-      hebbes_b = unsmob_translator (ly_car (p))->try_music (m);
-    }
-  return hebbes_b;
-}
-
 bool
 Translator_group::try_music (Music* m)
 {
@@ -399,6 +388,8 @@ Translator_group::do_announces ()
 void
 Translator_group::initialize ()
 {
+  SCM tab = scm_make_vector (gh_int2scm (19), SCM_BOOL_F);
+  set_property ("acceptHashTable", tab);
   each (&Translator::initialize);
 }
 
@@ -408,31 +399,57 @@ Translator_group::finalize ()
   each (&Translator::removal_processing);
 }
 
-LY_DEFINE(ly_get_context_property,
-         "ly-get-context-property", 2, 0, 0,
-         (SCM context, SCM name),
-         "retrieve the value of @var{sym} from context @var{tr}")
+
+
+bool translator_accepts_any_of (Translator*tr, SCM ifaces)
 {
-  Translator *t = unsmob_translator (context);
-  Translator_group* tr=   dynamic_cast<Translator_group*> (t);
-  SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Translator group");
-  SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
+  SCM ack_ifs = scm_assoc (ly_symbol2scm ("events-accepted"),
+                          tr->translator_description());
+  ack_ifs = gh_cdr (ack_ifs);
+  for (SCM s = ifaces; ly_pair_p (s); s = ly_cdr (s))
+    if (scm_memq (ly_car (s), ack_ifs) != SCM_BOOL_F)
+      return true;
+  return false;
+}
 
-  return tr->internal_get_property (name);
-  
+SCM
+find_accept_translators (SCM gravlist, SCM ifaces)
+{
+  SCM l = SCM_EOL;
+  for (SCM s = gravlist; ly_pair_p (s);  s = ly_cdr (s))
+    {
+      Translator* tr = unsmob_translator (ly_car (s));
+      if (translator_accepts_any_of (tr, ifaces))
+       l = scm_cons (tr->self_scm (), l); 
+    }
+  l = scm_reverse_x (l, SCM_EOL);
+
+  return l;
 }
 
-LY_DEFINE(ly_set_context_property,
-         "ly-set-context-property", 3, 0, 0,
-         (SCM context, SCM name, SCM val),
-         "set value of property @var{sym} in context @var{tr} to @var{val}.
-")
+bool
+Translator_group::try_music_on_nongroup_children (Music *m )
 {
-  Translator *t = unsmob_translator (context);
-  Translator_group* tr=   dynamic_cast<Translator_group*> (t);
+  SCM tab = get_property ("acceptHashTable");
+  SCM name = scm_assq ( ly_symbol2scm ("name"), m->get_property_alist (false));
 
-  SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
-  tr->internal_set_property (name, val);
+  if (!gh_pair_p (name))
+    return false;
 
-  return SCM_UNSPECIFIED;
+  name = gh_car (name);
+  SCM accept_list = scm_hashq_ref (tab, name, SCM_UNDEFINED);
+  if (accept_list == SCM_BOOL_F)
+    {
+      accept_list = find_accept_translators (simple_trans_list_,
+                                            m->get_mus_property ("types"));
+      scm_hashq_set_x (tab, name, accept_list);
+    }
+
+  for (SCM p = accept_list; gh_pair_p (p); p = ly_cdr (p))
+    {
+      Translator * t = unsmob_translator (ly_car (p));
+      if (t && t->try_music (m))
+       return true;
+    }
+  return false;
 }
index b483c39c18eedb551a15835e9fd336b0eede815d..0c77e982a96c46409871fc8d4d200a6ba7240001 100644 (file)
@@ -6,16 +6,26 @@
   (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include "type-swallow-translator.hh"
+#include "translator.hh"
 #include "musical-request.hh"
 
-
-bool
-Type_swallow_translator::try_music (Music*r)
+class Skip_req_swallow_translator : public virtual Translator
 {
-  if (classname (r) == swallow_string_)
-      return true;
-  return false;
-}
+protected:
+  virtual bool try_music (Music*) { return true; }
+
+public:  
+  TRANSLATOR_DECLARATIONS(Skip_req_swallow_translator);
+};
+
+
+Skip_req_swallow_translator::Skip_req_swallow_translator(){}
 
-DECLARE_REQUEST_SWALLOWER(Skip_req);
+ENTER_DESCRIPTION(Skip_req_swallow_translator,
+                 "Swallow \\skip.",
+                 "",
+                 "skip-event",
+                 "",
+                 "",
+                 "");
+                 
index 70204ee2f556073a8ba1b475f6b7a187c2c9cf0c..e8a5a3aa1593c44ccb7df45d87e7c1e2665330b0 100644 (file)
@@ -60,7 +60,7 @@ Voice_devnull_engraver::try_music (Music *m)
            }
        }
       /* Ugh.  Should eat other requests, script etc. too. */  
-      else if (dynamic_cast<Tie_req*> (m))
+      else if (m->is_mus_type ("tie-event"))
        return true;
     }
   return false;
@@ -123,7 +123,7 @@ Voice_devnull_engraver::Voice_devnull_engraver(){}
 ENTER_DESCRIPTION(Voice_devnull_engraver,
 /* descr */       "Kill off certain items and spanners if we're Voice `two' and unison or unisilence is set.",
 /* creats*/       "",
-/* accepts */     "general-music",
+/* accepts */     "general-music tie-event",
 /* acks  */      "grob-interface",
 /* reads */       "",
 /* write */       "");
index aef7bf664e9e89deffab7703bb52f039f37d0800..fc9e5b9cdd2431e236751c0a41edd156d80341ec 100644 (file)
@@ -34,6 +34,7 @@ TODO: consider making type into symbol ")
 (music-property-description 'cautionary boolean? "If set, this alteration needs cautionary accidental")
 (music-property-description 'change-to-id string? "name of the context to change to ")
 (music-property-description 'change-to-type string? "type of the context to change to.")
+(music-property-description 'compress-procedure procedure? "compress this music expression. Argument 1: the music, arg 2: factor")
 (music-property-description 'context-id string? "name of context")
 (music-property-description 'context-type string?  "type of context")
 (music-property-description 'denominator integer? "denominator in a time signature")
@@ -49,6 +50,7 @@ TODO: consider making type into symbol ")
 (music-property-description 'last-pitch pitch? "The last pitch after relativization.")
 (music-property-description 'length procedure? "How to compute the duration of this music")
 (music-property-description 'internal-class-name string? "C++ class to use for this Music object") 
+(music-property-description 'name symbol? "Name of this music object")
 (music-property-description 'numerator integer? "numerator of a time signature")
 (music-property-description 'once boolean? "Apply this operation only during one time step?")
 (music-property-description 'origin ly-input-location? "where was this piece of music defined?")
index c96ea36fddc739defcf80abf5b4149dc766600de..9c878669942979638d6f03ff98a24e7dceb1b72d 100644 (file)
@@ -1,6 +1,12 @@
 
 (define-public music-descriptions
   `(
+    (AbortEvent
+     . (
+       (internal-class-name . "Span_req")
+       (span-type . "abort")
+       (types . (general-music event abort-event))
+       ))
     (ArpeggioEvent 
      . (
        (internal-class-name .  "Arpeggio_req")
     (BassFigureEvent
      . (
        (internal-class-name . "Bass_figure_req")
+       (compress-procedure . ,music-duration-compress)
+       (length . ,music-duration-length) 
        (types . (general-music event rhythmic-event bass-figure-event))
-       ))  
+       ))
     (BreakEvent
      . (
        (internal-class-name . "Break_req")
      . (
        (internal-class-name . "Lyric_req")
        (types . (general-music rhythmic-event event))
-       )) 
+       ))
+    (LigatureEvent
+     . (
+       (internal-class-name . "Span_req")
+       (span-type . ligature)
+       (types . (general-music event span-event ligature-event))
+       ))
     (MarkEvent
      . (
        (internal-class-name . "Mark_req")
        ))
     (NoteEvent
      . (
-       (internal-class-name . "Note_req")
-       (types . (general-music event rhythmic-event melodic-event))
+       (internal-class-name . "Request")
+       (length . ,music-duration-length) 
+       (compress-procedure . ,music-duration-compress)
+       (types . (general-music event note-event rhythmic-event melodic-event))
        ))
     (PorrectusEvent
      . (
        )) 
     (RestEvent
      . (
-       (internal-class-name . "Rest_req")
-       (types . (general-music event rhythmic-event ))
+       (internal-class-name . "Request")
+       (length . ,music-duration-length)
+       (compress-procedure . ,music-duration-compress)
+       (types . (general-music event rhythmic-event rest-event))
        )) 
     (RhythmicEvent
      . (
        (internal-class-name . "Rhythmic_req")
+       (length . ,music-duration-length) 
+       (compress-procedure . ,music-duration-compress)
        (types . (general-music rhythmic-event  event))
        )) 
     (SequentialMusic
         (types . (general-music layout-instruction))
         (iterator-ctor . ,     Push_property_iterator::constructor)
         ))
-
      (RevertProperty
       . (
         (internal-class-name . "Music")
        (iterator-ctor . , Change_iterator::constructor)
        (types . (general-music translator-change-instruction))
        ))
-
     (TimeScaledMusic
      . (
        (internal-class-name . "Time_scaled_music")
        )) 
     (SkipEvent
      . (
-       (internal-class-name . "Skip_req")
-
-       (types . (general-music event rhythmic-event ))
+       (internal-class-name . "Request")
+       (types . (general-music event rhythmic-event skip-event))
        )) 
     (SpanEvent
      . (
        )) 
     (TieEvent
      . (
-       (internal-class-name . "Tie_req")
+       (internal-class-name . "Request")
        (types . (general-music tie-event event))
        ))
     ))
 
 
 
-(define music-name-to-property-table (make-vector 59))
+(define music-name-to-property-table (make-vector 59 '()))
+
 (map (lambda (x)
-       (hashq-set! music-name-to-property-table (car x) (cdr x))
+       (hashq-set! music-name-to-property-table (car x)
+                  (assoc-set! (cdr x) 'name (car x)))
        )
      music-descriptions)
 
+
+
 (define-public (make-music-by-name x)
   (if (not (symbol? x))
       (misc-error "Not a symbol: ~s" x))
   (let*
       (
        (props (hashq-ref music-name-to-property-table x '()))
-       (name (if (pair? props) (cdr (assoc 'internal-class-name props)) "Music"))
+       (name (if (pair? props)
+                (cdr (assoc 'internal-class-name props))
+                (misc-error "Can not find music object ~s" x)))
        )
-,
+
     (if (eq? props '())
        (ly-warn (format "Could not find music type `~a'" x)))  
     (ly-make-bare-music name props)
   ))
+