lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme function question


From: David Kastrup
Subject: Re: Scheme function question
Date: Thu, 21 Nov 2013 17:05:01 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

James Worlton <address@hidden> writes:

> Hello all,
>
> I'm making my first forays into Scheme by adapting preexisting examples to
> do what I need.
>
>
> Question: Why does the following code produce the output as shown in the
> attached png image? I expect it to just output a scale with a
> double-stemmed g.
>
> \version "2.17.95"
>
> doubleStem =
> #(define-music-function
>   (parser location note)
>   (ly:music?)
>   #{
>     << { \voiceOne #note } \new Voice { \voiceTwo #note } >> \oneVoice
>   #})
>
> melody = \relative c' {
>   c4 d e f
>   \doubleStem g a b c
> }
>
> \score {
>   \new Staff \melody
> }

Ok, this one is a puzzler.  Its solution is that you wrote #note twice
in the same music without making a copy.  Either call music-clone on one
of the occurences of #note, or write $note (which does a copy anyway).

If you don't do that, \relative will work _twice_ on the identical note
while working through the music, shifting it up to g' first, and then
seeing g', and consequently shifting it to g'' (taking the first
occurence along).

> I can work around this by adding \absolute before #note in the
> function (and remembering to use absolute mode in the input), but it
> would be nice if the function would produce the correct output. What
> am I doing wrong?

\relative is icky in this situation anyway: if you use \doubleStem g',
you'll get a similar problem.  There is the make-relative macro, but it
only works on single pitches rather than whole music.  Maybe I need to
extend it.

-- 
David Kastrup




reply via email to

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