]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 456: Also check for laissez-vibrer events attached to single heads inside a chord
authorReinhold Kainhofer <reinhold@kainhofer.com>
Fri, 9 Sep 2011 15:30:18 +0000 (17:30 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 15 Sep 2011 10:25:59 +0000 (12:25 +0200)
input/regression/laissez-vibrer-chords.ly [new file with mode: 0644]
lily/laissez-vibrer-engraver.cc

diff --git a/input/regression/laissez-vibrer-chords.ly b/input/regression/laissez-vibrer-chords.ly
new file mode 100644 (file)
index 0000000..bd0bd45
--- /dev/null
@@ -0,0 +1,11 @@
+\version "2.15.12"
+
+\header {
+  texidoc = "
+@code{\laissezVibrer} ties should also work on individual notes of a chord.
+" }
+
+\relative c' {
+  <d-\laissezVibrer g>1
+  <d^\laissezVibrer g_\laissezVibrer>1
+}
index 307f5aa7e6700dc3847ca8157a3e2663381c50ca..d0eb46d13e4e209a831a5fd367307fa2cbdc8ac9 100644 (file)
@@ -63,16 +63,32 @@ Laissez_vibrer_engraver::listen_laissez_vibrer (Stream_event *ev)
 void
 Laissez_vibrer_engraver::acknowledge_note_head (Grob_info inf)
 {
-  if (!event_)
+  /* use the heard event_ for all note heads, or an individual event for just
+   * a single note head (attached as an articulation inside a chord) */
+  Stream_event *tie_ev = event_;
+  Grob *head = inf.grob ();
+  Stream_event *note_ev = unsmob_stream_event (head->get_property ("cause"));
+  if (!tie_ev && note_ev && note_ev->in_event_class ("note-event"))
+    {
+      SCM articulations = note_ev->get_property ("articulations");
+      for (SCM s = articulations; !tie_ev && scm_is_pair (s); s = scm_cdr (s))
+        {
+          Stream_event *ev = unsmob_stream_event (scm_car (s));
+          if (ev && ev->in_event_class ("laissez-vibrer-event"))
+            tie_ev = ev;
+        }
+    }
+
+  if (!tie_ev)
     return;
 
-  SCM cause = event_->self_scm ();
+  SCM cause = tie_ev->self_scm ();
 
   if (!lv_column_)
     lv_column_ = make_item ("LaissezVibrerTieColumn", cause);
 
   Grob *lv_tie = make_item ("LaissezVibrerTie", cause);
-  lv_tie->set_object ("note-head", inf.grob ()->self_scm ());
+  lv_tie->set_object ("note-head", head->self_scm ());
 
   Pointer_group_interface::add_grob (lv_column_, ly_symbol2scm ("ties"),
                                      lv_tie);