lilypond-devel
[Top][All Lists]
Advanced

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

Re: Additions in event-listener.ly (issue 152600043 by address@hidden)


From: thomasmorley65
Subject: Re: Additions in event-listener.ly (issue 152600043 by address@hidden)
Date: Sat, 25 Mar 2017 15:31:36 -0700

On 2017/03/25 10:34:02, pkx166h wrote:
Thanks to David (and Graham).

I understand David's comments but don't have the knowledge (or the
time) to make
the edits that are suggested here - at least from as I understand it
there would
need to be some kind of 'check/test' (if/then) construction in
format-note to
decide if it was \Voice or \DrumVoice.

At least that is my reading of the comments.

Oh well, it didn't hurt to try to resurrect someone's old patch. I'll
have to
set this back to patch-abandoned then.

Thank you again all the same.

Hi James,

sorry for the late reply.
Maybe below will do the trick (diff is against master):


diff --git a/ly/event-listener.ly b/ly/event-listener.ly
index 4627aaa..a062472 100644
--- a/ly/event-listener.ly
+++ b/ly/event-listener.ly
@@ -122,12 +122,18 @@ as an engraver for convenience."

 #(define (format-note engraver event)
    (let* ((origin (ly:input-file-line-char-column
-                   (ly:event-property event 'origin))))
+                   (ly:event-property event 'origin)))
+          (drum-type (ly:event-property event 'drum-type))
+          (pitch (ly:event-property event 'pitch)))
      (print-line engraver
-                 "note"
-                 ;; get a MIDI pitch value.
-                 (+ 60 (ly:pitch-semitones
-                        (ly:event-property event 'pitch)))
+                 (if (ly:pitch? pitch)
+                     "note"
+                     "type")
+                 (if (ly:pitch? pitch)
+                     ;; get a MIDI pitch value.
+                     (+ 60 (ly:pitch-semitones
+                            (ly:event-property event 'pitch)))
+                     drum-type)
                  (ly:duration->string
                   (ly:event-property event 'duration))
                  (format-moment (ly:duration-length
@@ -206,23 +212,30 @@ as an engraver for convenience."
 %%%% are notified about all notes and rests. We don't create any grobs
or
 %%%% change any settings.

+#(define event-listener-engraver
+  (make-engraver
+    (listeners
+     (tempo-change-event . format-tempo)
+     (rest-event . format-rest)
+     (note-event . format-note) ;; works for
+     (articulation-event . format-articulation)
+     (text-script-event . format-text)
+     (slur-event . format-slur)
+     (breathing-event . format-breathe)
+     (dynamic-event . format-dynamic)
+     (crescendo-event . format-cresc)
+     (decrescendo-event . format-decresc)
+     (text-span-event . format-textspan)
+     (glissando-event . format-glissando)
+     (tie-event . format-tie))))
+
 \layout {
   \context {
-  \Voice
-  \consists #(make-engraver
-              (listeners
-               (tempo-change-event . format-tempo)
-               (rest-event . format-rest)
-               (note-event . format-note)
-               (articulation-event . format-articulation)
-               (text-script-event . format-text)
-               (slur-event . format-slur)
-               (breathing-event . format-breathe)
-               (dynamic-event . format-dynamic)
-               (crescendo-event . format-cresc)
-               (decrescendo-event . format-decresc)
-               (text-span-event . format-textspan)
-               (glissando-event . format-glissando)
-               (tie-event . format-tie)))
+    \Voice
+    \consists #event-listener-engraver
+  }
+  \context {
+    \DrumVoice
+    \consists #event-listener-engraver
   }
 }


https://codereview.appspot.com/152600043/



reply via email to

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