Le 11/04/2022 à 11:50, Henrik Frisk a écrit :
> Hi,
>
> I have not worked with scheme and lilypond for some years. I realize
> that this is more of a scheme question than Lilypond, but perhaps
> someone knows how to do this. I can generate four notes with the
> following:
>
> \version "2.18.0"
> \score {
> {
> $ (make-sequential-music
> (map (lambda (x)
> (make-music 'NoteEvent
> 'pitch
> (ly:make-pitch 0 x)
> 'duration
> (ly:make-duration 2)))
> (list 1 2 3 4)))
> }
> }
>
> However, if I would like to add a markup to each note to each note I
> fail. I would have guessed something like this would do it but it
> generates an (almost) empty staff:
>
> \version "2.18.0"
> \score {
> {
> $(make-sequential-music
> (map (lambda (x)
> (make-music 'NoteEvent
> 'pitch
> (ly:make-pitch 0 x)
> 'duration
> (ly:make-duration 2))
> (make-music 'MarkEvent
> 'label
> (markup
> #:line
> (#:override (cons (quote font-size) -3) "10"))))
> (list 1)))
> }
> }
A Scheme lambda returns the value of the last _expression_
inside. If there are other expressions before, they are
evaluated for their side effects, but the result is thrown
away. You want to combine both music events in a single
music expressions.
\version "2.22.2"
{
$(make-sequential-music
(map (lambda (x)
(make-sequential-music
(list
(make-music 'NoteEvent
'pitch
(ly:make-pitch 0 x)
'duration
(ly:make-duration 2))
(make-music 'MarkEvent
'label
(markup
#:line
(#:override (cons (quote font-size) -3)
"10"))))))
(list 1 2 3 4)))
}
Thanks Jean,
It was the (make-sequential-music) after the lambda _expression_ that I had missed, without it it doesn't help to combine the two music events in one list.
Very helpful!
/h