]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fixes to Rhythmic-music-iterator
authorDavid Kastrup <dak@gnu.org>
Thu, 19 Jan 2012 17:58:38 +0000 (18:58 +0100)
committerDavid Kastrup <dak@gnu.org>
Wed, 25 Jan 2012 13:52:42 +0000 (14:52 +0100)
lily/include/lily-proto.hh
lily/include/rhythmic-music-iterator.hh
lily/rhythmic-music-iterator.cc
scm/define-music-types.scm

index a1b566ddfe531a69d9cc714a940dd723f2f15bae..9ecb1b44aaf377c089302ca7e870251f6ba25b60 100644 (file)
@@ -151,6 +151,7 @@ class Property_iterator;
 class Rational;
 class Relative_octave_music;
 class Repeated_music;
+class Rhythmic_music_iterator;
 class Scale;
 class Scheme_hash_table;
 class Scheme_engraver;
index 6c6b7c66155c3b045ce0f57aa83c08d4c8983599..f639a1c051bd375a7eccc7867d787207f0570437 100644 (file)
 #include "simple-music-iterator.hh"
 
 /*
-  Iterator for atomic music objects: events are generated at the
-  beginning and at the end of the music.
+  Iterator for rhythmic music events that are not enclosed by EventChord
 */
 class Rhythmic_music_iterator : public Simple_music_iterator
 {
 protected:
   DECLARE_CLASSNAME (Rhythmic_music_iterator);
-  //Moment last_processed_mom_;
 
 public:
   DECLARE_SCHEME_CALLBACK (constructor, ());
   Rhythmic_music_iterator ();
+  Rhythmic_music_iterator (Rhythmic_music_iterator const &);
+
+protected:
   virtual void process (Moment);
-  //virtual bool ok ()const;
-  //virtual Moment pending_moment ()const;
+  virtual void construct_children ();
 };
 
 #endif /* RHYTHMIC_MUSIC_ITERATOR_HH */
index b547653cd73a6e2751c4c43fd52a682921a83ffb..8d9e75ae723f4f2a70009d3616b9bbde13a0da3b 100644 (file)
 #include "warn.hh"
 
 Rhythmic_music_iterator::Rhythmic_music_iterator ()
-  : Simple_music_iterator ()
 {
-  last_processed_mom_ = -1;
+}
+
+void
+Rhythmic_music_iterator::construct_children ()
+{
+  Simple_music_iterator::construct_children ();
+  descend_to_bottom_context ();
 }
 
 void
@@ -41,14 +46,34 @@ Rhythmic_music_iterator::process (Moment m)
 
       descend_to_bottom_context ();
 
+      Context *c = get_outlet ();
       Stream_event *ev = get_music ()->to_event ();
       SCM arts = ev->get_property ("articulations");
-      Context *c = get_outlet ();
       
       if (scm_is_pair (arts))
        {
-         ev->set_property ("articulations", SCM_EOL);
+         // There is no point in broadcasting articulations like
+         // harmonic events that nobody listens to.  Those work
+         // exclusively as articulations.
+         SCM listened = SCM_EOL;
+         SCM unlistened = SCM_EOL;
+         for (; scm_is_pair (arts); arts = scm_cdr (arts))
+           {
+             if (scm_is_true
+                 (scm_call_2
+                  (ly_lily_module_constant ("any"),
+                   ly_lily_module_constant ("ly:is-listened-event-class"),
+                   scm_call_1
+                   (ly_lily_module_constant ("ly:make-event-class"),
+                    unsmob_stream_event (scm_car (arts))
+                    ->get_property ("class")))))
+               listened = scm_cons (scm_car (arts), listened);
+             else
+               unlistened = scm_cons (scm_car (arts), unlistened);
+           }
+         ev->set_property ("articulations", scm_reverse_x (unlistened, SCM_EOL));
          c->event_source ()->broadcast (ev);
+         arts = scm_reverse_x (listened, SCM_EOL);
          for (; scm_is_pair (arts); arts = scm_cdr (arts))
            c->event_source ()->broadcast (unsmob_stream_event (scm_car (arts)));
        }
index fc8c0a857b2c720f45237d4b3bf82630453d7668..7b60887bd698a8de035b0d73751fb1218c093d41 100644 (file)
@@ -133,6 +133,7 @@ Syntax: @var{note}@code{\\breathe}")
     (ClusterNoteEvent
      . ((description . "A note that is part of a cluster.")
        ;; not a note-event, to ensure that Note_heads_engraver doesn't eat it.
+       (iterator-ctor . ,ly:rhythmic-music-iterator::constructor)
        (types . (general-music cluster-note-event melodic-event
                  rhythmic-event event))
        ))
@@ -287,6 +288,7 @@ Syntax: @code{\\lyricsto} @var{voicename} @var{lyrics}")
     (LyricEvent
      . ((description . "A lyric syllable.  Must be entered in lyrics mode,
 i.e., @code{\\lyrics @{ twinkle4 twinkle4 @} }.")
+       (iterator-ctor . ,ly:rhythmic-music-iterator::constructor)
        (types . (general-music rhythmic-event lyric-event event))
        ))
 
@@ -528,6 +530,7 @@ Syntax: @code{\\simultaneous @{ @dots{} @}} or @code{<< @dots{} >>}")
 print anything.
 
 Syntax: @code{s4} for a skip equivalent to a quarter rest.")
+       (iterator-ctor . ,ly:rhythmic-music-iterator::constructor)
        (types . (general-music event rhythmic-event skip-event))
        ))