Le 19/06/2022 à 10:58, Stefan Thomas a écrit :
Dear community,
I would like to do something like the following, but automatically,
without typing all the music again:
allNotes= { c'8 g' e' g' d' g' f' g' c' g' e' g' }
someNotes = { c' d' c' }
In other words: I would like to filter out every 4th note of allNotes,
so that I could do in combination with changePitch (see
https://github.com/gilles-th/arranger.ly/blob/master/changePitch.ly)
the following:
patI = { c8 r r4 }
someNotes = { \cPI { \someNotes s } }
Thanks for Your help,
Stefan
I'd do
\version "2.22.2"
filterNth =
#(define-music-function (n music) (index? ly:music?)
(music-filter
(let ((i -1))
(lambda (m)
(set! i (1+ i))
(zero? (modulo i n))))
music)
music)
\filterNth 4 \relative { c'8 e g e c e g e d f g f d f g f }
Note that if you use this with \relative, it must be outside the
\relative body.
Best,
Jean