]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/define-music-callbacks.scm
Permits all positive and zero-length buildings in skylines (issue 3161)
[lilypond.git] / scm / define-music-callbacks.scm
index 0cbd96b862658c504841edda2af8fb35cb870ecf..723ed130ec49b00912fe045a00d6006e65d8856a 100644 (file)
@@ -1,6 +1,6 @@
 ;;;; This file is part of LilyPond, the GNU music typesetter.
 ;;;;
-;;;; Copyright (C) 1998--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+;;;; Copyright (C) 1998--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
 ;;;;                Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;;                 Neil Puttock <n.puttock@gmail.com>
 ;;;;                 Carl Sorensen <c_sorensen@byu.edu>
@@ -34,6 +34,34 @@ to be used by the sequential-iterator"
          (make-music 'BarCheck
                      'origin location))))
 
+(define (make-volta-set music)
+  (let* ((alts (ly:music-property music 'elements))
+         (lalts (length alts))
+         (times (ly:music-property music 'repeat-count)))
+    (map (lambda (x y)
+           (make-music
+             'SequentialMusic
+             'elements
+               ;; set properties for proper bar numbering
+               (append
+                 (list (make-music 'AlternativeEvent
+                                   'alternative-dir (if (= y 0)
+                                                        -1
+                                                        0)
+                                   'alternative-increment
+                                     (if (= 0 y)
+                                         (1+ (- times
+                                                lalts))
+                                             1)))
+                       (list x)
+                       (if (= y (1- lalts))
+                           (list (make-music 'AlternativeEvent
+                                             'alternative-dir 1
+                                             'alternative-increment 0))
+                           '()))))
+         alts
+         (iota lalts))))
+
 (define (make-ottava-set music)
   "Set context properties for an ottava bracket."
   (let ((octavation (ly:music-property music 'ottava-number)))
@@ -64,11 +92,11 @@ to be used by the sequential-iterator"
                 (lambda (context)
                   (let* ((time-signature-settings
                           (ly:context-property context 'timeSignatureSettings))
-                         (my-base-fraction
-                           (base-fraction fraction time-signature-settings))
+                         (my-base-length
+                           (base-length fraction time-signature-settings))
                          (my-beat-structure
                            (if (null? structure)
-                               (beat-structure my-base-fraction
+                               (beat-structure my-base-length
                                                fraction
                                                time-signature-settings)
                                structure))
@@ -78,7 +106,7 @@ to be used by the sequential-iterator"
                      (ly:context-set-property!
                        context 'timeSignatureFraction fraction)
                      (ly:context-set-property!
-                       context 'baseMoment (fraction->moment my-base-fraction))
+                       context 'baseMoment (ly:make-moment my-base-length))
                      (ly:context-set-property!
                        context 'beatStructure my-beat-structure)
                      (ly:context-set-property!