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: Viktor Mastoridis
Subject: Re: Custom NoteNames doesn't work in 2.22
Date: Fri, 11 Nov 2022 14:24:00 +0000

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.
Exactly!
I didn't know about convert-ly as a way of converting multiple files through the terminal.
I used it only through Frescobaldy ( and I referred to it as update.ly in my original post:-)


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.
As I read  David's email, I quickly learned how to use convert-ly on a terminal and converted all my files, but the result was the same - no letters!

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:
Now, "markup->string" is really beyond my comprehension. I am a music class teacher and learn as much as 'need-to-know' in order to preserve sanity:-)

\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
   >>
 
Thank you!  This works.
 

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
 >>


Oh, this doesn't work on 2.22 and I am too scared to upgrade now before report writing kicks in. But I will keep it and try it out as soon as I upgrade.  

Thank you David for waking me up to convert-ly (terminal) and Jean for the "markup->string" solution. 

Viktor


reply via email to

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