[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: |
Mon, 21 Nov 2022 19:07:22 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 |
Le 21/11/2022 à 13:43, Jean Faure a écrit :
Hi. The code below is a copy&paste, I do not quite understand what it
does. Can I modify it so that an image is chosen according to the
following note's duration? Like custom4.eps, custom8.eps?
customHead = {
\once \override NoteHead #'stencil = #ly:text-interface::print
\once \override NoteHead #'text =
\markup {
\general-align #Y #CENTER {
\epsfile #X #2 #"./custom.eps"
}
}
}
{ e'4 f' \customHead g'4 }
Yes, use a callback for that:
\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:duration-log (ly:event-property (event-cause
grob) 'duration))
;; whole note:
((0) #{ \markup \epsfile #X #2 "custom1.eps" #})
;; half note:
((1) #{ \markup \epsfile #X #3 "custom2.eps" #})
;; quarter note:
((2) #{ \markup \epsfile #X #4 "custom4.eps" #})
;; eighth note:
((3) #{ \markup \epsfile #X #5 "custom8.eps" #})
;; Add more here if necessary (keeping the "else" line
below).
(else ""))
#})
}
{
\customHead c'1
\customHead c'2
\customHead c'4
\customHead c'8
}
Have a look at these pages:
https://lilypond.org/doc/v2.22/Documentation/extending/callback-functions
https://extending-lilypond.readthedocs.io/en/latest/backend.html#understanding-callbacks
Best,
Jean
OpenPGP_signature
Description: OpenPGP digital signature
- Note head as a custom image chosen according to note duration, Jean Faure, 2022/11/21
- Re: Note head as a custom image chosen according to note duration,
Jean Abou Samra <=
- Re: Note head as a custom image chosen according to note duration, Valentin Petzel, 2022/11/21
- Re: Note head as a custom image chosen according to note duration, Aaron Hill, 2022/11/21
- Re: Note head as a custom image chosen according to note duration, Jean Abou Samra, 2022/11/21
- Re: Note head as a custom image chosen according to note duration, Aaron Hill, 2022/11/21
- Message not available
- Re: Note head as a custom image chosen according to note duration, Jean Abou Samra, 2022/11/24
- Re: Note head as a custom image chosen according to note duration, Jean Faure, 2022/11/30
- Re: Note head as a custom image chosen according to note duration, Jean Abou Samra, 2022/11/30
- Re: Note head as a custom image chosen according to note duration, Jean Faure, 2022/11/30
- Re: Note head as a custom image chosen according to note duration, Jean Abou Samra, 2022/11/30