lilypond-user
[Top][All Lists]
Advanced

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

Re: Setting default arguments for music function?


From: Ahanu Banerjee
Subject: Re: Setting default arguments for music function?
Date: Tue, 31 Jan 2023 19:23:43 -0500

Is it possible to have one of the arguments rely on a property of another argument? 

In my example, I want the default value for "parenColor" to be the same as the color of the "parenItem":

\version "2.24"
\language "english" 
altParen = #(define-music-function
     (parenColor parenSize parenItem)
     ( (color? "black") (number? -4) ly:music?)
   #{
     \tweak Parentheses.font-size #parenSize \tweak Parentheses.color #parenColor \parenthesize #parenItem
   #})
{ c \altParen -\tweak color "green" \upbow }

Thanks,
-Ahanu

On Tue, Jan 31, 2023 at 7:10 PM Ahanu Banerjee <athecellist@gmail.com> wrote:
Thanks! I had no idea that that resource existed. 
Appreciate all your help.

-Ahanu

On Tue, Jan 31, 2023 at 7:08 PM Jean Abou Samra <jean@abou-samra.fr> wrote:
On 01/02/2023 01:04, Ahanu Banerjee wrote:
> Is it possible to specify default values for a function to use when arguments are missing? In the example below, I want the default font size to be -4 and the default color to be blue without having to specify it each time, but I also want the ability to change those values in rare cases.
>
> \version "2.24"
> \language "english" 
> altParen = #(define-music-function
>      (parenColor parenSize parenItem)
>      (color? number? ly:music?)
>    #{
>      \tweak Parentheses.font-size #parenSize \tweak Parentheses.color #parenColor \parenthesize #parenItem
>    #})
> { c \altParen "blue" #-4 \upbow }


Perhaps read this:

https://extending-lilypond.readthedocs.io/en/latest/extending/music.html#optional-arguments

Best,
Jean



reply via email to

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