[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lilypond-user
Subject:    Re: substitution function variable name
From:       Jean Abou Samra <jean () abou-samra ! fr>
Date:       2023-01-28 17:38:47
Message-ID: bac655d9-837a-4343-ddc9-18acbfd6812a () abou-samra ! fr
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]

[Attachment #4 (text/plain)]

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


["OpenPGP_signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic