X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=ly%2Fevent-listener.ly;h=b7b8ca086acc2fa467c93390b5c6c79033062804;hb=0b544cfb7332615ef809b71b57ab656741311ae1;hp=20615e8c2ae48bc65fd9047ce927264fba313c69;hpb=9d1520b21710bd22872010ae9aa4c4899014e9d4;p=lilypond.git diff --git a/ly/event-listener.ly b/ly/event-listener.ly index 20615e8c2a..b7b8ca086a 100644 --- a/ly/event-listener.ly +++ b/ly/event-listener.ly @@ -1,6 +1,6 @@ %%%% This file is part of LilyPond, the GNU music typesetter. %%%% -%%%% Copyright (C) 2011--2012 Graham Percival +%%%% Copyright (C) 2011--2014 Graham Percival %%%% %%%% LilyPond is free software: you can redistribute it and/or modify %%%% it under the terms of the GNU General Public License as published by @@ -32,18 +32,16 @@ -\version "2.15.31" +\version "2.16.0" %%%% 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." - (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 @@ -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 - (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 @@ -79,12 +77,11 @@ after beat? etc.)." (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 -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." - (let* ((context (ly:translator-context engraver)) - (moment (ly:context-current-moment context))) + (let* ((moment (ly:context-current-moment context))) (string-append (string-join (append @@ -96,16 +93,19 @@ values. The string ends with a newline." "\n"))) -#(define (print-line engraver . values) +#(define (print-line context . values) "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 - (make-output-string-line engraver values))) + (make-output-string-line context values))) (display - (make-output-string-line engraver values) + (make-output-string-line context values) p) (close p))) @@ -151,6 +151,10 @@ optionally outputs to the console as well." (print-line engraver "breathe")) +#(define (format-glissando engraver event) + (print-line engraver + "gliss")) + #(define (format-tie engraver event) (print-line engraver "tie")) @@ -218,6 +222,7 @@ optionally outputs to the console as well." (crescendo-event . format-cresc) (decrescendo-event . format-decresc) (text-span-event . format-textspan) + (glissando-event . format-glissando) (tie-event . format-tie))) } }