lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme function question


From: James Worlton
Subject: Re: Scheme function question
Date: Thu, 21 Nov 2013 10:13:10 -0600

On Thu, Nov 21, 2013 at 10:05 AM, David Kastrup <address@hidden> wrote:
> \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).

That is starting to make sense, after reading it a few times :) I've replaced #note with $note in both cases in the function and it works properly. Thanks!
 
I need to go back and re-read the part about the difference between # and $ in Scheme variables...

James Worlton

reply via email to

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