lilypond-user
[Top][All Lists]
Advanced

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

## Easy definition of music function

 From: Lukas-Fabian Moser Subject: Easy definition of music function Date: Fri, 27 Apr 2018 21:12:33 +0200 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

```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

```

reply via email to

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