[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Generate music with scheme
From: |
Hans Aikema |
Subject: |
Re: Generate music with scheme |
Date: |
Mon, 11 Apr 2022 12:21:51 +0200 |
> On 11 Apr 2022, at 11:51, Henrik Frisk <frisk.h@gmail.com> wrote:
>
>
> 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)))
> }
> }
>
> /h
>
My gut feel (not a scheme expert, quickly reading scheme docs over lunch) is
lack of parentheses.
From what I understand lambda creates a procedure, its first argument is the
argument-list, the second argument the procedure body and if more arguments
follow the lambda will be immediately invoked with those as parameters and the
result of that invocation returned instead of the procedure itself.
So to get the lambda to return the procedure I expect that you need another
pair of parentheses around the two make-music expressions.