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'
Asked
Active
Viewed 228 times
1 Answers
5
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.

PeterBjuhr
- 227
- 1
- 5
-
Thank you for your answer. However, it only works on the developmental version of LilyPond. – Jeff Hanson Jun 25 '15 at 05:18
-
Sorry about that! I have edited the example with the example from 2.18 instead. But actually the principle is the same, you write in your rhythm and write `$p` where the real pitch should go. – PeterBjuhr Jun 25 '15 at 07:30
-
How would you do the same thing but with a chord? – weux082690 Sep 14 '16 at 17:30