On Tue, 26 Jun 2018 at 12:03, David Kastrup <d...@gnu.org> wrote: > Gianmaria Lari <gianmarial...@gmail.com> writes: > > > On Tue, 26 Jun 2018 at 10:47, David Kastrup <d...@gnu.org> wrote: > > > >> Gianmaria Lari <gianmarial...@gmail.com> writes: > >> > >> > For this I thought to write a substitution function etc. Something > like > >> > this (it doesn't compile): > >> > > >> > \version "2.19.81" > >> > myScore = > >> > #(define-void-function (music) (ly:music?) > >> > (let (myRests #{ \time 3/4 r4 r r #} ) (ticktock #{ \time 3/4 hihat > >> > bassdrum bassdrum #})) > >> > #{ > >> > \score { > >> > << > >> > \new Staff {\myRests $music} > >> > \new DrumStaff { \ticktock} > >> > >> > >> > \layout{} \midi{} } #}) > >> > > >> > music = {\time 3/4 a b c'} > >> > > >> > \myScore \music > >> > > >> > The "let" part is not correct. I don't know how to define variable > >> > containing lilypond code using let. > >> > >> How about copy&paste from working code then? > >> > >> The first argument of "let" is a list (parenthesized) of variable > >> bindings. Each binding has the form (var value) so in general let > >> _alyways_ starts (the exception being named let, but that's a different > >> beast) > >> > >> (let (( > >> > >> and you are missing the second paren. Copying or imitating _any_ > >> working let would have worked here. > >> > > > > My apologies David and thank you for your help. > > But I also wanted to know if the direction I have taken was correct or > > completely wrong.... > > Well, it's a void function you use here, not a scheme function. Once it > works, it will create a score and throw it away.
Oh, you're right! So here it is the code where I fixed the function issue. It compiles. \version "2.19.82" #(define myRests #{ \time 3/4 r4 r r #} ) #(define ticktock #{ \drummode {\time 3/4 hihat4 bassdrum bassdrum} #} ) myScore = #(define-scheme-function (music) (ly:music?) #{ \score { << \new Staff {\myRests $music } \new DrumStaff { \ticktock} >> \layout{} \midi{} } #}) music = {\time 3/4 a b c'} \myScore \music Now in the following example I tried to put myRests and ticktock inside myScore. Because I know I could, I tried using nested define. It works ok. \version "2.19.82" myScore = #(define-scheme-function (music) (ly:music?) (define myRests #{ \time 3/4 r4 r r #} ) (define ticktock #{ \drummode {\time 3/4 hihat4 bassdrum bassdrum} #} ) #{ \score { << \new Staff { $myRests $music } \new DrumStaff { $ticktock } >> \layout{} \midi{} } #}) music = {\time 3/4 a b c'} \myScore \music And finally with let. It works ok. \version "2.19.82" myScore = #(define-scheme-function (music) (ly:music?) (let ((myRests #{ \time 3/4 r4 r r #} ) (ticktock #{ \drummode {\time 3/4 hihat4 bassdrum bassdrum} #} )) #{ \score { << \new Staff { $myRests $music } \new DrumStaff { $ticktock } >> \layout{} \midi{} } #})) music = {\time 3/4 a b c'} \myScore \music I have to say I have not been able to make it working until few minutes ago. I was using let similarly to the nested define. I was closing the parenthese of let command.... like this: (define-scheme-function ..... (let ..... ) ( .... body of define ..... ) That way the scope of the variable defined with let was not available inside the body of define. Thank you for the help! Now I will try to generate myRests and ticktock automatically according time defined in $music. g.
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user