Reputation: 41
How can you write a Lilypond function that takes in a note and outputs a note with a rhythm? say: input: c' output: c'8 c'16 c'
Upvotes: 3
Views: 305
Reputation: 237
In the LilyPond documentation you can find this example:
rhythm =
#(define-music-function (parser location p) (ly:pitch?)
"Make the rhythm in Mars (the Planets) at the given pitch"
#{ \tuplet 3/2 { $p 8 $p $p } $p 4 $p $p 8 $p $p 4 #})
\new Staff {
\time 5/4
\rhythm c'
\rhythm c''
\rhythm g
}
Hopefully that can be adapted to do what you want! Replace the Mars rhythm with your own. And please note that a space is needed between the variable $p
and the durations.
Upvotes: 5