[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Composing music functions
From: |
Thomas Morley |
Subject: |
Re: Composing music functions |
Date: |
Sun, 12 Mar 2017 23:30:11 +0100 |
2017-03-12 22:46 GMT+01:00 Morten Lemvigh <address@hidden>:
> Hi,
>
> I'm trying to create some tools for setting choir pieces. I have run against
> a problem where I have a music function that needs the result of another
> music function. That other function uses a Lilypond code block, so it takes
> both parser and location. For reasons I don't understand, I cannot get this
> to work. Lilypond gives me a:
>
> Wrong type to apply: #<Music function #<procedure #f (music)>>
>
>
> I have tried to create a small toy example to show what I want to achieve:
>
> rest-around = #(define-music-function (parser location music ) (ly:music?)
> #{ r4 $music r4 #})
>
> restful-choir = #(define-music-function (parser location music) (ly:music?)
> (let ((rest-around (rest-around parser location music)))
> #{
> <<
> \new Voice { \voiceOne \transpose c g $rest-framed }
rest-framed is not defined see terminal-output:
error: GUILE signaled an error for the expression beginning here
\new Voice { \voiceOne \transpose c g $
rest-framed }
Unbound variable: rest-framed
> \new Voice { \voiceTwo $rest-framed }
> >>
> #}))
>
>
> music = { c' d' e' }
>
> \score {
> \new Staff { \restful-choir \music }
> }
>
> I have run into this problem a couple of times, the current problem I'm
> trying to solve is: I have a list of music an I am trying to map each item
> of the list with a function that creates a staff with the music. Afterwards
> they should be combined as 'SimultaneousMusic. I would like to use Lilypond
> code blocks where I think it is clearer than the Scheme counterpart.
>
> Is there something obvious I am doing wrong,
You did not post your lily-version ;)
> or am I perhaps completely off
> on this approach...?
>
> Best regards,
> Morten
This works for newer devel-versions:
\version "2.19.56"
rest-around = #(define-music-function (music ) (ly:music?)
#{ r4 $music r4 #})
restful-choir = #(define-music-function (music) (ly:music?)
(let ((rest-framed (rest-around music)))
#{
<<
\new Voice { \voiceOne \transpose c g $rest-framed }
\new Voice { \voiceTwo $rest-framed }
>>
#}))
music = { c' d' e' }
\score {
\new Staff { \restful-choir \music }
}
Cheers,
Harm