lilypond-user
[Top][All Lists]
Advanced

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

Re: substitution for context


From: Carl Sorensen
Subject: Re: substitution for context
Date: Sat, 6 Mar 2010 12:32:12 -0700



On 3/6/10 9:11 AM, "Stefan Thomas" <address@hidden> wrote:

> Dear community,
> I wanted to create a substitution-function with Scheme, where one could freely
> choose the context.
> I don't know which kind of variable is necessesary for the context.

You have a couple of problems, including the name left for your left text.

I couldn't find a straightforward way to implement this with a simple
substituton function, so I ended up using a case statement:

spanTextLeft =
#(define-music-function (parser location ctx leftText) (symbol? string?)
(case ctx
     (('Voice)
       #{
          \override Voice.TextSpanner #'(bound-details left text) =
$leftText
       #})
     (('Staff)
       #{
          \override Staff.TextSpanner #'(bound-details left text) =
$leftText
       #})
     (('Score)
       #{
          \override Score.TextSpanner #'(bound-details left text) =
$leftText
       #})
     (else
       #{
          \override TextSpanner #'(bound-details left text) = $leftText
       #})))


\relative c' {
  \override TextSpanner #'(bound-details left text) = "hello"
  c4 \startTextSpan d4 d4 d4 d4 \stopTextSpan e4 e4 e4
  \spanTextLeft #'Voice "goodbye"
  f4 \startTextSpan f f f f f f f \stopTextSpan g
}


HTH,

Carl





reply via email to

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