David Kastrup <d...@gnu.org> writes: > Phil Holmes <m...@philholmes.net> 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 _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel