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
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user


_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to