lilypond-user
[Top][All Lists]
Advanced

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

Re: extending event-listener.ly


From: Phil Hézaine
Subject: Re: extending event-listener.ly
Date: Mon, 25 Mar 2013 22:05:28 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4

Le 25/03/2013 17:29, Graham Percival a écrit :
On Mon, Mar 25, 2013 at 08:58:09AM -0300, luis jure wrote:
i looked at event-listener.ly, but i'm afraid it's way over my head. i can
hardly manage some basic python, for me scheme is undecipherable.

could anyone give me a hint how to modify event-listener.ly to recognize
parenthesized notes?

Unfortunately you'll need some scheme knowledge, but if you can
get the general idea of the below function then you should be
fine:

#(define (format-note engraver event)
    (let* ((origin (ly:input-file-line-char-column
                    (ly:event-property event 'origin))))
      (print-line engraver
                  "note"
                  ;; get a MIDI pitch value.
                  (+ 60 (ly:pitch-semitones
                         (ly:event-property event 'pitch)))
                  (ly:duration->string
                   (ly:event-property event 'duration))
                  (format-moment (ly:duration-length
                                  (ly:event-property event
'duration)))
                  ;; point and click info
                  (ly:format "point-and-click ~a ~a"
                             (caddr origin)
                             (cadr origin)))))

The important bit is the (print-line ...) function.  It has a
number of arguments:
   - engraver
   - "note"
   - a MIDI pitch value
   - a duration (like "4.")
   - a duration (like "1.25")
   - point-and-click info

To add \parenthesize, you need to create a similar function or
extend that original one to deal with those events.  To see the
events, try:

\displayMusic { c'4 \parenthesize d' e }

oh, it looks like \parenthesize is an option to a note, rather
than a separate event:
...
         (make-music
           'NoteEvent
           'parenthesize
           #t
           'duration
           (ly:make-duration 2 0 1)
           'pitch
           (ly:make-pitch 0 1 0))
...


In that case, you need to add another argument to the
(print-line...) function to indicate whether the note is
parenthesized or not.  That requires a bunch more scheme, but this
should be enough hints for you to start reading the lilypond
scheme tutorial and the Extending manual.

A simple binary field would be enough for your personal use, but
it would be nice to have a more general approach in case people
want to add more options for notes.  Don't worry about this
general approach (required for accepted patches into mainstream
lilypond) right now; first just get the basics working for your
particular purpose.

- Graham


Hi,
Today, after the same discovery I was wondering the same question than Luis but for drum-types (in \drummode, ie: sna, wbl... ) N.R. says: "Not all lilypond music events are supported by ‘event-listener.ly’."
Is it possible to 'listen' the drums symbols?
Any hints will be appreciated.
Phil.



reply via email to

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