Hello everybody,

personally I increasingly feel like I kind of need these inspirational posts about the power of LilyPond, so here’s one of my own: I love how with the attached library file [ly-utility.ily], \include-d in [standard-include.ily], I can just add the following short lines at the top of my input file:

%%%%%%%%%%%%
\include "standard-include.ily"

transposer = \transpose es as \etc
\addToplevelMusicFunctions transposer
%%%%%%%%%%%%

and all the subsequent music will be transposed without the need to insert anything into any \score {}.

Best,
Simon

PS: Anticipating the question: I think \addToplevelMusicFunctions is in this form or another a candidate for openlilylib, if not even for the main code base.

\version "2.19.53"

musicFunctionDummy = #(define-music-function (mus) (ly:music?) mus)

addToplevelMusicFunctions =
#(define-scheme-function (names) (symbol-list-or-symbol?)
   (let* ((name-list (if (list? names) names (list names)))
          (lookup-function (lambda (name) (let ((fn (ly:parser-lookup name)))
                                            (if (equal? fn '())
                                                musicFunctionDummy
                                                fn))))
          (fn-list (map lookup-function name-list)))
     (set! toplevel-music-functions (append fn-list toplevel-music-functions))))
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to