[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
unfold-repeats
From: |
Rune Zedeler |
Subject: |
unfold-repeats |
Date: |
Fri, 05 Oct 2001 17:00:49 +0200 |
I have done a scheme function that unfolds all repeats - but it is ugly.
The problem is that I do not know a clean way to find the c-functions
corresponding the properties "length" and "iterator-ctor".
The attached example is much uglier than it needed to be without knowing
how to access the functions (not necessary to pollute global name space)
- but I found it silly to do anything as long as I cannot find the c
functions cleanly.
#(define unfold-length '() )
#(define unfold-iterator-ctor '() )
#(define (init-unfold-repeats unfolded-repeat)
(begin
(set! unfold-length
(ly-get-mus-property unfolded-repeat 'length))
(set! unfold-iterator-ctor
(ly-get-mus-property unfolded-repeat 'iterator-ctor))
unfolded-repeat)
)
#(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 unfold-length)
(ly-set-mus-property
music 'iterator-ctor unfold-iterator-ctor)))
(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 {
\apply #init-unfold-repeats \repeat unfold 2 {}
\mel \break
\apply #unfold-repeats \mel
}
}
-Rune
- unfold-repeats,
Rune Zedeler <=