John Doe <randy.josl...@gmail.com> writes:

> Hi, all,
>
> The Notation Reference section 1.1.2 says "Music inside a \transpose block
> is absolute unless a \relative is included in the block". I'm writing a
> function that uses \transpose to change a variable's pitch in a function.
>
> How can I check if the music entered was entered in a \relative block? Can
> I?
>
> Below is a minimal example showing the problem I'm having, along with a png
> (attached) demonstrating the output:
>
>     \version "2.19.82"
>     fall = #(define-music-function (input) (ly:music?)
>         #{ $input \transpose c g, $input #})
>               { \fall <e' b' e''>4 e2^"absolute"_"right"}
>     \relative { \fall <e' b' e>4e,2^"relative"_"wrong" }
>
> I hope this is clear enough—running low on sleep…

It's comparatively crappy but you can do

\version "2.19.82"
fall = #(define-music-function (input) (ly:music?)
    (make-relative (input) input #{ $input \transpose c g, $input #}))
          { \fall <e' b' e''>4 e2^"absolute"_"right"}
\relative { \fall <e' b' e>4e,2^"relative"_"wrong" }

This uses really involved code to simulate something that does not
really map well to LilyPond's internals so it may interfere with other
tricky code.  Particularly code that tries analyzing LilyPond code.

-- 
David Kastrup

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to