Dear all,

I was looking how to easily remove some notes at the beginning or at the
end of music.
Thanks to the wonderful \extractMusic script (thank you Gilles !), it can
be done with a few lines.

HTH,

Mathieu

%%%

\version "2.16.1"
\include "extractMusic.ly"  %% See  http://lsr.dsi.unimi.it/LSR/Item?id=542

removeStart = #(define-music-function (parser location music remove)
(ly:music? ly:music?)
"Remove, at the start of `music, a length equal to the one of `remove."
 #{ \extractMusic $music $remove \mmR #} )

removeEnd = #(define-music-function (parser location music remove)
      (ly:music? ly:music?)
      "Remove, at the end of `music, a length equal to the one of `remove."

      (let*
       ((new-length (ly:moment-sub (ly:music-length music) (ly:music-length
remove)))
 (newskip (make-music 'SkipEvent 'duration (make-duration-of-length
new-length))))
       #{ \extractMusic $music <> $newskip #} ))


music = \relative { c4 c g' g a a g2 }

<<
  \music
  \removeStart \music s2
  \removeEnd \music s2
>>

%%%
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to