lilypond-user
[Top][All Lists]
Advanced

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

Re: Note head as a custom image chosen according to note duration


From: Jean Abou Samra
Subject: Re: Note head as a custom image chosen according to note duration
Date: Wed, 30 Nov 2022 18:50:14 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0

Le 30/11/2022 à 16:50, Jean Faure a écrit :
Ah ok, thanks. Is there a way of keeping the original note heads, just superimpose them with a custom image?



Yes, try this:

\version "2.22.2"

customHead = {
  \once \override NoteHead.stencil =
    #(grob-transformer
      'stencil
      (lambda (grob original)
        (let* ((added-markup
                #{
                   \markup \general-align #Y #CENTER
                       #(case (ly:grob-property grob 'duration-log)
                          ;; whole note:
                          ((0) #{ \markup \epsfile #X #2 "custom1.eps" #})
                          ;; half note:
                          ((1) #{ \markup \epsfile #X #3 "custom2.eps" #})
                          ;; quarter note and shorter:
                          ((2) #{ \markup \epsfile #X #4 "custom4.eps" #}))
                #})
               (added-stencil (grob-interpret-markup grob added-markup)))
          (if (ly:stencil? original)
              (ly:stencil-add original added-stencil)
              added-stencil))))
}

{
  \customHead c'1
  \customHead c'2
  \customHead c'4
  \customHead c'8
}



Best,
(the other) Jean

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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