|
From: | Jeremiah Reilly |
Subject: | Re: Function definition |
Date: | Sun, 20 Feb 2022 15:49:01 +0100 |
Le 20/02/2022 à 15:26, Jeremiah Reilly a écrit :
> I have a problem which I cannot figure out.
>
> Lilypond has a built-in function to engrave guitar fingerings in a score.
>
> The function works just fine, but is long and cumbersome to type, for
> example:
>
> \rightHandFinger #2 /(#2 = i = index finger)/
>
> which fingers the attached note with the index finger label 'i'.
>
> I was able to follow the manual and create a shorthand for this function:
>
> #(define RH rightHandFinger)
>
> which works just fine, as illustrated with the following code (see
> attached score):
>
> #(define RH rightHandFinger)
>
> \new Staff \with {
> instrumentName = "Example"
> }
>
> \relative c'
> {
> \clef "treble_8"
> \key f \major
> \set strokeFingerOrientations = #'(up)
> a4\RH #2 c\RH #3 d\RH #2 e\RH #3 \bar "|." |
> }
>
> The code "\RH #2" is still more than I want to type.
>
> I want to create a fingering-function for the index finger as follows:
>
> \RHi (and similarly for all the fingerings i, m, a, and p).
>
> Can this be done? Am I missing a concept here? I tried:
>
> #(define RHi rightHandFinger #2)
>
> but this did not work.
The LilyPond syntax for applying a command is
\command arg1 arg2
In Schemeland, it doesn't work this way: you call functions.
The syntax for a call is
(function arg1 arg2)
Note the parentheses around the _expression_. LilyPond's
music functions happen to be callable as Scheme functions
too, so you should do
#(define RHi (rightHandFinger 2))
or, probably simpler:
RHi = \rightHandFinger 2
So why doesn't "RH = \rightHandFinger" work? Because \rightHandFinger
alone isn't a complete value, it's a command that expects further
arguments after it. However, you can use the syntax \etc to "cut"
the argument list and get a new function. Thus,
RH = \rightHandFinger \etc
is (for usual purposes) equivalent to
#(define RH rightHandFinger)
Best,
Jean
[Prev in Thread] | Current Thread | [Next in Thread] |