lilypond-user
[Top][All Lists]
Advanced

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

Re: variables for numbers


From: Flaming Hakama by Elaine
Subject: Re: variables for numbers
Date: Fri, 11 May 2018 16:14:17 -0700


On Thu, May 10, 2018 at 3:01 PM, Thomas Morley <address@hidden> wrote:
2018-05-10 22:51 GMT+02:00 Flaming Hakama by Elaine <address@hidden>:
>
> On Tue, May 1, 2018 at 11:03 AM, <address@hidden> wrote:
>>
>> Send lilypond-user mailing list submissions to
>>         address@hidden
>
>
>
> I'm having difficulty understanding how to use a variable that stores a
> number, for use with a \raise command.
>
>
> I have numerous markup definitions similar to this one:
>
> sottoVoce = <>^\markup \raise #1.3 { \italic "sotto voce" }
> mezzoVoce = <>^\markup \raise #1.3 { \italic "mezzo voce" }
> { \sottoVoce a'1 \mezzoVoce c''1 }
>
> And I'd like to use a variable for the raise value, instead of repeating
> #1.3 for each definnition.
>
>
>
> Here are three MWE's of failed approaches.
>
> %  The common sense approach
> raiseDistance = #1.3
> sottoVoce = <>^\markup \raise \raiseDistance { \italic "sotto voce" }
> { \sottoVoce a'1 }
>
>
> %  Based on the line-width example on
> http://lilypond.org/doc/v2.19/Documentation/learning/organizing-pieces-with-variables
> %{
> myWidth = 60      % a number to pass to a \paper variable (the unit is
> millimeter)
> Depending on its contents, the variable can be used in different places. The
> following example \paper {
>        line-width = \myWidth
> }
> {
>         c1
> }
> %}
> raiseDistance = 1.3
> sottoVoce = <>^\markup \raise \raiseDistance { \italic "sotto voce" }
> { \sottoVoce a'1 }
>
>
>
> % Based on
> http://lilypond.org/doc/v2.19/Documentation/extending/lilypond-variables
> %{
>     twelve = 12
>     twentyFour = #(* 2 twelve)
> %}
> raiseDistance = 1.3
> sottoVoce = <>^\markup \raise #(raiseDistance) { \italic "sotto voce" }
> { \sottoVoce a'1 }
>
>
>
> Does anyone have either a suggestion for how to do this, or the appropriate
> place to RTFM?
>
> The examples on
> http://lilypond.org/doc/v2.19/Documentation/notation/substitution-function-examples
> all are of functions that consume a value.  There are no examples of using a
> variable that is a number.
>
>
>
> Thanks,
>
> David Elaine Alt

Markup expects the scheme-representation of arguments, i.e. prepend
the variable with #
A single static variable shouldn't be enclosed into ()
Otherwise the first element would be seen as the operator doing
something with the other elements.

raiseDistance = #1.3
\markup \raise #raiseDistance { \italic "sotto voce" }

Cheers,
  Harm


Thanks, this works well.  I was even able to add a bit of scheme to use a default value if the variable has not been defined yet.

defaultRaiseDistance = #1.3

#(if (not (defined? 'raiseDistance))
    (define raiseDistance defaultRaiseDistance)
)


I'm curious though, where in the docs would we expect someone to learn how to do this?

I'd be willing to update the documentation, but I'm not sure what page(s) we intend for this to be explained.


Thanks,

David Elaine Alt
415 . 341 .4954                                           "Confusion is highly underrated"
address@hidden
skype: flaming_hakama
Producer ~ Composer ~ Instrumentalist
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 


reply via email to

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