2016-04-25 0:48 GMT+02:00 David Kastrup <[email protected]>:
> Simon Albrecht <[email protected]> writes:
>
>> Hello everybody,
>>
>> I’ve built some music functions to handle a large, multi-section
>> piece, and ran into a strange problem, which I could boil down to the
>> attached example.
>> If the concat-part function is called on the \key expression multiple
>> times in parallel, the \key expressions are accumulated in a way I’ve
>> never seen before. Why would that be?
>
> Because you are not copying the expression and still using it multiple
> times.  A big no-no.  Consequently, \transpose works multiple times on
> the identical expression.
>
> If you use stuff multiple times, _copy_ it.  Because LilyPond will
> generally _change_ expressions it is working on.
>
> Multiple \transpose, multiple \relative, multiple other stuff: all that
> you want to avoid occuring on the identical expression several times.
>
>> \version "2.19.39"
>>
>> global.1 = { \key c \major }
>>
>> concat-part =
>> #(define-music-function (al) (list?)
>>    (make-sequential-music (map cdr al)))
>> buildPart =
>> #(define-music-function () ()
>>    #{
>>      \new Voice <<
>>        \concat-part \global
>>        { c'1 }
>>      >>
>>    #})
>>
>> \transpose c d <<
>>   \buildPart
>>   \buildPart
>>>>
>
> --
> David Kastrup



David was faster...
Same problem as sometimes with #/$-signs.

Cheers,
  Harm

P.S.
David did not provide an improved code. Maybe because searching it,
may teach more.
Though, we're on the user list, so I attach it for follow readers.
\version "2.19.40"

global.1 = { \key c \major }

concat-part =
#(define-music-function (al) (list?)
   (ly:music-deep-copy (make-sequential-music (map cdr al))))
   
buildPart =
#(define-music-function () ()
   #{
     \new Voice <<
       \concat-part \global
       { c'1 }
     >>
   #})

\transpose c d <<
  \buildPart
  \buildPart
>>

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

Reply via email to