Dear Kieren,

I’d like to share two approaches I’ve developed for such issues. There’s two caveats:

Firstly, I couldn’t take time to study your setup and how that makes these approaches viable or not—sorry for that.

Secondly, if possible, I always try to use vanilla LilyPond tools, so I prefer using tags as far as they may take me over using the editionEngraver and I prefer complicated \include setups with Scheme conditionals over using make. This is in an attempt to improve maintainability and reduce overhead.

On 27.01.24 23:03, Kieren MacMillan wrote:
I don’t believe quoted music can be transposed directly (i.e., you need to 
create a second, pre-transposed, quotation)

What I’ve started doing after running into this problem is for example

sop = { %{soprano music%} }
\addQuote "sop" \sop
\addQuote "sop8vb" \transpose c c, \sop

Recently I even put this into my standard include files to avoid having that third (or more) lines from the example:

addQuote =
#(define-void-function (name music) (string? ly:music?)
   (_i "Define @var{music} as a quotable music expression named
@var{name}, along with transposed versions @var{name8va} and
@var{name8vb}.")
   (add-quotable name music)
   (add-quotable (string-append name "8va")
                 #{ \transpose c c' $music #})
   (add-quotable (string-append name "8vb")
                 #{ \transpose c c, $music #}))

Another technique is this:

%%% from my library/ly-utility.ily file
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 '())
                                (begin
                                 (ly:warning "Cannot find music function
~a to add to toplevel functions.\n" name)
                                 musicFunctionDummy)
                                fn))))
          (fn-list (map lookup-function name-list)))
     (set! toplevel-music-functions
           (append fn-list toplevel-music-functions))))
%%%

Example usage:

%%%
transposer = \transpose g f \etc
enharmonicsChooser = \keepWithTag #'originalSpelling \etc
\addToplevelMusicFunctions transposer,enharmonicsChooser
%%%

All the best for your projects!
Simon

Reply via email to