lilypond-user
[Top][All Lists]
Advanced

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

Re: filter the nth note


From: Gilles Thibault
Subject: Re: filter the nth note
Date: Mon, 04 Jul 2022 19:02:38 +0200
User-agent: Webmail Free/1.3.3

Le 2022-06-19 10:58, Stefan Thomas a écrit :
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,

"arranger.ly" provides a special function to play with the order of notes in a sequential music : tweak-notes-seq
(see page 25 of
   http://gillesth.free.fr/Lilypond/arranger-docs/arrangerDoc-en.pdf )
You just need here a little trick :

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.22.0"
\include "arranger.ly"

global = { \time 2/4 s2*8 }
#(init '(instru))

                %%%%%%%%%%%

allNotes= { c'8 g' e' g'
            d' g' f' g'
            c' g' e' g' }

#(define (note->skip note) ; the trick function for tweak-notes-seq
"Transforms any music to a single skip"
   (make-music 'SkipEvent))

someNotes = #(tweak-notes-seq `(1 ,(cons 4 note->skip))
                              allNotes)

patI = { c8 r r4 }
#(rm 'instru 1 (cp1 someNotes))  % cp1 = cp patI = \changePitch \patI

\new Staff { << \global \instru >> }

%% =>  { c' r8 r4
%%       d' r8 r4
%%       c' r8 r4 }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

explanation :
  (tweak-notes-seq '(1 4) allNotes) would make a sequential music,
     taking from allNotes the following notes :
       1st 4th 5th 8th 9th 12th...
  (tweak-notes-seq `(1 ,(cons 4 note->skip)) allNotes) do the same
     but note 4,8,12 etc are transformed into a skip
  a skip for changePitch means "skip the current pattern note and go
  to the next note (or here return to the beginning of the pattern)"

The number 4 is needed to let tweak-notes-seq knowing the length of the loop


--
Gilles (trying to make up for lost time)



reply via email to

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