]> git.donarmstrong.com Git - lilypond.git/blobdiff - ly/event-listener.ly
Run grand replace for 2015.
[lilypond.git] / ly / event-listener.ly
index f8d547ef7cbeb2106a5d014d465d80eec4314bab..9714e557e49f484cddc452de341009c17e95d117 100644 (file)
@@ -1,6 +1,6 @@
 %%%% This file is part of LilyPond, the GNU music typesetter.
 %%%%
 %%%% This file is part of LilyPond, the GNU music typesetter.
 %%%%
-%%%% Copyright (C) 2011 Graham Percival <graham@percival-music.ca>
+%%%% Copyright (C) 2011--2015 Graham Percival <graham@percival-music.ca>
 %%%%
 %%%% LilyPond is free software: you can redistribute it and/or modify
 %%%% it under the terms of the GNU General Public License as published by
 %%%%
 %%%% LilyPond is free software: you can redistribute it and/or modify
 %%%% it under the terms of the GNU General Public License as published by
 
 
 
 
 
 
-\version "2.15.0"
+\version "2.16.0"
 
 %%%% Helper functions
 
 
 %%%% Helper functions
 
-#(define (filename-from-staffname engraver)
+#(define (filename-from-staffname context)
    "Constructs a filename in the form
 @file{@var{original_filename}-@var{staff_instrument_name}.notes} if the
 staff has an instrument name.  If the staff has no instrument
 name, it uses "unnamed-staff" for that part of the filename."
    "Constructs a filename in the form
 @file{@var{original_filename}-@var{staff_instrument_name}.notes} if the
 staff has an instrument name.  If the staff has no instrument
 name, it uses "unnamed-staff" for that part of the filename."
-   (let* ((inst-name (ly:context-property
-                      (ly:translator-context engraver)
-                      'instrumentName)))
+   (let* ((inst-name (ly:context-property context 'instrumentName)))
      (string-concatenate (list
                           (substring (object->string (command-line))
                            ;; filename without .ly part
      (string-concatenate (list
                           (substring (object->string (command-line))
                            ;; filename without .ly part
@@ -68,7 +66,7 @@ program using the output of this function to interpret grace notes
 however they want (half duration, quarter duration?  before beat,
 after beat?  etc.)."
    (if
 however they want (half duration, quarter duration?  before beat,
 after beat?  etc.)."
    (if
-       (eq? 0 (ly:moment-grace-numerator moment))
+       (zero? (ly:moment-grace-numerator moment))
        (ly:format "~a" (format-moment moment))
        ;; grace notes have a negative numerator, so no "-" necessary
        (ly:format
        (ly:format "~a" (format-moment moment))
        ;; grace notes have a negative numerator, so no "-" necessary
        (ly:format
@@ -79,12 +77,11 @@ after beat?  etc.)."
                         (ly:moment-grace-numerator moment)
                         (ly:moment-grace-denominator moment))))))
 
                         (ly:moment-grace-numerator moment)
                         (ly:moment-grace-denominator moment))))))
 
-#(define (make-output-string-line engraver values)
+#(define (make-output-string-line context values)
    "Constructs a tab-separated string beginning with the
    "Constructs a tab-separated string beginning with the
-score time (derived from the engraver) and then adding all the
+score time (derived from the context) and then adding all the
 values.  The string ends with a newline."
 values.  The string ends with a newline."
-   (let* ((context (ly:translator-context engraver))
-          (moment (ly:context-current-moment context)))
+   (let* ((moment (ly:context-current-moment context)))
     (string-append
      (string-join
        (append
     (string-append
      (string-join
        (append
@@ -96,16 +93,19 @@ values.  The string ends with a newline."
      "\n")))
 
 
      "\n")))
 
 
-#(define (print-line engraver . values)
+#(define (print-line context . values)
    "Prints the list of values (plus the score time) to a file, and
    "Prints the list of values (plus the score time) to a file, and
-optionally outputs to the console as well."
-   (let* ((p (open-file (filename-from-staffname engraver) "a")))
+optionally outputs to the console as well.  context may be specified
+as an engraver for convenience."
+   (if (ly:translator? context)
+       (set! context (ly:translator-context context)))
+   (let* ((p (open-file (filename-from-staffname context) "a")))
      ;; for regtest comparison
     (if (defined? 'EVENT_LISTENER_CONSOLE_OUTPUT)
      (ly:progress
      ;; for regtest comparison
     (if (defined? 'EVENT_LISTENER_CONSOLE_OUTPUT)
      (ly:progress
-      (make-output-string-line engraver values)))
+      (make-output-string-line context values)))
     (display
     (display
-     (make-output-string-line engraver values)
+     (make-output-string-line context values)
      p)
     (close p)))
 
      p)
     (close p)))
 
@@ -151,6 +151,10 @@ optionally outputs to the console as well."
    (print-line engraver
                "breathe"))
 
    (print-line engraver
                "breathe"))
 
+#(define (format-glissando engraver event)
+   (print-line engraver
+               "gliss"))
+
 #(define (format-tie engraver event)
    (print-line engraver
                "tie"))
 #(define (format-tie engraver event)
    (print-line engraver
                "tie"))
@@ -188,8 +192,8 @@ optionally outputs to the console as well."
 #(define (format-textspan engraver event)
    (let* ((context (ly:translator-context engraver))
           (moment (ly:context-current-moment context))
 #(define (format-textspan engraver event)
    (let* ((context (ly:translator-context engraver))
           (moment (ly:context-current-moment context))
-          (spanner-props (ly:context-property context 'TextSpanner))
-          (details (chain-assoc-get 'bound-details spanner-props))
+          (spanner-props (ly:context-grob-definition context 'TextSpanner))
+          (details (assoc-get 'bound-details spanner-props))
           (left-props (assoc-get 'left details '()))
           (left-text (assoc-get 'text left-props '())))
      (print-line engraver
           (left-props (assoc-get 'left details '()))
           (left-text (assoc-get 'text left-props '())))
      (print-line engraver
@@ -205,21 +209,20 @@ optionally outputs to the console as well."
 \layout {
   \context {
   \Voice
 \layout {
   \context {
   \Voice
-  \consists #(list
-              (cons 'listeners
-                    (list
-                     (cons 'tempo-change-event format-tempo)
-                     (cons 'rest-event format-rest)
-                     (cons 'note-event format-note)
-                     (cons 'articulation-event format-articulation)
-                     (cons 'text-script-event format-text)
-                     (cons 'slur-event format-slur)
-                     (cons 'breathing-event format-breathe)
-                     (cons 'dynamic-event format-dynamic)
-                     (cons 'crescendo-event format-cresc)
-                     (cons 'decrescendo-event format-decresc)
-                     (cons 'text-span-event format-textspan)
-                     (cons 'tie-event format-tie)
-                     )))
+  \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)))
   }
 }
   }
 }