[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature request
From: |
Rune Zedeler |
Subject: |
Re: Feature request |
Date: |
Sun, 07 Oct 2001 03:10:42 +0200 |
Han-Wen Nienhuys wrote:
> It shouldn't be hard to write a Scheme function to replace all repeats
> with unfold repeats.
[...]
> Left to the reader as an exercise.
With thanks to Han-Wen:
#(define (unfold-repeats music)
(let* ((es (ly-get-mus-property music 'elements))
(e (ly-get-mus-property music 'element))
(body (ly-get-mus-property music 'body))
(alts (ly-get-mus-property music 'alternatives))
(n (ly-music-name music)))
(if (equal? n "Repeated_music")
(begin
(ly-set-mus-property
music 'length Repeated_music::unfolded_music_length)
(ly-set-mus-property
music 'iterator-ctor Unfolded_repeat_iterator::constructor)))
(if (pair? es)
(ly-set-mus-property
music 'elements
(map unfold-repeats es)))
(if (music? alts)
(ly-set-mus-property
music 'alternatives
(unfold-repeats alts)))
(if (music? body)
(ly-set-mus-property
music 'body
(unfold-repeats body)))
(if (music? e)
(ly-set-mus-property
music 'element
(unfold-repeats e)))
music))
mel = \notes \context Staff {
\repeat tremolo 8 {c'32 e' }
\repeat percent 2 { c''8 d'' }
\repeat volta 2 {c'4 d' e' f'}
\alternative {
{ g' a' a' g' }
{f' e' d' c' }
}
\bar "|."
}
\score { \notes {
\mel \break
\apply #unfold-repeats \mel
}
}
-Rune