I’m working on a score that has a lot of arpeggios where the first note of the 6-note group of 16th notes is doubled as a dotted 4th note. Having a macro/function to turn e.g. the pattern "f16 c a f c f,” into “<< { f4. } \\ { f16 c a f c f, } >>”, or even more preferably “<< { f4. } \\ { f16([ c a f c f,)] } >>” would save me a lot of typing and trouble.

What I’ve been tinkering around with is something like:

GR = #(define-music-function (parser location p1 p2 p3 p4 p5 p6)
        (ly:music? ly:music? ly:music? ly:music? ly:music? ly:music?)
        #{
          <<
            {$p1}
            \\
            {$p1 $p2 $p3 $p4 $p5 $p6}
          >>
        #})

\GR f16 c a f c f,

Some spaces already help:

GR = #(define-music-function (parser location p1 p2 p3 p4 p5 p6)
        (ly:music? ly:music? ly:music? ly:music? ly:music? ly:music?)
        #{
          <<
            { $p1 }
            \\
            { $p1 $p2 $p3 $p4 $p5 $p6  }
          >>
        #})

works (at least in 2.19.82).

It's not quite as easy to add articulations, beams and so on. To do so, it's easier if you make the function expect not music but only pitches. (This is necessary anyway since you want p1 taken twice with different duration.)

This leads to:

GR = #(define-music-function (parser location p1 p2 p3 p4 p5 p6)
        (ly:pitch? ly:pitch? ly:pitch? ly:pitch? ly:pitch? ly:pitch?)
        #{
          <<
            $p1 4.
            \\
            { $p1 16[( $p2 $p3 $p4 $p5 $p6 ])  }
          >>
        #})

\GR f c a f c f,

Lukas

PS. I highly recommend using the current "unstable" version if possible; lots of people here on this list use this heavily on a day-to-day basis, enjoying lots of new features and never experiencing trouble. For instance, you may now omit the "parser" and "location" arguments.

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

Reply via email to