lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Composing music functions


From: caagr98
Subject: Re: Composing music functions
Date: Sun, 12 Mar 2017 22:53:58 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

You can't call music functions directly from Scheme code. You have to either wrap the call in #{ #} or use `ly:music-function-extract` to extract the procedure itself and call that.

(In general, `Wrong type to apply` means you're trying to call something that isn't a procedure.)

On 03/12/17 22:46, Morten Lemvigh wrote:
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 }
       \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, or am I perhaps completely
off on this approach...?

Best regards,
Morten



_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user




reply via email to

[Prev in Thread] Current Thread [Next in Thread]