On 25 November 2017 at 10:00, Gianmaria Lari <gianmarial...@gmail.com>
wrote:
> On 24 November 2017 at 18:18, David Kastrup <d...@gnu.org> wrote:
>
>> Gianmaria Lari <gianmarial...@gmail.com> writes:
>>
>> > I'm trying to put the score functionality inside a function (consider
>> it a
>> > test). Here it is the code:
>> >
>> > \version "2.19.80"
>> > myScore =
>> > #(define (music) (ly:music?) #{
>> >   \score {
>> >     $music
>> >     \layout{}
>> >     \midi{}
>> >    } #} )
>> >
>> > \myScore {a b c'}
>> >
>> >
>> > The code correctly generate a score but it does not generate the midi
>> file.
>> > Why???
>>
>> There is a difference between define (which defines a pure Scheme
>> function or expression) and define-music-function (which defines
>> something taking arguments in LilyPond syntax and returning a music
>> expression) and your input is an interesting mashup where \myScore will
>> probably be left as *unspecified* after you define an argumentless
>> Scheme function named `music' that first calls ly:music? without
>> argument and then would return a score if the ly:music? call had not
>> already caused an error due to a missing argument.
>>
>> Now a score is not a music expression anyway, so you should rather
>> replace define with define-scheme-function here in order to avoid
>> errors: the resulting \myScore can then return arbitrary expressions
>> including whole scores.
>>
>> --
>> David Kastrup
>>
>
> David, I changed "define" in "define-music-function" and now it works
> perfectly, thank you David!
>
> I think this is something can be useful to others so I post the new
> working code:
>
> \version "2.19.80"
> myScore =
> #(define-scheme-function (music) (ly:music?) #{
>   \score {
>     $music
>     \layout{}
>     \midi{}
>    } #} )
>
> \myScore {a b c'}
>
>
David, we discussed these things few weeks ago and I have a new problem.
The previous function myScore was working well. But when I tried to make it
returning two scores (splitting the layout and midi) it stopped to work.
This is the code:

\version "2.19.80"
myScore =
#(define-scheme-function (music) (ly:music?) #{

  \score {
    $music
    \layout{}
  }

  \score {
     $music
     \midi{}
   }

#})

\myScore {a b c'}

and this is the error


error: syntax error, unexpected \score, expecting end of input

\score {


error: error in #{ ... #}


Any suggestion?
Thank you, Gianmaria
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to