]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/translator.cc, lily/context.cc:, lily/translator-group.cc:
authorErik Sandberg <mandolaerik@gmail.com>
Fri, 22 Sep 2006 07:51:37 +0000 (07:51 +0000)
committerErik Sandberg <mandolaerik@gmail.com>
Fri, 22 Sep 2006 07:51:37 +0000 (07:51 +0000)
remove try_music

* lily/*-engraver.cc, lily/*-performer.cc: Remove all remaining
references to Music; use ASSIGN_EVENT_ONCE everywhere

* lily/grob-info.cc: junk *music_cause

* lily/music.cc: copy eventified articulations to stream event

* lily/part-combine-iterator.cc: Cleanup using enums

* lily/translator-group.cc: Junk OldMusicEvent, and associated
methods

* lily/include/engraver.hh: Junk music.hh include

* lily/stream-event.cc: Changed constructors

78 files changed:
ChangeLog
flower/include/international.hh
flower/international.cc
lily/accidental-engraver.cc
lily/ambitus-engraver.cc
lily/arpeggio-engraver.cc
lily/auto-beam-engraver.cc
lily/beam-engraver.cc
lily/beam-performer.cc
lily/breathing-sign-engraver.cc
lily/chord-tremolo-engraver.cc
lily/coherent-ligature-engraver.cc
lily/completion-note-heads-engraver.cc
lily/constrained-breaking.cc
lily/context-handle.cc
lily/context.cc
lily/custos-engraver.cc
lily/drum-note-performer.cc
lily/dynamic-engraver.cc
lily/event-chord-iterator.cc
lily/fall-engraver.cc
lily/figured-bass-engraver.cc
lily/figured-bass-position-engraver.cc
lily/grace-spacing-engraver.cc
lily/gregorian-ligature-engraver.cc
lily/grob-info.cc
lily/grob-pq-engraver.cc
lily/include/context-handle.hh
lily/include/context.hh
lily/include/engraver.hh
lily/include/grob-info.hh
lily/include/paper-column-engraver.hh
lily/include/stream-event.hh
lily/include/translator-group.hh
lily/include/translator.hh
lily/ligature-engraver.cc
lily/lily-parser-scheme.cc
lily/lyric-combine-music-iterator.cc
lily/mark-engraver.cc
lily/melisma-translator.cc
lily/mensural-ligature-engraver.cc
lily/metronome-engraver.cc
lily/multi-measure-rest-engraver.cc
lily/music-iterator.cc
lily/music.cc
lily/new-fingering-engraver.cc
lily/note-heads-engraver.cc
lily/note-name-engraver.cc
lily/note-performer.cc
lily/parenthesis-engraver.cc
lily/part-combine-engraver.cc
lily/part-combine-iterator.cc
lily/percent-repeat-engraver.cc
lily/phrasing-slur-engraver.cc
lily/piano-pedal-engraver.cc
lily/pitched-trill-engraver.cc
lily/recording-group-engraver.cc
lily/relocate.cc
lily/repeat-tie-engraver.cc
lily/rest-engraver.cc
lily/slash-repeat-engraver.cc
lily/slur-engraver.cc
lily/spacing-engraver.cc
lily/staff-symbol-engraver.cc
lily/stem-engraver.cc
lily/stream-event-scheme.cc
lily/stream-event.cc
lily/tab-note-heads-engraver.cc
lily/text-spanner-engraver.cc
lily/tie-engraver.cc
lily/translator-group.cc
lily/translator.cc
lily/trill-spanner-engraver.cc
lily/tuplet-engraver.cc
lily/tweak-engraver.cc
scm/define-event-classes.scm
scm/define-music-types.scm
scm/translation-functions.scm

index bf5710c049221044577cb8b873a30fac8714ebe4..f0d3b2a49373d73bfb559b622d310777bf1cf0c9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
        hidden_state. Works around a problem when parser fetches
        MUSIC_FUNCTION token but not the following EXPECT_* token.
 
+       * lily/translator.cc, lily/context.cc:, lily/translator-group.cc:
+       remove try_music
+
+       * lily/*-engraver.cc, lily/*-performer.cc: Remove all remaining
+       references to Music; use ASSIGN_EVENT_ONCE everywhere
+
+       * lily/grob-info.cc: junk *music_cause
+
+       * lily/music.cc: copy eventified articulations to stream event
+
+       * lily/part-combine-iterator.cc: Cleanup using enums
+
+       * lily/translator-group.cc: Junk OldMusicEvent, and associated
+       methods
+
+       * lily/include/engraver.hh: Junk music.hh include
+
+       * lily/stream-event.cc: Changed constructors
+
 2006-09-21  Graham Percival  <gpermus@gmail.com>
 
        * Documentation/user/tweaks.itely (Fitting music onto fewer
index d1c71ed08b15f3be19d5970f132a76d9a0dad2c6..162e7ee38d8764ae92dbae4fe5e6541d61ee2e62 100644 (file)
@@ -31,6 +31,10 @@ string _ (char const *ch);
 string _f (char const *format, ...)
           __attribute__ ((format (printf, 1, 2)));
 string _f (char const *format, string s, string s2 = "", string s3 = "");
+/**
+   va_list version of _f
+ */
+string v_f (char const *format, va_list args);
 
 #endif // INTERNATIONAL_HH
 
index 7bb4130856468c1824257a2d21b33babe3ca4ca8..ef1ebfbc8967aeef836d95e343ffeb9e625e1140 100644 (file)
@@ -32,11 +32,17 @@ _f (char const *format, ...)
 {
   va_list args;
   va_start (args, format);
-  string str = String_convert::vform_string (gettext (format), args);
+  string str = v_f (format, args);
   va_end (args);
   return str;
 }
 
+string
+v_f (char const *format, va_list args)
+{
+  return String_convert::vform_string (gettext (format), args);
+}
+
 string
 _f (char const *format, string s, string s2, string s3)
 {
index 39a66ba95374e842d4d6cadb5839cf172b2a4ad6..f6ea8e0e18a1bea149d3e3ab874df1404571af24 100644 (file)
 #include "context.hh"
 #include "engraver.hh"
 #include "international.hh"
-#include "music.hh"
 #include "pitch.hh"
 #include "protected-scm.hh"
 #include "rhythmic-head.hh"
 #include "side-position-interface.hh"
+#include "stream-event.hh"
 #include "tie.hh"
 #include "warn.hh"
 
@@ -26,7 +26,7 @@ class Accidental_entry
 {
 public:
   bool done_;
-  Music *melodic_;
+  Stream_event *melodic_;
   Grob *accidental_;
   Context *origin_;
   Engraver *origin_engraver_;
@@ -51,8 +51,8 @@ class Accidental_engraver : public Engraver
   int get_bar_number ();
   void update_local_key_signature ();
   void create_accidental (Accidental_entry *entry, bool, bool);
-  Grob *make_standard_accidental (Music *note, Grob *note_head, Engraver *trans);
-  Grob *make_suggested_accidental (Music *note, Grob *note_head, Engraver *trans);
+  Grob *make_standard_accidental (Stream_event *note, Grob *note_head, Engraver *trans);
+  Grob *make_suggested_accidental (Stream_event *note, Grob *note_head, Engraver *trans);
 
 protected:
   TRANSLATOR_DECLARATIONS (Accidental_engraver);
@@ -316,7 +316,7 @@ Accidental_engraver::process_acknowledged ()
            continue;
          accidentals_[i].done_ = true;
 
-         Music *note = accidentals_[i].melodic_;
+         Stream_event *note = accidentals_[i].melodic_;
          Context *origin = accidentals_[i].origin_;
 
          Pitch *pitch = unsmob_pitch (note->get_property ("pitch"));
@@ -348,7 +348,7 @@ Accidental_engraver::process_acknowledged ()
          /* Cannot look for ties: it's not guaranteed that they reach
             us before the notes. */
          if (num
-             && !note->is_mus_type ("trill-span-event"))
+             && !note->in_event_class ("trill-span-event"))
            create_accidental (&accidentals_[i], num > 1, cautionary);
        }
     }
@@ -359,7 +359,7 @@ Accidental_engraver::create_accidental (Accidental_entry *entry,
                                        bool restore_natural,
                                        bool cautionary)
 {
-  Music *note = entry->melodic_;
+  Stream_event *note = entry->melodic_;
   Grob *support = entry->head_;
   Pitch *pitch = unsmob_pitch (note->get_property ("pitch"));
 
@@ -387,7 +387,7 @@ Accidental_engraver::create_accidental (Accidental_entry *entry,
 }
 
 Grob *
-Accidental_engraver::make_standard_accidental (Music *note,
+Accidental_engraver::make_standard_accidental (Stream_event *note,
                                               Grob *note_head,
                                               Engraver *trans)
 {
@@ -433,7 +433,7 @@ Accidental_engraver::make_standard_accidental (Music *note,
 }
 
 Grob *
-Accidental_engraver::make_suggested_accidental (Music *note,
+Accidental_engraver::make_suggested_accidental (Stream_event *note,
                                                Grob *note_head,
                                                Engraver *trans)
 {
@@ -481,7 +481,7 @@ Accidental_engraver::stop_translation_timestep ()
     {
       int barnum = get_bar_number ();
 
-      Music *note = accidentals_[i].melodic_;
+      Stream_event *note = accidentals_[i].melodic_;
       Context *origin = accidentals_[i].origin_;
 
       Pitch *pitch = unsmob_pitch (note->get_property ("pitch"));
@@ -537,10 +537,10 @@ Accidental_engraver::stop_translation_timestep ()
 void
 Accidental_engraver::acknowledge_rhythmic_head (Grob_info info)
 {
-  Music *note = info.music_cause ();
+  Stream_event *note = info.event_cause ();
   if (note
-      && (note->is_mus_type ("note-event")
-         || note->is_mus_type ("trill-span-event")))
+      && (note->in_event_class ("note-event")
+         || note->in_event_class ("trill-span-event")))
     {
       /*
        string harmonics usually don't have accidentals.
index f71c33b49c9c62537fd67ba4187eb6125359a4a8..1321c5bf6e1858d14a9391d7ed1aa937aa62a2f2 100644 (file)
@@ -17,6 +17,7 @@
 #include "protected-scm.hh"
 #include "side-position-interface.hh"
 #include "staff-symbol-referencer.hh" 
+#include "stream-event.hh"
 
 #include "translator.icc"
 
@@ -117,8 +118,8 @@ Ambitus_engraver::stop_translation_timestep ()
 void
 Ambitus_engraver::acknowledge_note_head (Grob_info info)
 {
-  Music *nr = info.music_cause ();
-  if (nr && nr->is_mus_type ("note-event"))
+  Stream_event *nr = info.event_cause ();
+  if (nr && nr->in_event_class ("note-event"))
     {
       Pitch pitch = *unsmob_pitch (nr->get_property ("pitch"));
       pitch_interval_.add_point (pitch);
index 1cc143dbd7beb9144decf9f80d1d58b4f88cd245..633d924e5a950f03a1ff8847e8b196bd2beddfb5 100644 (file)
@@ -44,7 +44,7 @@ Arpeggio_engraver::Arpeggio_engraver ()
 IMPLEMENT_TRANSLATOR_LISTENER (Arpeggio_engraver, arpeggio);
 void Arpeggio_engraver::listen_arpeggio (Stream_event *ev)
 {
-  arpeggio_event_ = ev;
+  ASSIGN_EVENT_ONCE (arpeggio_event_, ev);
 }
 
 void
index 26aef175432b2c4e05554e7f5b01980b19cb5d87..0472c4cdec07dc9b31436cb0ceef7f3437ffb283 100644 (file)
@@ -133,7 +133,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Auto_beam_engraver, beam_forbid);
 void
 Auto_beam_engraver::listen_beam_forbid (Stream_event *ev)
 {
-  forbid_ = ev;
+  ASSIGN_EVENT_ONCE (forbid_, ev);
 }
 
 bool
index 42d0a8db418b3f0e0c548a0b628c0a668d03890b..46d932e2f785d460bc795bf49fc9d24d00bcbf1b 100644 (file)
@@ -102,9 +102,9 @@ Beam_engraver::listen_beam (Stream_event *ev)
   Direction d = to_dir (ev->get_property ("span-direction"));
 
   if (d == START && valid_start_point ())
-    start_ev_ = ev;
+    ASSIGN_EVENT_ONCE (start_ev_, ev);
   else if (d == STOP && valid_end_point ())
-    now_stop_ev_ = ev;
+    ASSIGN_EVENT_ONCE (now_stop_ev_, ev);
 }
 
 void
index 6d36c78381774295d3d1c60411cf9bca29db0f66..ba0135f1d093741258641109e052ec3fc4d0673b 100644 (file)
@@ -12,7 +12,6 @@
 #include "global-context.hh"
 #include "stream-event.hh"
 #include "warn.hh"
-#include "music.hh"
 
 #include "translator.icc"
 
index 5b2ddaff47f1ddf0c670067cdb7a8be695546aa6..126110e07efce3e39b9b3202d3508f763aee8b3b 100644 (file)
@@ -42,9 +42,9 @@ Breathing_sign_engraver::Breathing_sign_engraver ()
 
 IMPLEMENT_TRANSLATOR_LISTENER (Breathing_sign_engraver, breathing);
 void
-Breathing_sign_engraver::listen_breathing (Stream_event *r)
+Breathing_sign_engraver::listen_breathing (Stream_event *ev)
 {
-  breathing_sign_event_ = r;
+  ASSIGN_EVENT_ONCE (breathing_sign_event_, ev);
 }
 
 void
index b0f17352baa49915e771c4b92d8d23f1fe34b60e..f07e9846267767d829ebfc30c84baf1b45e33ef8 100644 (file)
@@ -73,15 +73,19 @@ Chord_tremolo_engraver::listen_tremolo_span (Stream_event *ev)
   Direction span_dir = to_dir (ev->get_property ("span-direction"));
   if (span_dir == START)
     {
-      repeat_ = ev;
-      int type = scm_to_int (ev->get_property ("tremolo-type"));
-      /* e.g. 1 for type 8, 2 for type 16 */
-      flags_ = intlog2 (type) - 2;
-      expected_beam_count_ = scm_to_int (ev->get_property ("expected-beam-count"));
-      beam_dir_ = RIGHT;
+      if (ASSIGN_EVENT_ONCE (repeat_, ev))
+       {
+         int type = scm_to_int (ev->get_property ("tremolo-type"));
+         /* e.g. 1 for type 8, 2 for type 16 */
+         flags_ = intlog2 (type) - 2;
+         expected_beam_count_ = scm_to_int (ev->get_property ("expected-beam-count"));
+         beam_dir_ = RIGHT;
+       }
     }
   else if (span_dir == STOP)
     {
+      if (!repeat_)
+       ev->origin ()->warning (_ ("No tremolo to end"));
       repeat_ = 0;
       beam_ = 0;
       expected_beam_count_ = 0;
@@ -123,13 +127,13 @@ Chord_tremolo_engraver::acknowledge_stem (Grob_info info)
       if (beam_dir_ == RIGHT)
         beam_dir_ = LEFT;
 
-      if (info.ultimate_music_cause ()->is_mus_type ("rhythmic-event"))
+      if (info.ultimate_event_cause ()->in_event_class ("rhythmic-event"))
        Beam::add_stem (beam_, s);
       else
        {
          string s = _ ("stem must have Rhythmic structure");
-         if (info.music_cause ())
-           info.music_cause ()->origin ()->warning (s);
+         if (info.event_cause ())
+           info.event_cause ()->origin ()->warning (s);
          else
            ::warning (s);
        }
index a4815f0b8a2c261134a434cffa209c65fe7763a9..96ff842d0c57a44ffe2ff7a9555ce0b40cddd28a 100644 (file)
@@ -9,11 +9,12 @@
 #include "coherent-ligature-engraver.hh"
 
 #include "warn.hh"
-#include "staff-symbol-referencer.hh"
-#include "spanner.hh"
 #include "paper-column.hh"
 #include "pitch.hh"
 #include "pointer-group-interface.hh"
+#include "spanner.hh"
+#include "staff-symbol-referencer.hh"
+#include "stream-event.hh"
 
 /*
  * This abstract class serves as common superclass for all ligature
@@ -142,9 +143,9 @@ compute_delta_pitches (vector<Grob_info> primitives)
   for (vsize i = 0; i < primitives.size (); i++)
     {
       primitive = dynamic_cast<Item *> (primitives[i].grob ());
-      Music *music_cause = primitives[i].music_cause ();
+      Stream_event *cause = primitives[i].event_cause ();
       int pitch
-       = unsmob_pitch (music_cause->get_property ("pitch"))->steps ();
+       = unsmob_pitch (cause->get_property ("pitch"))->steps ();
       if (prev_primitive)
        {
          delta_pitch = pitch - prev_pitch;
index 3e5056619d6345af1b157b75948d4bf866ba70c1..69cd4b0785c90350a3707f1a103b727ba8d875fc 100644 (file)
@@ -12,7 +12,6 @@ using namespace std;
 #include "duration.hh"
 #include "global-context.hh"
 #include "item.hh"
-#include "music.hh"
 #include "output-def.hh"
 #include "pitch.hh"
 #include "rhythmic-head.hh"
index 4d9c5795eea42d6d80b159c8af1804b8c6e03d2f..4e5de38254a45df3b81d016d298ffc546bab97f4 100644 (file)
@@ -238,7 +238,7 @@ Constrained_breaking::get_solution (vsize start, vsize end, vsize sys_count)
             {
               if (brk != end_brk)
                 {
-                  warning ( _("couldn't find line breaking that satisfies constraints" ));
+                  warning (("couldn't find line breaking that satisfies constraints" ));
                   ret.push_back (space_line (brk, end_brk));
                 }
               /* build up the good solution */
@@ -255,7 +255,7 @@ Constrained_breaking::get_solution (vsize start, vsize end, vsize sys_count)
         }
     }
   /* if we get to here, just put everything on one line */
-  warning ( _("couldn't find line breaking that satisfies constraints" ));
+  warning (("couldn't find line breaking that satisfies constraints" ));
   ret.push_back (space_line (0, end_brk));
   return ret;
 }
index b9c8692ff07715e23ad2f2ca4c935b6570683da5..80aa6a1a2f94978c7ac4b36d4a2d547c9f17198e 100644 (file)
@@ -47,12 +47,6 @@ Context_handle::down ()
   outlet_ = 0;
 }
 
-bool
-Context_handle::try_music (Music *m)
-{
-  return outlet_->try_music (m);
-}
-
 void
 Context_handle::operator = (Context_handle const &s)
 {
index 5211cbb3f01f2bd118375e09e5e541e776d399e3..d9c5f88129e9d746072252638fbb895c31e290f7 100644 (file)
@@ -655,20 +655,6 @@ IMPLEMENT_SMOBS (Context);
 IMPLEMENT_DEFAULT_EQUAL_P (Context);
 IMPLEMENT_TYPE_P (Context, "ly:context?");
 
-bool
-Context::try_music (Music *m)
-{
-  Translator_group *t = implementation ();
-  if (!t)
-    return false;
-
-  bool b = t->try_music (m);
-  if (!b && daddy_context_)
-    b = daddy_context_->try_music (m);
-
-  return b;
-}
-
 Global_context *
 Context::get_global_context () const
 {
index 3b3f7610e0db9efd36c217fd8c7e851d1e5f74db..82381b764ca012b4d40c1316cef7f8f9a09d33af 100644 (file)
 #include "bar-line.hh"
 #include "item.hh"
 #include "note-head.hh"
+#include "pitch.hh"
 #include "staff-symbol-referencer.hh"
+#include "stream-event.hh"
 #include "warn.hh"
-#include "pitch.hh"
 
 #include "translator.icc"
 
@@ -73,8 +74,8 @@ Custos_engraver::acknowledge_bar (Grob_info info)
 void
 Custos_engraver::acknowledge_note_head (Grob_info info)
 {
-  Music *m = info.music_cause ();
-  if (m && m->is_mus_type ("note-event"))
+  Stream_event *ev = info.event_cause ();
+  if (ev && ev->in_event_class ("note-event"))
     {
 
       /*
@@ -85,7 +86,7 @@ Custos_engraver::acknowledge_note_head (Grob_info info)
        don't look at the staff-position, since we can't be sure
        whether Clef_engraver already applied a vertical shift.
       */
-      pitches_.push_back (*unsmob_pitch (m->get_property ("pitch")));
+      pitches_.push_back (*unsmob_pitch (ev->get_property ("pitch")));
     }
 }
 
index 2926fb8961279339ac29f3c1e9e1ba89e38082c3..a4e0ff2f7f526841fa04b1e212153e33b68c590e 100644 (file)
@@ -10,7 +10,6 @@
 #include "audio-item.hh"
 #include "audio-column.hh"
 #include "global-context.hh"
-#include "music.hh"
 #include "pitch.hh"
 #include "stream-event.hh"
 #include "translator.icc"
@@ -53,17 +52,17 @@ Drum_note_performer::process_music ()
       if (Pitch *pit = unsmob_pitch (defn))
        {
           SCM articulations = n->get_property ("articulations");
-          Music *tie_event = 0;
+          Stream_event *tie_event = 0;
           for (SCM s = articulations;
                !tie_event && scm_is_pair (s);
                s = scm_cdr (s))
             {
-              Music *m = unsmob_music (scm_car (s));
-              if (!m)
+              Stream_event *ev = unsmob_stream_event (scm_car (s));
+              if (!ev)
                 continue;
          
-              if (m->is_mus_type ("tie-event"))
-                tie_event = m;
+              if (ev->in_event_class ("tie-event"))
+                tie_event = ev;
             }
 
          Audio_note *p = new Audio_note (*pit, get_event_length (n), 
index 09a7e3930535a52b7a89686c7fde09ad804eb4cb..d8795f0bdc76f025383093c42180b150e5cac1eb 100644 (file)
@@ -97,7 +97,7 @@ Dynamic_engraver::listen_absolute_dynamic (Stream_event *ev)
   /*
     TODO: probably broken.
   */
-  script_ev_ = ev;
+  ASSIGN_EVENT_ONCE (script_ev_, ev);
 }
 
 IMPLEMENT_TRANSLATOR_LISTENER (Dynamic_engraver, span_dynamic);
@@ -106,9 +106,14 @@ Dynamic_engraver::listen_span_dynamic (Stream_event *ev)
 {
   Direction d = to_dir (ev->get_property ("span-direction"));
 
-  accepted_spanevents_drul_[d] = ev;
-  if (current_cresc_ev_ && d == START)
-    accepted_spanevents_drul_[STOP] = ev;
+  if (d == START)
+    ASSIGN_EVENT_ONCE (accepted_spanevents_drul_[START], ev);
+  
+  /* Cancel any ongoing crescendo, either explicitly by \! or
+     implicitly by a new crescendo. Also avoid warning if cresc is
+     cancelled both implicitly and explicitly. */
+  if ((d == STOP || current_cresc_ev_) && !accepted_spanevents_drul_[STOP])
+    ASSIGN_EVENT_ONCE (accepted_spanevents_drul_[STOP], ev);
 }
 
 void
index 60e7e3081a0ba00fce334c5ec16f5527181ceae1..89a0f383a99020427b918e09f8675663b9f7f087 100644 (file)
@@ -9,11 +9,13 @@
 #include "event-chord-iterator.hh"
 
 #include "context.hh"
+#include "dispatcher.hh"
 #include "duration.hh"
 #include "input.hh"
 #include "international.hh"
 #include "music.hh"
 #include "pitch.hh"
+#include "stream-event.hh"
 #include "warn.hh"
 
 Event_chord_iterator::Event_chord_iterator ()
@@ -38,6 +40,12 @@ Event_chord_iterator::process (Moment m)
          Music *mus = unsmob_music (scm_car (s));
          report_event (mus);
        }
+      for (SCM s = get_music ()->get_property ("events");
+          scm_is_pair (s); s = scm_cdr (s))
+       {
+         Stream_event *ev = unsmob_stream_event (scm_car (s));
+         get_outlet ()->event_source ()->broadcast (ev);
+       }
     }
   Simple_music_iterator::process (m);
 }
index 5df614bb419c9720193bd8973b5c65633f99ab7b..b0751a31d54430edf98be4db79e050036ecbe0c4 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "engraver.hh"
 #include "item.hh"
+#include "moment.hh"
 #include "spanner.hh"
 #include "stream-event.hh"
 
@@ -92,7 +93,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Bend_after_engraver, bend_after);
 void
 Bend_after_engraver::listen_bend_after (Stream_event *ev)
 {
-  fall_event_ = ev;
+  ASSIGN_EVENT_ONCE (fall_event_, ev);
 }
 
 void
index 9e0bf61786704b5a0e1882748789cae163931a69..a300df86d496d3ef10cf6889226370303ab2ad05 100644 (file)
@@ -137,7 +137,7 @@ void
 Figured_bass_engraver::listen_rest (Stream_event *ev)
 {
   new_event_found_ = true;
-  rest_event_ = ev;
+  ASSIGN_EVENT_ONCE (rest_event_, ev);
 }
 
 IMPLEMENT_TRANSLATOR_LISTENER (Figured_bass_engraver, bass_figure);
@@ -145,8 +145,9 @@ void
 Figured_bass_engraver::listen_bass_figure (Stream_event *ev)
 {
   new_event_found_ = true;
-  stop_moment_ = now_mom () + get_event_length (ev);
-     
+  Moment stop  = now_mom () + get_event_length (ev);
+  stop_moment_ = max (stop_moment_, stop);
+
   SCM fig = ev->get_property ("figure");
   for (vsize i = 0; i < groups_.size (); i++)
     {
index 8b4e7462c7c02339852d952633275fffcb593a91..2286fe6b526568154547ab8ca116bc560ecf8730 100644 (file)
@@ -10,7 +10,6 @@
 #include "engraver.hh"
 
 #include "context.hh"
-#include "music.hh"
 #include "spanner.hh"
 #include "side-position-interface.hh"
 #include "translator.icc"
index b784358a2c9dc335dd22a96ff338c3f89caa8d7e..f86b12ef22287b4a16ba7547d05bd3cbb4dca294 100644 (file)
@@ -8,8 +8,9 @@
 */
 
 #include "engraver.hh"
-#include "spanner.hh"
+#include "moment.hh"
 #include "pointer-group-interface.hh"
+#include "spanner.hh"
 
 #include "translator.icc"
 
index 6a99e3946e71ab0ed0655ab1cc7f69e3de04d266..e6b3c9b534ed67737ce708abf47f70f419afad42 100644 (file)
@@ -17,6 +17,9 @@
 #include "stream-event.hh"
 #include "warn.hh"
 
+/* ASSIGN_EVENT_ONCE */
+#include "translator.icc"
+
 /*
  * This abstract class is the common superclass for all ligature
  * engravers for Gregorian chant notation.  It cares for the musical
@@ -36,7 +39,7 @@ Gregorian_ligature_engraver::Gregorian_ligature_engraver ()
 void
 Gregorian_ligature_engraver::listen_pes_or_flexa (Stream_event *ev)
 {
-  pes_or_flexa_req_ = ev;
+  ASSIGN_EVENT_ONCE (pes_or_flexa_req_, ev);
 }
 
 void fix_prefix (char *name, int mask,
index 5ad3d5701e36fa6525fd422d017dcdd19528662a..23ff736d9536c0ab62a7b40c1a5023662052dddf 100644 (file)
@@ -29,24 +29,6 @@ Grob_info::Grob_info ()
   origin_trans_ = 0;
 }
 
-/* ES TODO: Junk this when no more engravers use try_music */
-Music *
-Grob_info::music_cause () const
-{
-  SCM cause = grob_->get_property ("cause");
-
-  Music *ret = unsmob_music (cause);
-  if (ret)
-    return ret;
-  else
-    {
-      Stream_event *ev = unsmob_stream_event (cause);
-      if (!ev)
-       return 0;
-      return unsmob_music (ev->get_property ("music-cause"));
-    }
-}
-
 Stream_event *
 Grob_info::event_cause () const
 {
@@ -97,25 +79,3 @@ Grob_info::ultimate_event_cause () const
     }
   return unsmob_stream_event (cause);
 }
-
-/*
-ES TODO: Junk this when no more engraver uses try_music
-*/
-Music *
-Grob_info::ultimate_music_cause () const
-{
-  SCM cause = grob_->self_scm ();
-  while (unsmob_grob (cause))
-    {
-      cause = unsmob_grob (cause)->get_property ("cause");
-    }
-
-  Music *ret = unsmob_music (cause);
-  if (ret)
-    return ret;
-  else
-    {
-      Stream_event *ev = unsmob_stream_event (cause);
-      return unsmob_music (ev->get_property ("music-cause"));
-    }
-}
index 80d072b404fff458548a8ccb1b9b435f5bffbe7b..6f6ee8faabd901ba2b851af7d52c6e5cf79c4cc5 100644 (file)
@@ -60,13 +60,13 @@ LY_DEFINE (ly_grob_pq_less_p, "ly:grob-pq-less?",
 void
 Grob_pq_engraver::acknowledge_grob (Grob_info gi)
 {
-  Music *m = gi.music_cause ();
+  Stream_event *ev = gi.event_cause ();
 
-  if (m
+  if (ev
       && !gi.grob ()->internal_has_interface (ly_symbol2scm ("multi-measure-interface")))
     {
       Moment n = now_mom ();
-      Moment l = m->get_length ();
+      Moment l = get_event_length (ev);
 
       if (!l.to_bool ())
        return;
index ea7e255809e96422619b6729d8322b5e9e86938a..e32bc29cb7f8881b6d7589c4f622473396f5d8e9 100644 (file)
@@ -21,7 +21,6 @@ public:
   Context_handle ();
 
   void set_context (Context *);
-  bool try_music (Music *);
   void operator = (Context_handle const &);
   Context_handle (Context_handle const &);
   Context *get_outlet () const;
index 1a9c0c256730133045bd3a7573dbd0127f8d523a..6be715ce3de1e037b306ca243b68da27e600146d 100644 (file)
@@ -112,7 +112,6 @@ public:
   void add_context (Context *trans);
   bool is_bottom_context () const;
   bool is_removable () const;
-  bool try_music (Music *);
 
   Context *find_create_context (SCM context_name,
                                string id, SCM ops);
index 04a7623e3f47e2ae6adb1aa2588e4e8f3e2839a3..abbeb2eec9ad99500b94e577928b20b48f0f161f 100644 (file)
@@ -9,7 +9,6 @@
 #ifndef ENGRAVER_HH
 #define ENGRAVER_HH
 
-#include "music.hh"
 #include "grob-info.hh"
 #include "translator.hh"
 
index ebd860ef3a82869ee156886d6678f994b22a7f73..b92f033718e48c3b1d44357ffea3ce2b1660c35a 100644 (file)
@@ -30,9 +30,7 @@ public:
 
   Context *context () const;
   Stream_event *event_cause () const;
-  Music *music_cause () const;
   Stream_event *ultimate_event_cause () const;
-  Music *ultimate_music_cause () const;
   vector<Context*> origin_contexts (Translator *) const;
   Grob_info (Translator *, Grob *);
   Grob_info ();
index 5f3131ccb009411731cf1b1bac2f313cc360b51e..1dd227e2090adbb1a0aa44c7c19e0fd1be14a3e4 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "engraver.hh"
 #include "listener.hh"
+#include "moment.hh"
 #include "stream-event.hh"
 
 class Paper_column_engraver : public Engraver
index 991e6723090a26b9f040870270c5fe9f07e8c838..4e1688f6f466a7fa3436b3ebfd082f67845f1181 100644 (file)
@@ -19,8 +19,7 @@ public:
   Stream_event ();
   VIRTUAL_COPY_CONSTRUCTOR (Stream_event, Stream_event);
   // todo: remove unneeded constructors
-  Stream_event (SCM event_class, SCM mutable_props);
-  Stream_event (SCM property_alist);
+  Stream_event (SCM event_class, SCM mutable_props=SCM_EOL);
   Stream_event (SCM class_name, Input *);
   Stream_event (Stream_event *ev);
 
index 2552fb4186fbf4067865b039413cef60e690e7c7..45a7c77030343940383b54fc65e3a9e912466c43 100644 (file)
@@ -50,7 +50,6 @@ private:
   SCM protected_events_;
 
   DECLARE_LISTENER (create_child_translator);
-  DECLARE_LISTENER (eat_event);
 
 public:
   VIRTUAL_COPY_CONSTRUCTOR (Translator_group, Translator_group);
@@ -61,7 +60,6 @@ public:
   virtual void disconnect_from_context ();
   virtual Translator_group *get_daddy_translator ()const;
   virtual SCM get_simple_trans_list ();
-  virtual bool try_music (Music *req);
   virtual void initialize ();
   virtual void finalize ();
 
@@ -80,7 +78,6 @@ public:
   Context *context () const { return context_; }
 protected:
   SCM simple_trans_list_;
-  SCM accept_hash_table_;
   Context *context_;
 
   friend class Context_def;
index 871b87a95dd3cad5729f5eac3ead83850efe7998..eea779085aa82b23676da28f52088e21a83d9765 100644 (file)
@@ -108,7 +108,6 @@ public:
   virtual Translator_group *get_daddy_translator ()const;
   virtual Moment now_mom () const;
 
-  virtual bool try_music (Music *req);
   virtual void initialize ();
   virtual void finalize ();
 
index 81523a0109d5056fc5050c3d7099c503c6736b3b..9922ca1c4819706cb478cf74aa55bcdb5bd2115f 100644 (file)
@@ -82,7 +82,7 @@ void
 Ligature_engraver::listen_ligature (Stream_event *ev)
 {
   Direction d = to_dir (ev->get_property ("span-direction"));
-  events_drul_[d] = ev;
+  ASSIGN_EVENT_ONCE (events_drul_[d], ev);
 }
 
 void
index 30062e14ff61706141e529a30a20e48a8898ca8f..90d9a60366e018a21fc845de9bf91ae55419927d 100644 (file)
@@ -110,9 +110,9 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
       exit (2);
     }
 
-  if ((file_name != "-") && global_path.find (file_name).empty ())
+  if ((file_name != "-") && file_name.empty ())
     {
-      warning (_f ("can't find file: `%s'", file_name));
+      warning (_f ("can't find file: `%s'", file));
       scm_throw (ly_symbol2scm ("ly-file-failed"),
                 scm_list_1 (scm_makfrom0str (file_name.c_str ())));
     }
index aaccf2e2107bccd81438c580b05cc8efe612f136..dafed1d3c8756e74ac9f61faaeab022eba64464e 100644 (file)
@@ -63,11 +63,8 @@ void
 Lyric_combine_music_iterator::set_busy (SCM se)
 {
   Stream_event *e = unsmob_stream_event (se);
-  SCM mus = e->get_property ("music");
-  Music *m = unsmob_music (mus);
-  assert (m);
 
-  if (m->is_mus_type ("note-event") || m->is_mus_type ("cluster-note-event"))
+  if (e->in_event_class ("note-event") || e->in_event_class ("cluster-note-event"))
     busy_ = true;
 }
 
@@ -76,13 +73,13 @@ Lyric_combine_music_iterator::set_music_context (Context *to)
 {
   if (music_context_)
     {
-      music_context_->event_source()->remove_listener (GET_LISTENER (set_busy), ly_symbol2scm ("OldMusicEvent"));
+      music_context_->event_source()->remove_listener (GET_LISTENER (set_busy), ly_symbol2scm ("music-event"));
       lyrics_context_->unset_property (ly_symbol2scm ("associatedVoiceContext"));
     }
   music_context_ = to;
   if (to)
     {
-      to->event_source()->add_listener (GET_LISTENER (set_busy), ly_symbol2scm ("OldMusicEvent"));
+      to->event_source()->add_listener (GET_LISTENER (set_busy), ly_symbol2scm ("music-event"));
       lyrics_context_->set_property ("associatedVoiceContext", to->self_scm ());
     }
 }
index b236779ac17773029e51e5eb053ed2a4297fb421..70115d62fdcd5de334cb2acda79ceb9a49e41747 100644 (file)
@@ -113,7 +113,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Mark_engraver, mark);
 void
 Mark_engraver::listen_mark (Stream_event *ev)
 {
-  mark_ev_ = ev;
+  ASSIGN_EVENT_ONCE (mark_ev_, ev);
 }
 
 /*
index 69f9f7f53abd7ece6099d9394101e2dfb2788074..adc873d4dcfa176cc746d3f6e44b88eb744edcc5 100644 (file)
@@ -9,6 +9,7 @@
 #include "engraver.hh"
 #include "grob.hh"
 #include "context.hh"
+#include "music.hh"
 #include "translator.icc"
 
 /* Remove this translator. */
index c1c5bcad6d3a9e8cd2bce49618635fa6576816d2..f40ce004b056b6bbc2df480a3b5bf20d5f9f213d 100644 (file)
 #include "font-interface.hh"
 #include "international.hh"
 #include "mensural-ligature.hh"
-#include "music.hh"
 #include "note-column.hh"
 #include "note-head.hh"
 #include "output-def.hh"
 #include "paper-column.hh"
+#include "pitch.hh"
 #include "rhythmic-head.hh"
 #include "spanner.hh"
 #include "staff-symbol-referencer.hh"
@@ -104,12 +104,12 @@ Mensural_ligature_engraver::transform_heads (vector<Grob_info> primitives)
       Item *primitive = dynamic_cast<Item *> (info.grob ());
       int duration_log = Note_head::get_balltype (primitive);
 
-      Music *nr = info.music_cause ();
+      Stream_event *nr = info.event_cause ();
 
       /*
        ugh. why not simply check for pitch?
       */
-      if (!nr->is_mus_type ("note-event"))
+      if (!nr->in_event_class ("note-event"))
        {
          nr->origin ()->warning
            (_f ("cannot determine pitch of ligature primitive -> skipping"));
@@ -174,7 +174,7 @@ Mensural_ligature_engraver::transform_heads (vector<Grob_info> primitives)
            }
          // b. descendens longa or brevis
          else if (i < s - 1
-                  && (unsmob_pitch (primitives[i + 1].music_cause ()
+                  && (unsmob_pitch (primitives[i + 1].event_cause ()
                                     ->get_property ("pitch"))->steps () < pitch)
                   && duration_log > -3)
            {
index cfae9a5ee87c4f0cba3e124df239e78c3de013b6..5e5986d2ea81f2911505e96f1bae39b7138d1ef5 100644 (file)
@@ -11,10 +11,13 @@ using namespace std;
 
 #include "engraver.hh"
 
-#include "item.hh"
 #include "context.hh"
-#include "grob-array.hh"
 #include "duration.hh"
+#include "grob-array.hh"
+#include "item.hh"
+#include "stream-event.hh"
+
+#include "translator.icc"
 
 /**
    put stuff over or next to  bars.  Examples: bar numbers, marginal notes,
@@ -91,8 +94,6 @@ Metronome_mark_engraver::process_music ()
   last_count_ = count;
 }
 
-#include "translator.icc"
-
 ADD_TRANSLATOR (Metronome_mark_engraver,
                /* doc */ "Engrave metro nome marking. This delegates the formatting work "
                "to the function in the metronomeMarkFormatter property. "
index ff073601e938be2081af8b271c3c20a2bada0aeb..20199593994f1ba0c0386daf56cce529c6af20aa 100644 (file)
@@ -65,8 +65,14 @@ IMPLEMENT_TRANSLATOR_LISTENER (Multi_measure_rest_engraver, multi_measure_rest);
 void
 Multi_measure_rest_engraver::listen_multi_measure_rest (Stream_event *ev)
 {
+  /* FIXME: Should use ASSIGN_EVENT_ONCE. Can't do that yet because of
+     the kill-mm-rests hack in part-combine-iterator. */
   rest_ev_ = ev;
   stop_moment_ = now_mom () + get_event_length (rest_ev_);
+  /*
+  if (ASSIGN_EVENT_ONCE (rest_ev_, ev))
+    stop_moment_ = now_mom () + get_event_length (rest_ev_);
+  */
 }
 
 IMPLEMENT_TRANSLATOR_LISTENER (Multi_measure_rest_engraver, multi_measure_text);
index ce824968a9b1d3242c8dd582c77a7ad4e749ac8d..036a0c324945341182b4c4a04b2a6043e17b8b8d 100644 (file)
@@ -169,7 +169,7 @@ Music_iterator::report_event (Music *m)
     FIXME: then don't do it. 
   */
   if (!m->is_mus_type ("event"))
-    m->origin ()->programming_error (_f ("Sending non-event to context"));
+    m->origin ()->programming_error (_ ("Sending non-event to context"));
 
   m->send_to_context (get_outlet ());
 }
index 4d71d99d98e6bfd8069936ccd88600834d563d3b..b938c86e2235bc5235b3081a6623d218eb142b6c 100644 (file)
@@ -269,7 +269,7 @@ Music::to_event () const
   out[outpos] = 0;
   SCM class_name = ly_symbol2scm (out);
 
-  // catch mistakes.
+  // catch programming mistakes.
   if (!internal_is_music_type (class_name))
     {
       programming_error ("Not a music type");
@@ -280,24 +280,32 @@ Music::to_event () const
   if (length.to_bool ())
     e->set_property ("length", length.smobbed_copy ());
 
+  // articulations as events.
+  SCM art_mus = e->get_property ("articulations");
+  if (scm_is_pair (art_mus))
+    {
+      SCM art_ev = SCM_EOL;
+      for (; scm_is_pair (art_mus); art_mus = scm_cdr (art_mus))
+       {
+         Music *m = unsmob_music (scm_car (art_mus));
+         SCM ev = m ? m->to_event ()->unprotect () : scm_car (art_mus);
+         art_ev = scm_cons (ev, art_ev);
+       }
+      e->set_property ("articulations", scm_reverse_x (art_ev, SCM_EOL));
+    }
+
   /*
     ES TODO: This is a temporary fix. Stream_events should not be
     aware of music.
   */
   e->set_property ("music-cause", self_scm ());
+
   return e;
 }
 
 void
 Music::send_to_context (Context *c)
 {
-  /*
-    TODO: This is a work-in-progress solution. Send the event so it
-    can be read both by old-style translators and the new ones.
-  */
-  send_stream_event (c, "OldMusicEvent", origin (),
-                    ly_symbol2scm("music"), self_scm (), 0);
-
   Stream_event *ev = to_event ();
   c->event_source ()->broadcast (ev);
   ev->unprotect ();
index 75e893c351e585e056970becf1a28d9c65b641bb..2e8c94399ca16d79664a702dfa6bc05507914b43 100644 (file)
@@ -14,7 +14,7 @@
 #include "self-alignment-interface.hh"
 #include "side-position-interface.hh"
 #include "stem.hh"
-#include "stem.hh"
+#include "stream-event.hh"
 #include "warn.hh"
 
 #include "translator.icc"
@@ -23,8 +23,8 @@ struct Finger_tuple
 {
   Grob *head_;
   Grob *script_;
-  Music *note_event_;
-  Music *finger_event_;
+  Stream_event *note_event_;
+  Stream_event *finger_event_;
   bool follow_into_staff_;
   int position_;
 
@@ -58,16 +58,16 @@ protected:
   void stop_translation_timestep ();
   DECLARE_ACKNOWLEDGER (rhythmic_head);
   DECLARE_ACKNOWLEDGER (stem);
-  void add_fingering (Grob *, Music *, Music *);
-  void add_script (Grob *, Music *, Music *);
-  void add_string (Grob *, Music *, Music *);
+  void add_fingering (Grob *, Stream_event *, Stream_event *);
+  void add_script (Grob *, Stream_event *, Stream_event *);
+  void add_string (Grob *, Stream_event *, Stream_event *);
   void position_scripts (SCM orientations, vector<Finger_tuple> *);
 };
 
 void
 New_fingering_engraver::acknowledge_rhythmic_head (Grob_info inf)
 {
-  Music *note_ev = inf.music_cause ();
+  Stream_event *note_ev = inf.event_cause ();
   if (!note_ev)
     return;
 
@@ -75,20 +75,20 @@ New_fingering_engraver::acknowledge_rhythmic_head (Grob_info inf)
 
   for (SCM s = arts; scm_is_pair (s); s = scm_cdr (s))
     {
-      Music *m = unsmob_music (scm_car (s));
+      Stream_event *ev = unsmob_stream_event (scm_car (s));
 
-      if (!m)
+      if (!ev)
        continue;
 
-      if (m->is_mus_type ("fingering-event"))
-       add_fingering (inf.grob (), m, note_ev);
-      else if (m->is_mus_type ("text-script-event"))
-       m->origin ()->warning (_ ("can't add text scripts to individual note heads"));
-      else if (m->is_mus_type ("script-event"))
-       add_script (inf.grob (), m, note_ev);
-      else if (m->is_mus_type ("string-number-event"))
-       add_string (inf.grob (), m, note_ev);
-      else if (m->is_mus_type ("harmonic-event"))
+      if (ev->in_event_class ("fingering-event"))
+       add_fingering (inf.grob (), ev, note_ev);
+      else if (ev->in_event_class ("text-script-event"))
+       ev->origin ()->warning (_ ("can't add text scripts to individual note heads"));
+      else if (ev->in_event_class ("script-event"))
+       add_script (inf.grob (), ev, note_ev);
+      else if (ev->in_event_class ("string-number-event"))
+       add_string (inf.grob (), ev, note_ev);
+      else if (ev->in_event_class ("harmonic-event"))
        {
          inf.grob ()->set_property ("style", ly_symbol2scm ("harmonic"));
          Grob *d = unsmob_grob (inf.grob ()->get_object ("dot"));
@@ -108,8 +108,8 @@ New_fingering_engraver::acknowledge_stem (Grob_info inf)
 
 void
 New_fingering_engraver::add_script (Grob *head,
-                                   Music *event,
-                                   Music *note)
+                                   Stream_event *event,
+                                   Stream_event *note)
 {
   (void) note;
 
@@ -129,8 +129,8 @@ New_fingering_engraver::add_script (Grob *head,
 
 void
 New_fingering_engraver::add_fingering (Grob *head,
-                                      Music *event,
-                                      Music *hevent)
+                                      Stream_event *event,
+                                      Stream_event *hevent)
 {
   Finger_tuple ft;
 
@@ -166,8 +166,8 @@ New_fingering_engraver::add_fingering (Grob *head,
 
 void
 New_fingering_engraver::add_string (Grob *head,
-                                   Music *event,
-                                   Music *hevent)
+                                   Stream_event *event,
+                                   Stream_event *hevent)
 {
   Finger_tuple ft;
 
index 93fb8feb4d620bc9946830809d2e70cf39ff1b44..1d2f32418a2aac5b6da0dcf9513082c80f4acaf1 100644 (file)
@@ -14,6 +14,7 @@ using namespace std;
 #include "duration.hh"
 #include "item.hh"
 #include "output-def.hh"
+#include "pitch.hh"
 #include "rhythmic-head.hh"
 #include "staff-symbol-referencer.hh"
 #include "stream-event.hh"
index 1222654dab57ff445f795d7b072017acc2f59176..32253cb2bc3157d817991e93e9392b6485e0fd26 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "engraver.hh"
 #include "item.hh"
+#include "pitch.hh"
 #include "stream-event.hh"
 
 #include "translator.icc"
index 8a39546b41c32c2e4062c54bceedb1211eccd8ac..4aecc396067c9524a73767261d5bf9cdc0150909 100644 (file)
@@ -10,7 +10,6 @@
 #include "audio-item.hh"
 #include "audio-column.hh"
 #include "global-context.hh"
-#include "music.hh"
 #include "stream-event.hh"
 #include "warn.hh"
 
@@ -54,17 +53,17 @@ Note_performer::process_music ()
          if (Pitch *pitp = unsmob_pitch (pit))
            {
               SCM articulations = n->get_property ("articulations");
-              Music *tie_event = 0;
+              Stream_event *tie_event = 0;
               for (SCM s = articulations;
                    !tie_event && scm_is_pair (s);
                    s = scm_cdr (s))
                 {
-                  Music *m = unsmob_music (scm_car (s));
-                  if (!m)
+                  Stream_event *ev = unsmob_stream_event (scm_car (s));
+                  if (!ev)
                     continue;
          
-                  if (m->is_mus_type ("tie-event"))
-                    tie_event = m;
+                  if (ev->in_event_class ("tie-event"))
+                    tie_event = ev;
                 }
 
              Audio_note *p = new Audio_note (*pitp, get_event_length (n), 
index 01ea191cb34360b173330480b3668b62a6b2cbde..53d332427eeccfdfa33bf2e4ca238a35a5fb6fab 100644 (file)
@@ -9,12 +9,12 @@
 
 #include "engraver.hh"
 
-#include "warn.hh"
-#include "simple-closure.hh"
-#include "music.hh"
 #include "grob.hh"
 #include "item.hh"
 #include "pointer-group-interface.hh"
+#include "simple-closure.hh"
+#include "stream-event.hh"
+#include "warn.hh"
 
 #include "translator.icc"
 
@@ -33,9 +33,9 @@ Parenthesis_engraver::Parenthesis_engraver()
 void
 Parenthesis_engraver::acknowledge_grob (Grob_info info)
 {
-  if (Music *music = info.music_cause ())
+  if (Stream_event *ev = info.event_cause ())
     {
-      if (to_boolean (music->get_property ("parenthesize")))
+      if (to_boolean (ev->get_property ("parenthesize")))
        {
          if (Item *victim = dynamic_cast<Item*> (info.grob ()))
            {
index d1bd10cc518902d7bed96cc2be03268abb298734..284f7616c7226befc52faa368370c0bb515c7cd0 100644 (file)
@@ -38,7 +38,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Part_combine_engraver, part_combine);
 void
 Part_combine_engraver::listen_part_combine (Stream_event *ev)
 {
-  event_ = ev;
+  ASSIGN_EVENT_ONCE (event_, ev);
 }
 
 Part_combine_engraver::Part_combine_engraver ()
index 99f36b2b74d5a9a82dee26b89bac08a5a556f2bd..2a85da80375a877b3d7fb4990c487cbc7b6fac4f 100644 (file)
 #include "music-sequence.hh"
 #include "warn.hh"
 
+typedef enum Outlet_type
+  {
+    CONTEXT_ONE, CONTEXT_TWO, CONTEXT_SHARED, CONTEXT_SOLO, CONTEXT_NULL, NUM_OUTLETS
+  };
+
+static const char *outlet_names_[NUM_OUTLETS] = 
+  {"one", "two", "shared", "solo", "null"};
+
 class Part_combine_iterator : public Music_iterator
 {
 public:
@@ -67,16 +75,13 @@ private:
   /*
     TODO: this is getting of hand...
   */
-  Context_handle one_;
-  Context_handle two_;
-  Context_handle null_;
-  Context_handle shared_;
-  Context_handle solo_;
+  Context_handle handles_[NUM_OUTLETS];
 
-  void substitute_both (Context *to1,
-                       Context *to2);
+  void substitute_both (Outlet_type to1,
+                       Outlet_type to2);
 
-  void kill_mmrest (Context *);
+  /* parameter is really Outlet_type */
+  void kill_mmrest (int in);
   void chords_together ();
   void solo1 ();
   void solo2 ();
@@ -92,11 +97,14 @@ Part_combine_iterator::do_quit ()
   if (second_iter_)
     second_iter_->quit ();
 
-  null_.set_context (0);
-  one_.set_context (0);
-  two_.set_context (0);
-  shared_.set_context (0);
-  solo_.set_context (0);
+  // Add listeners to all contexts except Devnull.
+  for (int i = 0; i < NUM_OUTLETS; i++)
+    {
+      Context *c = handles_[i].get_outlet ();
+      if (c->is_alias (ly_symbol2scm ("Voice")))
+       c->event_source ()->remove_listener (GET_LISTENER (set_busy), ly_symbol2scm ("music-event"));
+      handles_[i].set_context (0);
+    }
 }
 
 Part_combine_iterator::Part_combine_iterator ()
@@ -154,21 +162,21 @@ Part_combine_iterator::chords_together ()
       playing_state_ = TOGETHER;
       state_ = TOGETHER;
 
-      substitute_both (shared_.get_outlet (), shared_.get_outlet ());
+      substitute_both (CONTEXT_SHARED, CONTEXT_SHARED);
     }
 }
 
 void
-Part_combine_iterator::kill_mmrest (Context *tg)
+Part_combine_iterator::kill_mmrest (int in)
 {
-  static Music *mmrest;
+  static Stream_event *mmrest;
   if (!mmrest)
     {
-      mmrest = make_music_by_name (ly_symbol2scm ("MultiMeasureRestEvent"));
+      mmrest = new Stream_event (ly_symbol2scm ("multi-measure-rest-event"));
       mmrest->set_property ("duration", SCM_EOL);
     }
 
-  mmrest->send_to_context (tg);
+  handles_[in].get_outlet ()->event_source ()->broadcast (mmrest);
 }
 
 void
@@ -179,50 +187,42 @@ Part_combine_iterator::solo1 ()
   else
     {
       state_ = SOLO1;
-      substitute_both (solo_.get_outlet (),
-                      null_.get_outlet ());
+      substitute_both (CONTEXT_SOLO, CONTEXT_NULL);
 
-      kill_mmrest (two_.get_outlet ());
-      kill_mmrest (shared_.get_outlet ());
+      kill_mmrest (CONTEXT_TWO);
+      kill_mmrest (CONTEXT_SHARED);
 
       if (playing_state_ != SOLO1)
        {
-         static Music *event;
+         static Stream_event *event;
          if (!event)
-           event = make_music_by_name (ly_symbol2scm ("SoloOneEvent"));
+           event = new Stream_event (ly_symbol2scm ("solo1-event"));
 
-         event->send_to_context (first_iter_->get_outlet ());
+         first_iter_->get_outlet ()->event_source ()->broadcast (event);
        }
       playing_state_ = SOLO1;
     }
 }
 
 void
-Part_combine_iterator::substitute_both (Context *to1,
-                                       Context *to2)
+Part_combine_iterator::substitute_both (Outlet_type to1,
+                                       Outlet_type to2)
 {
-  Context *tos[] = {to1, to2};
+  Outlet_type tos[] = {to1, to2};
+
   Music_iterator *mis[] = {first_iter_, second_iter_};
-  Context_handle *hs[]
-    = {
-    &null_,
-    &one_, &two_,
-    &shared_, &solo_,
-    0
-  };
 
   for (int i = 0; i < 2; i++)
     {
-      for (int j = 0; hs[j]; j++)
-       if (hs[j]->get_outlet () != tos[i])
-         mis[i]->substitute_outlet (hs[j]->get_outlet (), tos[i]);
+      for (int j = 0; j < NUM_OUTLETS; j++)
+       if (j != tos[i])
+         mis[i]->substitute_outlet (handles_[j].get_outlet (), handles_[tos[i]].get_outlet ());
     }
 
-  for (int j = 0; hs[j]; j++)
+  for (int j = 0; j < NUM_OUTLETS; j++)
     {
-      Context *t = hs[j]->get_outlet ();
-      if (t != to1 && t != to2)
-       kill_mmrest (t);
+      if (j != to1 && j != to2)
+       kill_mmrest (j);
     }
 }
 
@@ -240,23 +240,24 @@ Part_combine_iterator::unisono (bool silent)
        in the 1st voice, so in that case, we use the second voice
        as a basis for events.
       */
-      Context *c1 = (last_playing_ == SOLO2) ? null_.get_outlet () : shared_.get_outlet ();
-      Context *c2 = (last_playing_ == SOLO2) ? shared_.get_outlet () : null_.get_outlet ();
+      Outlet_type c1 = (last_playing_ == SOLO2) ? CONTEXT_NULL : CONTEXT_SHARED;
+      Outlet_type c2 = (last_playing_ == SOLO2) ? CONTEXT_SHARED : CONTEXT_NULL;
       substitute_both (c1, c2);
       kill_mmrest ((last_playing_ == SOLO2)
-                  ? one_.get_outlet () : two_.get_outlet ());
-      kill_mmrest (shared_.get_outlet ());
+                  ? CONTEXT_ONE : CONTEXT_TWO);
+      kill_mmrest (CONTEXT_SHARED);
 
       if (playing_state_ != UNISONO
          && newstate == UNISONO)
        {
-         static Music *event;
+         static Stream_event *event;
          if (!event)
-           event = make_music_by_name (ly_symbol2scm ("UnisonoEvent"));
+           event = new Stream_event (ly_symbol2scm ("unisono-event"));
+
 
          Context *out = (last_playing_ == SOLO2 ? second_iter_ : first_iter_)
            ->get_outlet ();
-         event->send_to_context (out);
+         out->event_source ()->broadcast (event);
          playing_state_ = UNISONO;
        }
       state_ = newstate;
@@ -272,15 +273,15 @@ Part_combine_iterator::solo2 ()
     {
       state_ = SOLO2;
 
-      substitute_both (null_.get_outlet (), solo_.get_outlet ());
+      substitute_both (CONTEXT_NULL, CONTEXT_SOLO);
 
       if (playing_state_ != SOLO2)
        {
-         static Music *event;
+         static Stream_event *event;
          if (!event)
-           event = make_music_by_name (ly_symbol2scm ("SoloTwoEvent"));
+           event = new Stream_event (ly_symbol2scm ("solo2-event"));
 
-         event->send_to_context (second_iter_->get_outlet ());
+         second_iter_->get_outlet ()->event_source ()->broadcast (event);
          playing_state_ = SOLO2;
        }
     }
@@ -297,7 +298,7 @@ Part_combine_iterator::apart (bool silent)
   else
     {
       state_ = APART;
-      substitute_both (one_.get_outlet (), two_.get_outlet ());
+      substitute_both (CONTEXT_ONE, CONTEXT_TWO);
     }
 }
 
@@ -306,56 +307,27 @@ Part_combine_iterator::construct_children ()
 {
   start_moment_ = get_outlet ()->now_mom ();
   split_list_ = get_music ()->get_property ("split-list");
-  SCM lst = get_music ()->get_property ("elements");
-
-  SCM props = scm_list_n (/*
-                           used to have tweaks here.
-                         */
 
-                         SCM_UNDEFINED);
+  Context *c = get_outlet ();
 
-  Context *tr
-    = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"),
-                                         "shared", props);
-
-  shared_.set_context (tr);
-
-  /*
-    If we don't, we get a new staff for every Voice.
-  */
-  set_context (tr);
-
-  Context *solo_tr
-    = get_outlet ()->find_create_context (ly_symbol2scm ("Voice"),
-                                         "solo", props);
-
-  solo_.set_context (solo_tr);
-
-  Context *null
-    = get_outlet ()->find_create_context (ly_symbol2scm ("Devnull"),
-                                         "", SCM_EOL);
-
-  if (!null)
-    programming_error ("no Devnull found");
-
-  null_.set_context (null);
-
-  Context *one = tr->find_create_context (ly_symbol2scm ("Voice"),
-                                         "one", props);
-
-  one_.set_context (one);
+  for (int i = 0; i < NUM_OUTLETS; i++)
+    {
+      SCM type = (i == CONTEXT_NULL) ? ly_symbol2scm ("Devnull") : ly_symbol2scm ("Voice");
+      /* find context below c: otherwise we may create new staff for each voice */
+      c = c->find_create_context (type, outlet_names_[i], SCM_EOL);
+      handles_[i].set_context (c);
+      if (c->is_alias (ly_symbol2scm ("Voice")))
+       c->event_source ()->add_listener (GET_LISTENER (set_busy), ly_symbol2scm ("music-event"));
+    }
 
+  SCM lst = get_music ()->get_property ("elements");
+  Context *one = handles_[CONTEXT_ONE].get_outlet ();
   set_context (one);
   first_iter_ = unsmob_iterator (get_iterator (unsmob_music (scm_car (lst))));
-
-  Context *two = tr->find_create_context (ly_symbol2scm ("Voice"),
-                                         "two", props);
-  two_.set_context (two);
+  Context *two = handles_[CONTEXT_TWO].get_outlet ();
   set_context (two);
   second_iter_ = unsmob_iterator (get_iterator (unsmob_music (scm_cadr (lst))));
 
-  set_context (tr);
-
   char const *syms[]
     = {
     "Stem",
@@ -369,13 +341,6 @@ Part_combine_iterator::construct_children ()
     0
   };
 
-  // Add listeners to all contexts except Devnull.
-  Context *contexts[] = {one, two, solo_tr, tr, 0};
-  for (int i = 0; contexts[i]; i++)
-    {
-      contexts[i]->event_source ()->add_listener (GET_LISTENER (set_busy), ly_symbol2scm ("OldMusicEvent"));
-    }
-
   for (char const **p = syms; *p; p++)
     {
       SCM sym = ly_symbol2scm (*p);
@@ -395,11 +360,8 @@ Part_combine_iterator::set_busy (SCM se)
     return;
 
   Stream_event *e = unsmob_stream_event (se);
-  SCM mus = e->get_property ("music");
-  Music *m = unsmob_music (mus);
-  assert (m);
 
-  if (m->is_mus_type ("note-event") || m->is_mus_type ("cluster-note-event"))
+  if (e->in_event_class ("note-event") || e->in_event_class ("cluster-note-event"))
     busy_ = true;
 }
 
index a27eef826b9163f94168cec7e6ea92d630adc49e..57357cb55943d546e2824ad301009f80f31f1333 100644 (file)
@@ -78,26 +78,31 @@ Percent_repeat_engraver::listen_percent (Stream_event *ev)
       Moment body_length = get_event_length (ev);
       Moment meas_len (robust_scm2moment (get_property ("measureLength"),
                                          Moment (1)));
-
       if (meas_len == body_length)
-      {
-       repeat_sign_type_ = MEASURE;
-       start_mom_ = now_mom ();
-       stop_mom_ = now_mom () + body_length;
-       get_global_context ()->add_moment_to_process (stop_mom_);
-      }
+       {
+         repeat_sign_type_ = MEASURE;
+         start_mom_ = now_mom ();
+         stop_mom_ = now_mom () + body_length;
+         get_global_context ()->add_moment_to_process (stop_mom_);
+       }
       else if (Moment (2) * meas_len == body_length)
-      {
-       repeat_sign_type_ = DOUBLE_MEASURE;
-       start_mom_ = now_mom () + meas_len;
-       stop_mom_ = now_mom () + body_length; /* never used */
-       get_global_context ()->add_moment_to_process (start_mom_);
-      }
+       {
+         repeat_sign_type_ = DOUBLE_MEASURE;
+         start_mom_ = now_mom () + meas_len;
+         stop_mom_ = now_mom () + body_length; /* never used */
+         get_global_context ()->add_moment_to_process (start_mom_);
+       }
       else
-       return;
-
+       {
+         ev->origin ()->warning (_ ("Junking percent repeat event: Duration must be exactly one or two measures"));
+         return;
+       }
       percent_event_ = ev;
     }
+  else
+    /* print a warning: no assignment happens because
+       percent_event_ != 0 */
+    ASSIGN_EVENT_ONCE (percent_event_, ev);
 }
 
 void
index d9c6e3e03910d7560f2cb008c99b449f734691be..bb93668ca9606e270c756701021801d118b52289 100644 (file)
@@ -66,9 +66,9 @@ Phrasing_slur_engraver::listen_phrasing_slur (Stream_event *ev)
   */
   Direction d = to_dir (ev->get_property ("span-direction"));
   if (d == START)
-    events_[START] = ev;
+    ASSIGN_EVENT_ONCE (events_[START], ev);
   else if (d == STOP && !slurs_.empty ())
-    events_[STOP] = ev;
+    ASSIGN_EVENT_ONCE (events_[STOP], ev);
 }
 
 void
index 90844c6d24ef7ad396a5c00d68bac56efc8be705..c8a44bd4e402854cb567839cdbd3807e490c7e97 100644 (file)
@@ -225,26 +225,26 @@ Piano_pedal_engraver::acknowledge_note_column (Grob_info info)
 
 IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_engraver, sostenuto);
 void
-Piano_pedal_engraver::listen_sostenuto (Stream_event *r)
+Piano_pedal_engraver::listen_sostenuto (Stream_event *ev)
 {
-  Direction d = to_dir (r->get_property ("span-direction"));
-  info_list_[SOSTENUTO].event_drul_[d] = r;
+  Direction d = to_dir (ev->get_property ("span-direction"));
+  ASSIGN_EVENT_ONCE (info_list_[SOSTENUTO].event_drul_[d], ev);
 }
 
 IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_engraver, sustain);
 void
-Piano_pedal_engraver::listen_sustain (Stream_event *r)
+Piano_pedal_engraver::listen_sustain (Stream_event *ev)
 {
-  Direction d = to_dir (r->get_property ("span-direction"));
-  info_list_[SUSTAIN].event_drul_[d] = r;
+  Direction d = to_dir (ev->get_property ("span-direction"));
+  ASSIGN_EVENT_ONCE (info_list_[SUSTAIN].event_drul_[d], ev);
 }
 
 IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_engraver, una_corda);
 void
-Piano_pedal_engraver::listen_una_corda (Stream_event *r)
+Piano_pedal_engraver::listen_una_corda (Stream_event *ev)
 {
-  Direction d = to_dir (r->get_property ("span-direction"));
-  info_list_[UNA_CORDA].event_drul_[d] = r;
+  Direction d = to_dir (ev->get_property ("span-direction"));
+  ASSIGN_EVENT_ONCE (info_list_[UNA_CORDA].event_drul_[d], ev);
 }
 
 void
index b514dfd10158e553744f12fff41e64123db25e4d..5044552a529ad93fdc033b9929c987ed4d3e523d 100644 (file)
@@ -8,14 +8,15 @@
 
 #include "engraver.hh"
 
-#include "dots.hh"
-#include "pointer-group-interface.hh"
 #include "axis-group-interface.hh"
 #include "context.hh"
-#include "note-head.hh"
+#include "dots.hh"
 #include "item.hh"
-#include "side-position-interface.hh"
+#include "note-head.hh"
 #include "pitch.hh"
+#include "pointer-group-interface.hh"
+#include "side-position-interface.hh"
+#include "stream-event.hh"
 #include "warn.hh"
 
 class Pitched_trill_engraver : public Engraver
@@ -37,7 +38,7 @@ private:
 
   vector<Grob*> heads_;
 
-  void make_trill (Music *);
+  void make_trill (Stream_event *);
 };
 
 Pitched_trill_engraver::Pitched_trill_engraver ()
@@ -61,18 +62,18 @@ Pitched_trill_engraver::acknowledge_note_head (Grob_info info)
 void
 Pitched_trill_engraver::acknowledge_text_spanner (Grob_info info)
 {
-  Music *mus = info.music_cause ();
-  if (mus
-      && mus->is_mus_type ("trill-span-event")
-      && to_dir (mus->get_property ("span-direction")) == START
-      && unsmob_pitch (mus->get_property ("pitch")))
-    make_trill (mus);
+  Stream_event *ev = info.event_cause ();
+  if (ev
+      && ev->in_event_class ("trill-span-event")
+      && to_dir (ev->get_property ("span-direction")) == START
+      && unsmob_pitch (ev->get_property ("pitch")))
+    make_trill (ev);
 }
 
 void
-Pitched_trill_engraver::make_trill (Music *mus)
+Pitched_trill_engraver::make_trill (Stream_event *ev)
 {
-  SCM scm_pitch = mus->get_property ("pitch");
+  SCM scm_pitch = ev->get_property ("pitch");
   Pitch *p = unsmob_pitch (scm_pitch);
 
   SCM keysig = get_property ("localKeySignature");
@@ -90,7 +91,7 @@ Pitched_trill_engraver::make_trill (Music *mus)
       trill_head_ = 0;
     }
 
-  trill_head_ = make_item ("TrillPitchHead", mus->self_scm ());
+  trill_head_ = make_item ("TrillPitchHead", ev->self_scm ());
   SCM c0scm = get_property ("middleCPosition");
 
   int c0 = scm_is_number (c0scm) ? scm_to_int (c0scm) : 0;
@@ -99,14 +100,14 @@ Pitched_trill_engraver::make_trill (Music *mus)
                             scm_from_int (unsmob_pitch (scm_pitch)->steps ()
                                           + c0));
 
-  trill_group_ = make_item ("TrillPitchGroup", mus->self_scm ());
+  trill_group_ = make_item ("TrillPitchGroup", ev->self_scm ());
   trill_group_->set_parent (trill_head_, Y_AXIS);
 
   Axis_group_interface::add_element (trill_group_, trill_head_);
 
   if (print_acc)
     {
-      trill_accidental_ = make_item ("TrillPitchAccidental", mus->self_scm ());
+      trill_accidental_ = make_item ("TrillPitchAccidental", ev->self_scm ());
 
       // fixme: naming -> alterations
       trill_accidental_->set_property ("accidentals", scm_list_1 (scm_from_int (p->get_alteration ())));
index e230316d8fa88745d76349c6ef049d15e9713a6e..896ad6f694e6d2a4edbc48b70be9564bb986eb46 100644 (file)
@@ -4,10 +4,13 @@
   source file of the GNU LilyPond music typesetter
 
   (c) 2003--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+TODO: junk this file
 */
 
 #include "recording-group-engraver.hh"
 #include "context.hh"
+#include "music.hh"
 
 /*
   TODO: Junk this class, extract events directly instead. 
@@ -54,7 +57,7 @@ Recording_group_engraver::finalize ()
 bool
 Recording_group_engraver::try_music (Music *m)
 {
-  bool retval = Translator_group::try_music (m);
+  bool retval = true;//Translator_group::try_music (m);
 
   add_music (m->self_scm (), ly_bool2scm (retval));
   return retval;
index d7f7888c4a6ecdf7e2d0401b8be4af941caecd26..ac4c31bac4658673c9af16e3b9f0363ef969b783 100644 (file)
@@ -385,7 +385,7 @@ read_relocation_file (string filename)
       else if (command == "prependdir")
        prepend_env_path (variable.c_str (), value);
       else
-       error ( _f("Unknown relocation command %s", command));
+       error (_f ("Unknown relocation command %s", command));
     }
 
   fclose (f);
index c9e8c9c208a0c85c9e42cfe58b7094ed711cff0d..c793449dda3aac7e38c203bfc86d055be5776680 100644 (file)
@@ -47,7 +47,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Repeat_tie_engraver, repeat_tie);
 void
 Repeat_tie_engraver::listen_repeat_tie (Stream_event *ev)
 {
-  event_ = ev;
+  ASSIGN_EVENT_ONCE (event_, ev);
 }
 
 void
index b59acf73f4d5bda1dd6a0e3b9c715a0695ee6378..95a8d10126e2c5cd2296e5d774d59363b7337f0c 100644 (file)
@@ -11,6 +11,7 @@
 #include "dots.hh"
 #include "duration.hh"
 #include "item.hh"
+#include "pitch.hh"
 #include "rhythmic-head.hh"
 #include "staff-symbol-referencer.hh"
 #include "stream-event.hh"
index 18d5312311b01d2bb74dfa90e62a6b1c328161c5..37595526c55afe19b13429dcb27d7f91b0ee7106 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "bar-line.hh"
 #include "global-context.hh"
+#include "international.hh"
 #include "item.hh"
 #include "misc.hh"
 #include "percent-repeat-iterator.hh"
@@ -48,7 +49,9 @@ Slash_repeat_engraver::listen_percent (Stream_event *ev)
     = robust_scm2moment (get_property ("measureLength"), Moment (0));
   
   if (get_event_length (ev) < meas_length)
-    slash_ = ev;
+    ASSIGN_EVENT_ONCE (slash_, ev);
+  else
+    ev->origin ()->warning (_ ("Slash repeat doesn't fit in one measure, junking"));
 }
 
 void
index fb7a9e67c68ec86425e948ce949b0c1e72ccc9d7..3ee546c3bf16aa03ae49677dbc41743482f2c7e5 100644 (file)
@@ -63,9 +63,10 @@ Slur_engraver::listen_slur (Stream_event *ev)
 {
   Direction d = to_dir (ev->get_property ("span-direction"));
   if (d == START)
-    events_[START] = ev;
+    ASSIGN_EVENT_ONCE (events_[START], ev);
   else if (d == STOP)
-    events_[STOP] = ev;
+    ASSIGN_EVENT_ONCE (events_[STOP], ev);
+  else ev->origin ()->warning (_ ("Invalid direction of slur-event"));
 }
 
 void
index a77fb9b593447be82b633abe8063144950cb5fa0..914c672ccd59cd073cb546da1f082960a3ada0ee 100644 (file)
@@ -7,6 +7,7 @@
 */
 
 #include "engraver.hh"
+#include "moment.hh"
 #include "note-spacing.hh"
 #include "paper-column.hh"
 #include "pointer-group-interface.hh"
@@ -89,7 +90,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Spacing_engraver, spacing_section);
 void
 Spacing_engraver::listen_spacing_section (Stream_event *ev)
 {
-  start_section_ = ev;
+  ASSIGN_EVENT_ONCE (start_section_, ev);
 }
 
 void
index d4e57955fceb01b030fc7086cf034052dbe62696..242e06e46a7439be625778c02bc3feb0aa51d6e8 100644 (file)
@@ -57,7 +57,7 @@ Staff_symbol_engraver::listen_staff_span (Stream_event *ev)
 {
   Direction d = to_dir (ev->get_property ("span-direction"));
   if (d)
-    span_events_[d] = ev;
+    ASSIGN_EVENT_ONCE (span_events_[d], ev);
   else
     programming_error (_ ("staff-span event has no direction"));
 }
index 6a69aaa6493c605c2fd6df353742e9c0553c7424..6ca9368d8688def88f123241518690948e3222c5 100644 (file)
@@ -166,7 +166,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Stem_engraver, tremolo);
 void
 Stem_engraver::listen_tremolo (Stream_event *ev)
 {
-  tremolo_ev_ = ev;
+  ASSIGN_EVENT_ONCE (tremolo_ev_, ev);
 }
 
 ADD_ACKNOWLEDGER (Stem_engraver, rhythmic_head);
index ce337d5472a990b8e0b549527e5cb6bdfff31111..ea9365496187c371bbe721be6b72906b1b8586f2 100644 (file)
@@ -9,11 +9,17 @@
 #include "stream-event.hh"
 
 LY_DEFINE (ly_make_stream_event, "ly:make-stream-event",
-          1, 0, 0, (SCM proplist),
-          "Creates a stream event, with the given property list.\n" )
+          1, 1, 0, (SCM cl, SCM proplist),
+          "Creates a stream event of class @var{cl} with the given mutable property list.\n" )
 {
-  SCM_ASSERT_TYPE (scm_list_p (proplist), proplist, SCM_ARG1, __FUNCTION__, "association list");
-  Stream_event *e = new Stream_event (proplist);
+  SCM_ASSERT_TYPE (scm_is_symbol (cl), cl, SCM_ARG1, __FUNCTION__, "symbol");
+  if (proplist != SCM_UNDEFINED)
+    {
+      SCM_ASSERT_TYPE (scm_list_p (proplist), proplist, SCM_ARG2, __FUNCTION__, "association list");
+    }
+  else
+    proplist = SCM_EOL;
+  Stream_event *e = new Stream_event (cl, proplist);
   return e->unprotect ();
 }
 
@@ -28,3 +34,11 @@ LY_DEFINE (ly_event_property, "ly:event-property",
 
   return e->internal_get_property (sym);
 }
+
+LY_DEFINE (ly_event_set_property, "ly:event-set-property!",
+           3, 0, 0, (SCM ev, SCM sym, SCM val),
+           "Set property @var{sym} in event @var{ev} to @var{val}."){
+  Stream_event *sc = unsmob_stream_event (ev);
+  SCM_ASSERT_TYPE (sc, ev, SCM_ARG1, __FUNCTION__, "event");
+  return ly_prob_set_property_x (ev, sym, val);
+}
index 7a1118e65af459566227edd71d557ed1fa646ce1..ff736d88323809227888f6b74037107ec21827d1 100644 (file)
@@ -27,12 +27,6 @@ Stream_event::Stream_event (SCM event_class, SCM mutable_props)
   mutable_property_alist_ = mutable_props;
 }
 
-Stream_event::Stream_event (SCM property_alist)
-  : Prob (ly_symbol2scm ("Stream_event"), SCM_EOL)
-{
-  mutable_property_alist_ = property_alist;
-}
-
 Stream_event::Stream_event (SCM class_name, Input *origin)
   : Prob (ly_symbol2scm ("Stream_event"),
          scm_list_1 (scm_cons (ly_symbol2scm ("class"), class_name)))
index 1ddabdd6971a87d77f4647b7198b99076510d7ec..d30c2265c7da959f81b32e5f1183252eae19d03e 100644 (file)
@@ -14,8 +14,8 @@ using namespace std;
 #include "dots.hh"
 #include "duration.hh"
 #include "item.hh"
-#include "music.hh"
 #include "output-def.hh"
+#include "pitch.hh"
 #include "rhythmic-head.hh"
 #include "score-engraver.hh"
 #include "staff-symbol-referencer.hh"
@@ -81,10 +81,10 @@ Tab_note_heads_engraver::process_music ()
       for (SCM s = event->get_property ("articulations");
           !tabstring_event && scm_is_pair (s); s = scm_cdr (s))
        {
-         Music *art = unsmob_music (scm_car (s));
+         Stream_event *art = unsmob_stream_event (scm_car (s));
 
-         if (art->is_mus_type ("string-number-event"))
-           tabstring_event = art->to_event ();
+         if (art->in_event_class ("string-number-event"))
+           tabstring_event = art;
        }
 
       if (!tabstring_event && j < tabstring_events_.size ())
@@ -163,7 +163,7 @@ Tab_note_heads_engraver::stop_translation_timestep ()
 }
 
 ADD_TRANSLATOR (Tab_note_heads_engraver,
-               /* doc */ "Generate one or more tablature noteheads from Music of type NoteEvent.",
+               /* doc */ "Generate one or more tablature noteheads from event of type NoteEvent.",
                /* create */ "TabNoteHead Dots",
                /* accept */ "note-event string-number-event",
                /* read */ "middleCPosition stringTunings minimumFret tablatureFormat highStringOne stringOneTopmost",
index b7628c325c29fef4d5ec88aab8d164500a85278c..b10832f1b34d79abe3abfb0f512a0e341577ca2f 100644 (file)
@@ -48,7 +48,7 @@ void
 Text_spanner_engraver::listen_text_span (Stream_event *ev)
 {
   Direction d = to_dir (ev->get_property ("span-direction"));
-  event_drul_[d] = ev;
+  ASSIGN_EVENT_ONCE (event_drul_[d], ev);
 }
 
 void
@@ -137,7 +137,7 @@ Text_spanner_engraver::finalize ()
 
 ADD_ACKNOWLEDGER (Text_spanner_engraver, note_column);
 ADD_TRANSLATOR (Text_spanner_engraver,
-               /* doc */ "Create text spanner from a Music.",
+               /* doc */ "Create text spanner from an event.",
                /* create */ "TextSpanner",
                /* accept */ "text-span-event",
                /* read */ "",
index 9547d14025ae9e81c08f5f6cf8dc3444168ea594..1dfb42fa523236e2bd5266154c34a361d1f8ada7 100644 (file)
@@ -38,7 +38,7 @@ struct Head_event_tuple
   Moment end_moment_;
   SCM tie_definition_;
   Stream_event *tie_stream_event_;
-  Music *tie_event_;
+  Stream_event *tie_event_;
   
   Head_event_tuple ()
   {
@@ -88,7 +88,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Tie_engraver, tie);
 void
 Tie_engraver::listen_tie (Stream_event *ev)
 {
-  event_ = ev;
+  ASSIGN_EVENT_ONCE (event_, ev);
 }
 
 void
@@ -198,18 +198,18 @@ Tie_engraver::stop_translation_timestep ()
       
       SCM left_articulations = left_ev->get_property ("articulations");
 
-      Music *tie_event = 0;
+      Stream_event *tie_event = 0;
       Stream_event *tie_stream_event = event_;
       for (SCM s = left_articulations;
           !tie_event && !tie_stream_event && scm_is_pair (s);
           s = scm_cdr (s))
        {
-         Music *m = unsmob_music (scm_car (s));
-         if (!m)
+         Stream_event *ev = unsmob_stream_event (scm_car (s));
+         if (!ev)
            continue;
          
-         if (m->is_mus_type ("tie-event"))
-           tie_event = m;
+         if (ev->in_event_class ("tie-event"))
+           tie_event = ev;
        }
          
       if (left_ev && (tie_event || tie_stream_event))
index badd1b82e802da140b35901b97a953e4be1b2ecd..da3fda5ed5bbeb12cca478346fec0f5239662ceb 100644 (file)
@@ -51,8 +51,6 @@ Translator_group::connect_to_context (Context *c)
     }
   
   context_ = c;
-  c->event_source ()->add_listener (GET_LISTENER (eat_event),
-                                   ly_symbol2scm ("OldMusicEvent"));
   c->event_source ()->add_listener (GET_LISTENER (create_child_translator),
                                    ly_symbol2scm ("AnnounceNewContext"));
   for (SCM tr_list = simple_trans_list_; scm_is_pair (tr_list); tr_list = scm_cdr (tr_list))
@@ -70,8 +68,6 @@ Translator_group::disconnect_from_context ()
       Translator *tr = unsmob_translator (scm_car (tr_list));
       tr->disconnect_from_context (context_);
     }
-  context_->event_source ()->remove_listener (GET_LISTENER (eat_event),
-                                             ly_symbol2scm ("OldMusicEvent"));
   context_->event_source ()->remove_listener (GET_LISTENER (create_child_translator),
                                              ly_symbol2scm ("AnnounceNewContext"));
   context_ = 0;
@@ -83,33 +79,6 @@ Translator_group::finalize ()
 {
 }
 
-bool
-translator_accepts_any_of (Translator *tr, SCM ifaces)
-{
-  SCM ack_ifs = scm_assoc (ly_symbol2scm ("events-accepted"),
-                          tr->translator_description ());
-  ack_ifs = scm_cdr (ack_ifs);
-  for (SCM s = ifaces; scm_is_pair (s); s = scm_cdr (s))
-    if (scm_c_memq (scm_car (s), ack_ifs) != SCM_BOOL_F)
-      return true;
-  return false;
-}
-
-SCM
-find_accept_translators (SCM gravlist, SCM ifaces)
-{
-  SCM l = SCM_EOL;
-  for (SCM s = gravlist; scm_is_pair (s); s = scm_cdr (s))
-    {
-      Translator *tr = unsmob_translator (scm_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;
-}
-
 SCM
 filter_performers (SCM ell)
 {
@@ -221,56 +190,6 @@ Translator_group::create_child_translator (SCM sev)
                            DOWN);
 }
 
-IMPLEMENT_LISTENER (Translator_group, eat_event);
-void
-Translator_group::eat_event (SCM sev)
-{
-  Stream_event *ev = unsmob_stream_event (sev);
-  SCM sm = ev->get_property ("music");
-  Music *m = unsmob_music (sm);
-  try_music (m);
-}
-
-bool
-Translator_group::try_music (Music *m)
-{
-  SCM name = scm_sloppy_assq (ly_symbol2scm ("name"),
-                             m->get_property_alist (false));
-
-  if (!scm_is_pair (name))
-    return false;
-
-  name = scm_cdr (name);
-  SCM accept_list = scm_hashq_ref (accept_hash_table_, name, SCM_UNDEFINED);
-  if (accept_list == SCM_BOOL_F)
-    {
-      accept_list = find_accept_translators (get_simple_trans_list (),
-                                            m->get_property ("types"));
-      scm_hashq_set_x (accept_hash_table_, name, accept_list);
-    }
-
-  for (SCM p = accept_list; scm_is_pair (p); p = scm_cdr (p))
-    {
-      Translator *t = unsmob_translator (scm_car (p));
-      if (t && t->try_music (m))
-       return true;
-    }
-    
-  // We couldn't swallow the event in this context. Try parent.
-  Context *p = context ()->get_parent_context ();
-  // Global context's translator group is a dummy, so don't try it.
-  if (p->get_parent_context())
-    // ES todo: Make Translators listeners directly instead.
-    return p->implementation ()->try_music (m);
-  // 'junking event' warning is temporarily disabled during translator cleanup
-  /*
-  else
-    // We have tried all possible contexts. Give up.
-    m->origin ()->warning (_f ("junking event: `%s'", m->name ()));
-  */
-  return false;
-}
-
 SCM
 Translator_group::get_simple_trans_list ()
 {
@@ -328,12 +247,9 @@ recurse_over_translators (Context *c, Translator_method ptr, Translator_group_me
 Translator_group::Translator_group ()
 {
   simple_trans_list_ = SCM_EOL;
-  accept_hash_table_ = SCM_EOL;
   protected_events_ = SCM_EOL;
   context_ = 0;
   smobify_self ();
-
-  accept_hash_table_ = scm_c_make_hash_table (19);
 }
 
 void
@@ -410,7 +326,6 @@ Translator_group::mark_smob (SCM smob)
   Translator_group *me = (Translator_group *)SCM_CELL_WORD_1 (smob);
 
   me->derived_mark ();
-  scm_gc_mark (me->accept_hash_table_);
   scm_gc_mark (me->protected_events_);
   return me->simple_trans_list_;
 }
index ec2b0f64a485ee0a5e4af91218800d9e9fb74091..c9c8d874fb309721ce291938935872b839648a40 100644 (file)
@@ -52,12 +52,6 @@ Translator::Translator (Translator const &src)
   must_be_last_ = src.must_be_last_;
 }
 
-bool
-Translator::try_music (Music *)
-{
-  return false;
-}
-
 Moment
 Translator::now_mom () const
 {
@@ -94,12 +88,9 @@ Translator::stop_translation_timestep ()
 }
 
 /*
-  this function has 2 properties
-
-  - It is called before try_music ()
-
-  - It is called before any user information enters the translators.
-  (i.e. any \property or event is not processed yet.)
+  this function is called once each moment, before any user
+  information enters the translators.  (i.e. no \property or event has
+  been processed yet.)
 */
 void
 Translator::start_translation_timestep ()
@@ -293,16 +284,17 @@ internal_event_assignment (Stream_event **old_ev, Stream_event *new_ev, const ch
     {
       /* extract event class from function name */
       const char *prefix = "listen_";
-      assert (!strncmp (function, "listen_", strlen (prefix)));
-      function += strlen (prefix);
-      char ev_class[strlen (function) + 1];
-      strcpy (ev_class, function);
-      for (char *c = ev_class; *c; c++)
-       if (*c == '_')
-         *c = '-';
-
-      new_ev->origin ()->warning (_f ("Two simultaneous %s events, junking this one", ev_class));
-      (*old_ev)->origin ()->warning (_f ("Previous %s event here", ev_class));
+      string ev_class = function;
+      /* This assertion fails if EVENT_ASSIGNMENT was called outside a
+        translator listener. Don't do that. */
+      assert (0 == ev_class.find (prefix));
+
+      /* "listen_foo_bar" -> "foo-bar" */
+      ev_class.erase (0, strlen(prefix));
+      replace_all (ev_class, '_', '-');
+
+      new_ev->origin ()->warning (_f ("Two simultaneous %s events, junking this one", ev_class.c_str ()));
+      (*old_ev)->origin ()->warning (_f ("Previous %s event here", ev_class.c_str ()));
       return false;
     }
   else
index 54d3daa96b71eaac338d61630463343dbc515c86..8770ab9cefd97754ac420c82333103d92f433d92 100644 (file)
@@ -55,7 +55,7 @@ void
 Trill_spanner_engraver::listen_trill_span (Stream_event *ev)
 {
   Direction d = to_dir (ev->get_property ("span-direction"));
-  event_drul_[d] = ev;
+  ASSIGN_EVENT_ONCE (event_drul_[d], ev);
 }
 
 void
@@ -142,7 +142,7 @@ Trill_spanner_engraver::finalize ()
 
 ADD_ACKNOWLEDGER (Trill_spanner_engraver, note_column);
 ADD_TRANSLATOR (Trill_spanner_engraver,
-               /* doc */ "Create trill spanner from a Music.",
+               /* doc */ "Create trill spanner from an event.",
                /* create */ "TrillSpanner",
                /* accept */ "trill-span-event",
                /* read */ "",
index 3bd0948e4842de79af4ee1ce42b6d2d7f75a449f..7ac0e5332299b017abbdea99cfb5b962bfb01164 100644 (file)
@@ -6,12 +6,14 @@
   (c) 1998--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
-#include "tuplet-bracket.hh"
-#include "note-column.hh"
 #include "beam.hh"
 #include "engraver.hh"
+#include "international.hh"
+#include "note-column.hh"
 #include "spanner.hh"
 #include "stream-event.hh"
+#include "tuplet-bracket.hh"
+#include "warn.hh"
 
 #include "translator.icc"
 
@@ -61,11 +63,13 @@ Tuplet_engraver::listen_tuplet_span (Stream_event *ev)
       d.event_ = ev;
       tuplets_.push_back (d);
     }
-  if (dir == STOP && tuplets_.size ())
+  else if (dir == STOP && tuplets_.size ())
     {
       stopped_tuplets_.push_back (tuplets_.back ());
       tuplets_.pop_back ();
     }
+  else 
+    programming_error (_ ("invalid direction of tuplet-span-event"));
 }
 
 void
index 9843dce725513eb5ada5b86085cbd941f73a0250..a851c5a8ef2a4aa7eef369f66a1f4870abc8d1e8 100644 (file)
@@ -9,8 +9,8 @@
 
 #include "engraver.hh"
 
-#include "music.hh"
 #include "grob.hh"
+#include "stream-event.hh"
 #include "translator.icc"
 
 class Tweak_engraver : public Engraver
@@ -28,9 +28,9 @@ Tweak_engraver::Tweak_engraver()
 void
 Tweak_engraver::acknowledge_grob (Grob_info info)
 {
-  if (Music *music = info.music_cause ())
+  if (Stream_event *ev = info.event_cause ())
     {
-      for (SCM s = music->get_property ("tweaks");
+      for (SCM s = ev->get_property ("tweaks");
           scm_is_pair (s); s = scm_cdr (s))
        {
          info.grob ()->internal_set_property (scm_caar (s), scm_cdar (s));
@@ -40,7 +40,7 @@ Tweak_engraver::acknowledge_grob (Grob_info info)
 
 ADD_ACKNOWLEDGER (Tweak_engraver, grob);
 ADD_TRANSLATOR (Tweak_engraver,
-               /* doc */ "Read the @code{tweaks} property from the originating Music event, and set properties." ,
+               /* doc */ "Read the @code{tweaks} property from the originating event, and set properties." ,
                
                /* create */ "",
                /* accept */ "",
index 4050a388f7720f355228935005488cc6faa6ad7c..808fcf716c00c7d21d355a97ea664040655adcbc 100644 (file)
 (define-public (ly:make-event-class leaf)
  (hashq-ref ancestor-lookup leaf))
 
+(define-public (ly:in-event-class? ev cl)
+  "Does event @var{ev} belong to event class @var{cl}?"
+  (memq cl (ly:make-event-class (ly:event-property ev 'class))))
+
 ;; does this exist in guile already?
 (define (map-tree f t)
   (cond
    ((pair? e) (cons (simplify (car e))
                    (simplify (cdr e))))
    ((ly:stream-event? e)
-    (list 'unquote `(make-stream-event ,(simplify (Stream_event::dump e)))))
+    (list 'unquote (list 'make-stream-event (simplify (Stream_event::dump e)))))
    ((ly:music? e)
     (list 'unquote (music->make-music e)))
    ((ly:moment? e)
index bfed38e04d9aa202751169e2accfb7bcbd9427c7..b3855c34dbf0eb679a655547c0d4b6cab45f396c 100644 (file)
@@ -8,8 +8,7 @@
 ;; TODO: should link back into user manual.
 
 (define (mm-rest-child-list music)
-  "Check if we have R1*4-\\markup { .. }, and if applicable convert to
-a property set for MultiMeasureRestNumber."
+  "Generate events for multimeasure rests, to be used by the sequential-iterator"
   (let ((location (ly:music-property music 'origin))
        (duration (ly:music-property music 'duration)))
     (list (make-music 'BarCheck
index 998d05e836226e00d69e945c120560c0692d06a5..96a5c7ec27b2c7f1bab4268337b5a3127e3984e8 100644 (file)
@@ -60,9 +60,8 @@
 ;; Bass figures.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(define-public (format-bass-figure figure stream-event context)
-  (let* ((event (ly:event-property stream-event 'music-cause ))
-        (fig (ly:music-property event 'figure))
+(define-public (format-bass-figure figure event context)
+  (let* ((fig (ly:event-property event 'figure))
         (fig-markup (if (number? figure)
 
                         ;; this is not very elegant, but center-aligning all digits
                              (lambda (y) (make-translate-scaled-markup (cons -0.7 0) y))
                              identity)
 
-                         (if (eq? #t (ly:music-property event 'diminished))
+                         (if (eq? #t (ly:event-property event 'diminished))
                              (markup #:slashed-digit figure)
                              (markup #:number (number->string figure 10))))
                         #f
                         ))
-        (alt (ly:music-property event 'alteration))
+        (alt (ly:event-property event 'alteration))
         (alt-markup
          (if (number? alt)
              (markup
@@ -88,7 +87,7 @@
               (alteration->text-accidental-markup alt))
              
              #f))
-        (plus-markup (if (eq? #t (ly:music-property event 'augmented))
+        (plus-markup (if (eq? #t (ly:event-property event 'augmented))
                          (markup #:number "+")
                          #f))