]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/music-functions.scm
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / scm / music-functions.scm
index 2207e18601f6812641f0dad2c7aaa45317e0838a..bc8dad2e448c5d5517725b485e196d8976b13a1d 100644 (file)
@@ -202,6 +202,36 @@ Returns `obj'.
   (music-map (lambda (x) (shift-one-duration-log x shift dot))
             music))
 
+(define-public (make-repeat name times main alts)
+  "create a repeat music expression, with all properties initialized properly"
+  (let ((talts (if (< times (length alts))
+                  (begin
+                    (ly:warning (_ "More alternatives than repeats. Junking excess alternatives"))
+                    (take alts times))
+                  alts))
+       (r (make-repeated-music name)))
+    (set! (ly:music-property r 'element) main)
+    (set! (ly:music-property r 'repeat-count) (max times 1))
+    (set! (ly:music-property r 'elements) talts)
+    (if (equal? name "tremolo")
+       (let* ((dot? (zero? (modulo times 3)))
+              (dots (if dot? 1 0))
+              (mult (if dot?
+                        (quotient (* times 2) 3)
+                        times))
+              (shift (- (ly:intlog2 mult))))
+         
+         (if (memq 'sequential-music (ly:music-property main 'types))
+             ;; \repeat "tremolo" { c4 d4 }
+             (let ((children (length (ly:music-property main 'elements))))
+               (if (not (= children 2))
+                   (ly:warning (_ "expecting 2 elements for chord tremolo, found ~a") children))
+               (ly:music-compress r (ly:make-moment 1 children))
+               (shift-duration-log r (1- shift) dots))
+             ;; \repeat "tremolo" c4
+             (shift-duration-log r shift dots)))
+       r)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; clusters.
 
@@ -472,11 +502,6 @@ of beat groupings "
 (define-public (set-time-signature num den . rest)
   (ly:export (apply make-time-signature-set `(,num ,den . ,rest))))
 
-(define-safe-public (make-penalty-music pen page-pen)
-  (make-music 'BreakEvent
-             'penalty pen
-             'page-penalty page-pen))
-
 (define-safe-public (make-articulation name)
   (make-music 'ArticulationEvent
              'articulation-type name))
@@ -701,7 +726,7 @@ Syntax:
             (cue-voice (if (eq? 1 dir) 0 1))
             (main-music (ly:music-property quote-music 'element))
             (return-value quote-music))
-       
+
        (if (or (eq? 1 dir) (eq? -1 dir))
            
            ;; if we have stem dirs, change both quoted and main music
@@ -732,11 +757,15 @@ Syntax:
         (quoted-vector (if (string? quoted-name)
                            (hash-ref quote-tab quoted-name #f)
                            #f)))
+
     
     (if (string? quoted-name)
-       (if  (vector? quoted-vector)
-            (set! (ly:music-property music 'quoted-events) quoted-vector)
-            (ly:warning (_ "can't find quoted music `~S'" quoted-name))))
+       (if (vector? quoted-vector)
+           (begin
+             (set! (ly:music-property music 'quoted-events) quoted-vector)
+             (set! (ly:music-property music 'iterator-ctor)
+                   ly:quote-iterator::constructor))
+           (ly:warning (_ "can't find quoted music `~S'" quoted-name))))
     music))
 
 
@@ -819,6 +848,7 @@ if appropriate.
      (skip-to-last x parser)
    )))
 
+
 ;;;;;;;;;;;;;;;;;
 ;; lyrics