lilypond-devel
[Top][All Lists]
Advanced

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

Re: Scheme question


From: David Kastrup
Subject: Re: Scheme question
Date: Mon, 13 Jun 2016 20:55:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

David Kastrup <address@hidden> writes:

> Phil Holmes <address@hidden> writes:
>
>> Can anyone explain why the f in the attached code is 2 octaves above where 
>> I would expect them?
>>
>> testy = #(define-music-function (note)
>>   (ly:music?)
>> #{
>>   \tag #'a { #note }
>>   \tag #'b { #note }
>> #})
>>
>> \score {
>> \keepWithTag #'a {
>>     \new Staff
>>     {
>>       \new Voice { \relative c'' { c d e \testy f } }
>>     }
>>   }
>> }
>
> Because you let it be shifted two times before selecting your tag?  Your
> music does not contain two _copies_ of note, but rather contains note
> _itself_ two times.  So \relative is applied to the same music two times
> in succession.
>
> Use #(music-clone note) or #(ly:music-deep-copy note) or $note for your
> two uses, and the note will get placed in two separate _copies_ of the
> original rather than using the note object itself in two places.

By the way: since \relative is applied before \keepWithTag, the result
will still likely suck when writing

    \relative c'' { c d e \testy f, c }

since in first iteration it expands to

    \relative c'' { c d e \tag #'a f, \tag #'b f, c }

namely

    \absolute { c'' d'' e'' \tag #'a f' \tag #'b f c }

so the subsequent c is still likely to be one octave lower than
expected.

So you probably want

testy = #(define-music-function (note)
  (ly:music?)
  (make-relative (note) note
#{
  \tag #'a { $note }
  \tag #'b { $note }
#}))

This uses just "note" as the expression affecting \relative, but places
two separate copies of the once-affected note in your tags.

Expressed differently: the whole concept of \relative sucks.

-- 
David Kastrup



reply via email to

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