lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Broadcast articulations not in EventChord (issue 5528111)


From: dak
Subject: Re: Broadcast articulations not in EventChord (issue 5528111)
Date: Wed, 18 Jan 2012 11:40:58 +0000

Reviewers: MikeSol,

Message:
On 2012/01/17 17:42:38, MikeSol wrote:
I would advise not handling it this way - the function to_event is
supposed to
take music and return an event.  In this patch, it is taking music,
returning an
event, and maybe broadcasting music and/or sending it to a context.

I'd recommend creating a new iterator, rhythmic-music-iterator, that
inherits
from Simple_music_iterator.

I have reduced the impact on strange areas: it is now just
send_to_context and its caller report_event that take an optional
argument changing the behavior.

I don't see how a rhythmic-music-iterator would help here since the
rhythmic events need to get handled either way, whether they are called
inside of an EventChord or not.  The problem is that the _default_
behavior of articulations needs to be that they just get _removed_ from
events and broadcast in parallel.  Only inside of EventChord are they
allowed to stay associated with the individual event carrying them.

That's the way things work currently.  It is just that this unwrapping
and parallel broadcasting is currently wired into the parser, where
_everything_ gets wrapped in an EventChord (except when it isn't, like
inside of a chord), just in two different manners depending on whether
we are in-chord or not.

So if we are not wrapping non-chord notes in EventChord, this difference
needs to get established elsewhere if the input is to retain its
meaning.  And that means the default behavior needs to be unwrapping,
while EventChord refrains from it.

I don't see that a rhythmic-music-iterator would help since it gets to
play at a time when the distinction of EventChord-or-not must already
have had its effect.

Description:
Broadcast articulations not in EventChord
This is in preparation for issue 2070.
Should not cause any differences in output with current parser.

Please review this at http://codereview.appspot.com/5528111/

Affected files:
  M lily/event-chord-iterator.cc
  M lily/include/music-iterator.hh
  M lily/include/music.hh
  M lily/music-iterator.cc
  M lily/music.cc


Index: lily/event-chord-iterator.cc
diff --git a/lily/event-chord-iterator.cc b/lily/event-chord-iterator.cc
index 899287a99990036b4ccdf78a0c6638bd56254f40..015385a0559ddae265db490d3faec4141286b177 100644
--- a/lily/event-chord-iterator.cc
+++ b/lily/event-chord-iterator.cc
@@ -47,7 +47,7 @@ Event_chord_iterator::process (Moment m)
            scm_is_pair (s); s = scm_cdr (s))
         {
           Music *mus = unsmob_music (scm_car (s));
-          report_event (mus);
+          report_event (mus, true);
         }
       for (SCM s = get_music ()->get_property ("events");
            scm_is_pair (s); s = scm_cdr (s))
Index: lily/include/music-iterator.hh
diff --git a/lily/include/music-iterator.hh b/lily/include/music-iterator.hh
index a34e3009037120f66baeeda9104d27a753ffe43a..490b64380f61fd53476b2aed648035a1870288bf 100644
--- a/lily/include/music-iterator.hh
+++ b/lily/include/music-iterator.hh
@@ -72,7 +72,7 @@ public:
   Moment music_get_length () const;
   Moment music_start_mom () const;
   Music_iterator ();
-  void report_event (Music *);
+  void report_event (Music *, bool keep_articulations = false);
   Context *get_outlet () const;
   void set_context (Context *);
   static SCM get_static_get_iterator (Music *mus);
Index: lily/include/music.hh
diff --git a/lily/include/music.hh b/lily/include/music.hh
index 83cc5ff4c3148a4add8d1c7b165bc46a0bfe8829..e194b8fafbffcf66c3ecab0e536e6e96f4c944e1 100644
--- a/lily/include/music.hh
+++ b/lily/include/music.hh
@@ -55,7 +55,7 @@ public:
   void compress (Moment factor);

   // Broadcast the event in a context's event-source.
-  void send_to_context (Context *c);
+  void send_to_context (Context *c, bool keep_articulations = false);

   DECLARE_SCHEME_CALLBACK (duration_length_callback, (SCM));

Index: lily/music-iterator.cc
diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc
index c076b7ad65867e9e9b3cdb9266ae0748c1dd7586..ee6dcfa730d9a207f4964162135e650b9e478691 100644
--- a/lily/music-iterator.cc
+++ b/lily/music-iterator.cc
@@ -170,7 +170,7 @@ Music_iterator::descend_to_bottom_context ()
 }

 void
-Music_iterator::report_event (Music *m)
+Music_iterator::report_event (Music *m, bool keep_articulations)
 {
   descend_to_bottom_context ();

@@ -180,7 +180,7 @@ Music_iterator::report_event (Music *m)
   if (!m->is_mus_type ("event"))
     m->origin ()->programming_error ("Sending non-event to context");

-  m->send_to_context (get_outlet ());
+  m->send_to_context (get_outlet (), keep_articulations);
 }

 IMPLEMENT_CTOR_CALLBACK (Music_iterator);
Index: lily/music.cc
diff --git a/lily/music.cc b/lily/music.cc
index d8609ace96e2e6b56af077898edc1b0e7284a859..7aaae452a9d6af02814bacf11b96d7663b6d4b57 100644
--- a/lily/music.cc
+++ b/lily/music.cc
@@ -306,10 +306,23 @@ Music::to_event () const
 }

 void
-Music::send_to_context (Context *c)
+Music::send_to_context (Context *c, bool keep_articulations)
 {
   Stream_event *ev = to_event ();
-  c->event_source ()->broadcast (ev);
+  SCM p = ev->get_property ("articulations");
+  if (!keep_articulations && scm_is_pair (p))
+    {
+      ev->set_property ("articulations", SCM_EOL);
+      c->event_source ()->broadcast (ev);
+      for (; scm_is_pair (p); p = scm_cdr (p))
+       {
+         Stream_event *art = unsmob_stream_event (scm_car (p));
+         if (art)
+           c->event_source ()->broadcast (art);
+       }
+    }
+  else
+    c->event_source ()->broadcast (ev);
   ev->unprotect ();
 }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]