Including tweaks in a variable

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Including tweaks in a variable

Michael Stickles
This should be simple, but I just can't seem to get it to work.  I'm working on re-doing a lot of our church music, and use variables extensively to help make the .ly files more readable. There are a lot of places where one vocal part splits and we want the "secondary" notes to be smaller, resulting in code like this:

<f  \tweak font-size #-2  f,>1

What I want to do is replace the "tweak" section with a variable, like this:

smNote = \tweak font-size #-2

<f  \smNote  f,>1

But this results in errors:

error: unknown escaped string: `\smNote'
error: wrong type for argument 3.  Expecting symbol list or music, found #<Book>

(the "smNote" definition is at the end of the variables section, and the first line after the variables section is "\book {" )

Some online searching came up with a few suggestions, but none of them worked for me. Given that they worked for the original posters, I'd guess I implemented them incorrectly, but I can't figure out what I'm doing wrong. Ideas?


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Including tweaks in a variable

Jan-Peter Voigt
Hello Michael,

it works if you add \etc to the variable (in lily-dev 2.19.x IIRC):
smNote = \tweak font-size #-2 \etc
That way smNote becomes a music-function that takes the note as argument
and the tweak is applied.
If you are using 2.18 you have to create the function like this:
smNote = #(define-music-function (m)(ly:music?) #{ \tweak font-size #-2
#m #})

HTH
Jan-Peter

Am 01.03.2018 um 15:33 schrieb Michael Stickles:

> This should be simple, but I just can't seem to get it to work.  I'm
> working on re-doing a lot of our church music, and use variables
> extensively to help make the .ly files more readable. There are a lot
> of places where one vocal part splits and we want the "secondary"
> notes to be smaller, resulting in code like this:
>
> <f  \tweak font-size #-2  f,>1
>
> What I want to do is replace the "tweak" section with a variable, like
> this:
>
> smNote = \tweak font-size #-2
>
> <f  \smNote  f,>1
>
> But this results in errors:
>
> error: unknown escaped string: `\smNote'
> error: wrong type for argument 3.  Expecting symbol list or music,
> found #<Book>
>
> (the "smNote" definition is at the end of the variables section, and
> the first line after the variables section is "\book {" )
>
> Some online searching came up with a few suggestions, but none of them
> worked for me. Given that they worked for the original posters, I'd
> guess I implemented them incorrectly, but I can't figure out what I'm
> doing wrong. Ideas?
>
>
> _______________________________________________
> lilypond-user mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/lilypond-user


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Including tweaks in a variable

Michael Stickles
In reply to this post by Michael Stickles
Jan-Peter,

Thanks. That was the correct idea. It was driving me crazy at first because it still wouldn't work, until I dug through the documentation a bit more and found that 2.18 and 2.19 have slightly different syntax for the function arguments:

2.19
===
smNote = #(define-music-function
  (m)(ly:music?)
  #{
    \tweak font-size #-2 
#m
  #}
)


2.18
===
smNote = #(define-music-function
  (parser location m)(ly:music?)
  #{
    \tweak font-size #-2 
#m
  #}
)


After adding "parser location" to the start of the arguments section, it works perfectly. Thanks again!


From: "Jan-Peter Voigt" <[hidden email]>
Sent: Thursday, March 01, 2018 10:43 AM
To: [hidden email]
Subject: Re: Including tweaks in a variable


Hello Michael,

it works if you add \etc to the variable (in lily-dev 2.19.x IIRC):
smNote = \tweak font-size #-2 \etc
That way smNote becomes a music-function that takes the note as argument
and the tweak is applied.
If you are using 2.18 you have to create the function like this:
smNote = #(define-music-function (m)(ly:music?) #{ \tweak font-size #-2
#m #})

HTH
Jan-Peter

Am 01.03.2018 um 15:33 schrieb Michael Stickles:
> This should be simple, but I just can't seem to get it to work.  I'm
> working on re-doing a lot of our church music, and use variables
> extensively to help make the .ly files more readable. There are a lot
> of places where one vocal part splits and we want the "secondary"
> notes to be smaller, resulting in code like this:
>
> <f  \tweak font-size #-2  f,>1
>
> What I want to do is replace the "tweak" section with a variable, like
> this:
>
> smNote = \tweak font-size #-2
>
> <f  \smNote  f,>1
>
> But this results in errors:
>
> error: unknown escaped string: `\smNote'
> error: wrong type for argument 3.  Expecting symbol list or music,
> found #<Book>
>
> (the "smNote" definition is at the end of the variables section, and
> the first line after the variables section is "\book {" )
>
> Some online searching came up with a few suggestions, but none of them
> worked for me. Given that they worked for the original posters, I'd
> guess I implemented them incorrectly, but I can't figure out what I'm
> doing wrong. Ideas?
>
>
> _______________________________________________
> lilypond-user mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/lilypond-user


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Including tweaks in a variable

Simon Albrecht-2
On 01.03.2018 17:51, Michael Stickles wrote:
> It was driving me crazy at first because it still wouldn't work, until
> I dug through the documentation a bit more and found that 2.18 and
> 2.19 have a slightly different syntax for the function arguments:

Truly the fact that it’s difficult for power users to provide the proper
syntax for 2.18 shows how old that stable release is. We’re working on a
2.20 release, but until then you’re also pretty safe using 2.19.81 and
enjoying its multiple improvements.

Best, Simon

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: Including tweaks in a variable

David Kastrup
Simon Albrecht <[hidden email]> writes:

> On 01.03.2018 17:51, Michael Stickles wrote:
>> It was driving me crazy at first because it still wouldn't work,
>> until I dug through the documentation a bit more and found that 2.18
>> and 2.19 have a slightly different syntax for the
>> function arguments:
>
> Truly the fact that it’s difficult for power users to provide the
> proper syntax for 2.18 shows how old that stable release is.

It isn't that old but like with most stable releases so far, there are
few "catchy" syntactic changes (usually backwards-compatible) that one
gets used to very fast.  This is one.  The \etc is another one.

--
David Kastrup

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user