lilypond-user
[Top][All Lists]
Advanced

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

Re: scheme function returning two scores


From: Gianmaria Lari
Subject: Re: scheme function returning two scores
Date: Sun, 25 Feb 2018 22:54:48 +0100


On 25 February 2018 at 22:41, Caagr98 <address@hidden> wrote:


On 02/25/18 22:24, Gianmaria Lari wrote:
>
>
> On 25 February 2018 at 15:05, Caagr98 <address@hidden <mailto:address@hidden>> wrote:
>
>
>
>     On 02/25/18 14:50, David Kastrup wrote:
>     > In the mean time, you could define a void function and let it just call
>     > toplevel-score-handler on your scores.  Of course, this would no longer
>     > allow you to place those scores in a book or bookpart.
>
>     Why not call add-score (defined in scm/lily-library.scm) instead? It seems to add the score to the current book/bookpart.
>
>
> Dear Caagr98, if would be great if you can refer an example.
>
> Thanks a lot!
> Ciao, Gianmaria


\version "2.19.81"
addScore = #(define-void-function (score) (ly:score?) (add-score score))

myScore = #(define-void-function (music) (ly:music?) #{
  \addScore \score { $music \layout{} }
  \addScore \score { \unfoldRepeats $music \midi{}}
#} )

\bookpart {
  \myScore {\repeat percent 2 {c' d' e' f'}}
}
\bookpart {
  \myScore {\repeat percent 2 {g c' c' c'}}
}


The (add-score) function (and the \addScore function I defined up there for easier syntax) adds the given score to the closest enclosing \book or \bookpart.

I tried your code as it is. It generate only one score and two midi.
I modify it a bit in this way:

\version "2.19.81"
addScore = #(define-void-function (score) (ly:score?) (add-score score))

myScore = #(define-void-function (music) (ly:music?) #{
  \addScore \score { $music \layout{} }
  \addScore \score { \unfoldRepeats $music \midi{}}
#} )

\book {
  \myScore {\repeat percent 2 {c' d' e' f'}}
  \myScore {\repeat percent 2 {g c' c' c'}}
}

And this generates as expected two scores and two midis. Fantastic!

 
Keep in mind, though, that you can't do anything like this:

foo = \myScore c1
\book {
  \foo
}

That'll add the sheet and midi to the toplevel book and leave the second one empty.

I will not use this :)

Really thanks a lot!!!
Ciao, g.


reply via email to

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