lilypond-user
[Top][All Lists]
Advanced

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

Re: Unfolding percents in score only


From: Thomas Morley
Subject: Re: Unfolding percents in score only
Date: Tue, 29 Nov 2016 23:31:59 +0100

2016-11-27 19:11 GMT+01:00 Garrett Fitzgerald <address@hidden>:
> As far as I can tell, short of writing tagged sections, there's no way to
> easily unfold only percents, while leaving voltas intact. Would this be a
> desirable behavior for Lilypond to have?
>
> My particular use case is transcribing band music. The inner parts of
> marches often use percent repeats in the parts I'm working with. I would
> like to be able to leave them as percents in the parts, but have them
> unfolded in the score, so the conductor doesn't have to go hunting for the
> first measure if she's checking notes.
>
> Thanks.


Hi Garrett,

how about below?

\version "2.19.51"

#(define-public (unfold-repeat-types types music)
  "Replace repeats of the types given by @var{types} with unfolded repeats."
  (for-each
    (lambda (type)
      (let ((es (ly:music-property music 'elements))
            (e (ly:music-property music 'element)))
        (if (music-is-of-type? music type)
            (set! music (make-music 'UnfoldedRepeatedMusic music)))
        (if (pair? es)
            (set! (ly:music-property music 'elements)
                  (map (lambda (x) (unfold-repeat-types types x)) es)))
        (if (ly:music? e)
            (set! (ly:music-property music 'element)
                  (unfold-repeat-types types e)))))
    types)
  music)

unfoldRepeatTypes =
#(define-music-function (types music)
  ((symbol-list? '(repeated-music)) ly:music?)
  (_i "Force @code{\\repeat volta}, @code{\\repeat tremolo} or
@code{\\repeat percent} commands in @var{music} to be interpreted
as @code{\\repeat unfold}, if specified in the optional symbol-list @var{types},
which defaults to @code{'(repeated-music)}.
Possible other entries are @code{volta-repeated-music},
@code{tremolo-repeated-music} or @code{percent-repeated-music}.
Multiple entries are possible.")
   (unfold-repeat-types types music))

%%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLE
%%%%%%%%%%%%%%%%%%%%%%%%

m =
  \repeat volta 2 {
        \repeat percent 4 { c'1 }
        \repeat tremolo 4 { c'16 d' }
        \repeat tremolo 4 { c'16 d' }
  }
  \alternative {
        { d'1 }
        { e'1 }
  }

\markup "not expanding"
\m

\markup "expanding all, same as unfoldRepeats"
\unfoldRepeatTypes \m

\markup "expanding percent-repeated-music"
\unfoldRepeatTypes #'(percent-repeated-music) \m

\markup "expanding tremolo-repeated-music"
\unfoldRepeatTypes #'(tremolo-repeated-music) \m

\markup "expanding volta-repeated-music"
\unfoldRepeatTypes #'(volta-repeated-music) \m

%% combinations are possible:
\markup "expanding percent-repeated-music and tremolo-repeated-music"
\unfoldRepeatTypes #'(percent-repeated-music tremolo-repeated-music) \m


Cheers.
  Harm



reply via email to

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