[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Generate music with scheme
From: |
Aaron Hill |
Subject: |
Re: Generate music with scheme |
Date: |
Mon, 11 Apr 2022 09:43:11 -0700 |
On 2022-04-11 9:10 am, Henrik Frisk wrote:
\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.
You could also use append-map which will concatenate the lists without
the inner call to make-sequential-music:
%%%%
{
$(make-sequential-music
(append-map
(lambda (x) (list
#{ $(ly:make-pitch 0 x) 4 #}
#{ \mark \markup \override #'(font-size . -3) 10 #} ))
(iota 4 1)))
}
%%%%
In fact, using list-splicing, you can eliminate the outer call to
make-sequential-music as well:
%%%%
{
$@(append-map
(lambda (x) (list
#{ $(ly:make-pitch 0 x) 4 #}
#{ \mark \markup \override #'(font-size . -3) 10 #} ))
(iota 4 1))
}
%%%%
Also note the above use of #{ #} to escape music syntax within scheme,
which can often be more abbreviated.
-- Aaron Hill