lilypond-user
[Top][All Lists]
Advanced

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

Re: Custom NoteNames doesn't work in 2.22


From: Jean Abou Samra
Subject: Re: Custom NoteNames doesn't work in 2.22
Date: Fri, 11 Nov 2022 14:51:36 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1

Le 11/11/2022 à 14:28, David Kastrup a écrit :
   \override NoteName #'stencil = #ChimeNoteNames
This is the problematic line, and the error message should have
indicated as much.  This should be NoteName.stencil but you really
really really should figure out how to run convert-ly in the correct
manner on your files, or you'll be back asking for help on the list for
every single incompatible syntax change in future.



Viktor, I suspect what is happening is that you first upgraded
an old file to 2.20 without convert-ly, which didn't change
this syntax, then upgraded from 2.20 to 2.22, which didn't
change it either because the conversion rule is done when crossing
the version in which the change was done, namely version 2.17.6.

That said, while true that this syntax is deprecated, it still
works and replacing NoteName #'stencil with NoteName.stencil
does not make a difference in the output.

The problem appears to be that the NoteName text in 2.22 is
not a simple string but a combination of \concat, \line and
\simple that ends up printing the same thing. One can fix
the snippet by first extracting the string from that markup
before the alist lookup, using markup->string:

\version "2.22.0"
music =\relative c' { c4 d e f}
chimenames =
#`(
    ("c" . "C")
  ("d" . "D")
   ("e" . "E")
   ("f" . "F")
   )

  ChimeNoteNames =
#(lambda (grob)
   (let* ((default-name (markup->string (ly:grob-property grob 'text)))
          (new-name (assoc-get default-name chimenames)))
         (ly:grob-set-property! grob 'text new-name)
   (ly:text-interface::print grob)))

   \new StaffGroup
<<
\new Staff \music
 \new NoteNames \with {
  \override NoteName.stencil = #ChimeNoteNames
    }
      \music
  >>



Note that if the goal is to uppercase the note names, there
is also a simpler solution that works in recent versions,
thanks to the new string transformers facility:

\version "2.23.80"

#(define (ChimeNoteNames grob)
   (grob-interpret-markup
    grob
    #{
      \markup \with-string-transformer
                #(lambda (layout props str)
                   (string-upcase str))
              #(ly:grob-property grob 'text)
    #}))

music =\relative c' { <c d>4 dis e f}

\new StaffGroup <<
  \new Staff \music
  \new NoteNames \with {
    \override NoteName.stencil = #ChimeNoteNames
  }
  \music
>>


Best,
Jean

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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