lilypond-user
[Top][All Lists]
Advanced

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

Re: substitution function variable name


From: Jean Abou Samra
Subject: Re: substitution function variable name
Date: Sat, 28 Jan 2023 18:38:47 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0

On 22/01/2023 18:31, Jean Abou Samra wrote:
> Le 22/01/2023 à 18:22, Darren Ng a écrit :
>> Thanks. The following works:
>>
>>    accOne =
>>    #(define-music-function
>>        (x        )
>>        (ly:pitch?)
>>      #{
>>        $x 8 $x 8
>>      #})
>>
>> My ultimate goal is a function which does the following
>>
>>    accTwo =
>>    #(define-music-function
>>        (x        )
>>        (ly:pitch?)
>>      #{
>>        $x 8             r8
>>        <($x+4) ($x+7)>8 r8
>>        ($x-5) 8         r8
>>        <($x+4) ($x+7)>8 r8
>>      #})
>>
>> E.g.
>>
>>    \accTwo c expands to { c8r8 <eg>8r8  g,8r8 <eg>8r8 }
>>    \accTwo f expands to { f8r8 <ac'>8r8 c8r8  <ac'>8r8 }
>>
>> What material should I read so that I'll be able to achieve this?
> 
> 
> Spoiler: you can do that with just
> 
> \version "2.24.0"
> 
> accTwo =
> #(define-music-function
>     (x        )
>     (ly:pitch?)
>   #{
>     $x 8
>     r8
>     <\transpose c e $x \transpose c g $x >8
>     r8
>     <\transpose c g, $x >8 r8
>     <\transpose c e $x \transpose c g $x >8
>     r8
>   #})
> 
> \accTwo c'


Not sure why I didn't think of this much simpler solution a week ago:

\version "2.24.0"

accTwo =
#(define-music-function (x) (ly:pitch?)
  #{ \transpose c $x { c8 r <e g> r g, r <e g> r } #})

\accTwo c'


Jean

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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