Folks,

I sometimes enter music which consists of a lot of "patterns" where (relatively complicated) constructions of beams, tuplets etc. are used repeatedly with changing pitches. Of course I'd like to put those in a function.

For instance, in a Mozart symphony I have

  r16 \once \omit TupletBracket \tuplet 3/2 { c32([ e g] } c16) c-!

all over the place. So, I want do define a function \pat that takes

\pat c e g c

and creates just this pattern.

QUESTION: I am under the impression that, since I want to give only pitches to the function, I have to create the music in Scheme, and hence I do not know how to attach the various articulations etc. other than in Scheme. Hence, my function now reads:

pat = #(define-music-function
        (pa pb pc pd)
        (ly:pitch? ly:pitch? ly:pitch? ly:pitch?)
        #{
          r16
          \once \omit TupletBracket
          \tuplet 3/2 {
            #(make-music 'NoteEvent
               'duration (ly:make-duration 5)
               'pitch pa
               'articulations (list
                               (make-music 'SlurEvent 'span-direction -1)
                               (make-music 'BeamEvent 'span-direction -1)
                               )
               )
            #(make-music 'NoteEvent 'duration (ly:make-duration 5) 'pitch pb)             #(make-music 'NoteEvent 'duration (ly:make-duration 5) 'pitch pc                'articulations (list (make-music 'BeamEvent 'span-direction 1))
               )
          }
          #(make-music 'NoteEvent
             'duration (ly:make-duration 4)
             'pitch pd
             'articulations (list (make-music 'SlurEvent 'span-direction 1))
             )
          #(make-music 'NoteEvent
             'duration (ly:make-duration 4)
             'pitch pd
             'articulations (list
                             (make-music 'ArticulationEvent
                               'articulation-type "staccatissimo"
                               ))
             )
        #}
        )

Works like a charm, but I admit that I find the definition quite tedious (me being a non-Schemer, essentially), especially I think that I only realized part of -! in my articulation definition (the MIDI part being omitted).

What I really would like to have is something like:

pat = #(define-music-function
        (pa pb pc pd)
        (ly:pitch? ly:pitch? ly:pitch? ly:pitch?)
        #{
             r16 \once \omit TupletBracket \tuplet 3/2 { #pa 32([ #pb #pc] } #pd 16) #pd-!
        #}
        )

But of course this does not work since pitch #pa and 32([ do not glue together.


Is there some easy way to define the function I want? My present solution (see above) takes almost as much time to write and debug that I often wonder if I shouldn't just to copy and paste in frescobaldi and change pitches along the way ...


Best
Lukas


_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to