Re: Obtain the number of notes and rests from "ly:music?" parameter passed to a function
Paolo Prete wrote > Hello, > in the snippet below how can I replace "4" (in the denominator of > "\times") with the number of notes+rests (including "s") in $notes ? > Thanks > > > createTuplet = #(define-music-function (parser location notes) > (ly:music?)#{ \times 2/4 $notes#}) > { \createTuplet {c' e' r g'}} Well, you could do like below, but I can't believe the output is what you want. \version "2.18.2" createTuplet = #(define-music-function (parser location notes) (ly:music?) #{ \times #(cons 2 (length (extract-named-music notes '(RestEvent SkipEvent NoteEvent $notes #}) { \createTuplet { c'4 e' r g' } \createTuplet { c'4 e' r} \createTuplet { c'4 e' r s4 } \createTuplet { c'4 e' r s16 s16 s16 s16 } } Cheers, Harm -- Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Obtain the number of notes and rests from "ly:music?" parameter passed to a function
Meanwhile, I found a solution for my question, for anyone who could be interested: createTuplet = #(define-music-function (parser location notes) (ly:music?)(let ((noteCount (length (extract-typed-music notes '(note-event event-chord rest-event skip-event ) #{ \times #(cons 2 noteCount) $notes#})) {\createTuplet {e' s g r}} Il Venerdì 2 Marzo 2018 18:33, Paolo Prete ha scritto: Hello, in the snippet below how can I replace "4" (in the denominator of "\times") with the number of notes+rests (including "s") in $notes ? Thanks createTuplet = #(define-music-function (parser location notes) (ly:music?)#{ \times 2/4 $notes#}) { \createTuplet {c' e' r g'}} ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user