On Sep 19, 2013, at 11:03 AM, Urs Liska <u...@openlilylib.org> wrote:
> even=
> #(define-music-function (parser location music)(ly:music?)
>   #{
>     \once \override TupletNumber #'text = "even"
>     \times 4/4 { $music }
>   #})
> 
> \even { a8 g16 f }
> 
> Maybe it works ;-)

Thanks for the suggestion. That works great, and while I'd rarely use that one, 
this little shorthand I'll use constantly:

triplet = #(define-music-function (parser location music)(ly:music?)
        #{
                \tuplet 3/2 { $music }
        #})

\triplet { a8 b c }

However, I'd like to make a version that accepts an optional argument for the 
tuplet span duration, defaulting to 4, so I can do this for the most common 
case:

\triplet { a8 b c a b c a b c a b c }

but still be able to do this on occasion:

\triplet 2 { a4 b c a b c }

How do I do the default value properly? My guess doesn't quite work:

triplet = #(define-music-function (parser location tuplet-span 
music)((ly:duration? '4) ly:music?)
        #{
                \tuplet 3/2 $tuplet-span { $music }
        #})

I get this error:

example.ly:24:44: error: wrong type for argument 3.  Expecting music, found 4
        \evenly { a8 g16 f } g4 gf8 f r4 | 
                                           \triplet { a8 b c f g a }

Works fine when I include the optional argument:

 \triplet 4 { a8 b c f g a }

Thanks again,

Alec

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to