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 Faure
Subject: Re: Note head as a custom image chosen according to note duration
Date: Wed, 30 Nov 2022 16:34:58 +0100

Just for a test, I changed all image filenames to note4.eps. However, it turned out that the custom image is scaled differently depending on duration-log. Why?
I attach the lily, eps and output pdf files.

Cheers, Jean

On Thu, Nov 24, 2022 at 10:22 AM Jean Abou Samra <jean@abou-samra.fr> wrote:
Hello,

I'm adding back the list in copy, please always use "Reply to all"
to include the list so that everyone can participate.


Le 24/11/2022 à 00:06, Jean Faure a écrit :
Hi, thanks a lot for all the clarifications. However, I wasn't precise. I would indeed prefer that the choice of the EPS file be dependent only on the original note shape. Thus, duration-log would be much more convenient.

But I do not know how to apply Aaron's optimization. Could you help me once more and give me the code which ignores duration variations like dots, which do not affect the original note's shape?


You would use it like this:

\version "2.22.2"

customHead = {
  \once \override NoteHead.stencil = #ly:text-interface::print
  \once \override NoteHead.text =
    #(lambda (grob)
       #{
          \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" #}))
       #})
}

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



Note that my original suggestion also ignored dots. The difference
is that this one also treats quarter notes and shorter notes the
same (there is a note head full of ink with a stem in all those cases).

(Valentin: I use text-interface and \markup so it is obvious
how to make further transformation, like \with-color or such.)

Best,
Jean


Attachment: a.lily
Description: Binary data

Attachment: note4.eps
Description: image/eps

Attachment: a.pdf
Description: Adobe PDF document


reply via email to

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