]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/music-functions.scm
(get_configuration): only shift tie by a whole staff
[lilypond.git] / scm / music-functions.scm
index 53570933dbd76fd4668fdf08ac2809dc820e6cd2..ce4af76c064d378045ce7d305589a00ec5bd74d3 100644 (file)
   (make-procedure-with-setter ly:music-property
                              ly:music-set-property!))
 
+
+;; TODO move this
 (define-public ly:grob-property
   (make-procedure-with-setter ly:grob-property
                              ly:grob-set-property!))
 
+(define-public ly:paper-system-property
+  (make-procedure-with-setter ly:paper-system-property
+                             ly:paper-system-set-property!))
+
 (define-public (music-map function music)
   "Apply @var{function} to @var{music} and all of the music it contains.
 
@@ -96,11 +102,11 @@ For instance,
       (symbol->keyword (string->symbol (substring cmd-markup 0 (- (string-length cmd-markup)
                                                                  (string-length "-markup")))))))
   (define (transform-arg arg)
-    (cond ((and (pair? arg) (pair? (car arg))) ;; a markup list
+    (cond ((and (pair? arg) (markup? (car arg))) ;; a markup list
           (apply append (map inner-markup->make-markup arg)))
-         ((pair? arg)                         ;; a markup
+         ((and (not (string? arg)) (markup? arg)) ;; a markup
           (inner-markup->make-markup arg))
-         (else                                ;; scheme arg
+         (else                                  ;; scheme arg
           arg)))
   (define (inner-markup->make-markup mrkup)
     (let ((cmd (proc->command-keyword (car mrkup)))
@@ -121,17 +127,16 @@ that is, for a music expression, a (make-music ...) form."
         (ly:music? obj)
         `(make-music 
           ',(ly:music-property obj 'name)
-          ,@(append (map (lambda (prop)
-                           (list
-                            (car prop)
-                            (if (and (not (markup? (cdr prop)))
-                                     (list? (cdr prop))
-                                     (pair? (cdr prop))) ;; property is a non-empty list
-                                `(list ,@(map music->make-music (cdr prop)))
-                                (music->make-music (cdr prop)))))
-                         (remove (lambda (prop)
-                                   (eqv? (car prop) 'origin))
-                                 (ly:music-mutable-properties obj))))))
+          ,@(apply append (map (lambda (prop)
+                                  `(',(car prop)
+                                    ,(if (and (not (markup? (cdr prop)))
+                                              (list? (cdr prop))
+                                              (pair? (cdr prop))) ;; property is a non-empty list
+                                         `(list ,@(map music->make-music (cdr prop)))
+                                         (music->make-music (cdr prop)))))
+                                (remove (lambda (prop)
+                                          (eqv? (car prop) 'origin))
+                                        (ly:music-mutable-properties obj))))))
        (;; moment
         (ly:moment? obj)
         `(ly:make-moment ,(ly:moment-main-numerator obj)
@@ -214,14 +219,20 @@ Returns `obj'.
 (define-public (unfold-repeats music)
   "
 This function replaces all repeats  with unfold repeats. "
-  
+
   (let ((es (ly:music-property music 'elements))
        (e  (ly:music-property music 'element))
        )
     (if (memq 'repeated-music (ly:music-property music 'types))
-       (begin
-         (if (equal? (ly:music-property music 'iterator-ctor)
-                     Chord_tremolo_iterator::constructor)
+       (let*
+           ((props (ly:music-mutable-properties music))
+            (old-name (ly:music-property music 'name))
+            (flattened  (flatten-alist props)))
+
+         (set! music (apply make-music (cons 'UnfoldedRepeatedMusic
+                                             flattened)))
+
+         (if (equal? old-name 'TremoloRepeatedMusic)
              (let* ((seq-arg? (memq 'sequential-music
                                     (ly:music-property e 'types)))
                     (count  (ly:music-property music 'repeat-count))
@@ -235,14 +246,9 @@ This function replaces all repeats  with unfold repeats. "
                                             (ly:intlog2 count)) dot-shift)
                
                (if seq-arg?
-                   (ly:music-compress e (ly:make-moment (length (ly:music-property e 'elements)) 1)))))
+                   (ly:music-compress e (ly:make-moment (length (ly:music-property
+                                                                 e 'elements)) 1)))))))
          
-         (set! (ly:music-property music 'length-callback)
-               Repeated_music::unfolded_music_length)
-         (set! (ly:music-property music 'start-callback)
-               Repeated_music::first_start)
-         (set! (ly:music-property music 'iterator-ctor)
-               Unfolded_repeat_iterator::constructor)))
     
     (if (pair? es)
        (set! (ly:music-property music 'elements)
@@ -274,7 +280,7 @@ i.e.  this is not an override"
 
 (define-public (make-grob-property-revert grob gprop)
   "Revert the grob property GPROP for GROB."
-  (make-music 'OverrideProperty
+  (make-music 'RevertProperty
              'symbol grob
              'grob-property gprop))
 
@@ -361,21 +367,38 @@ i.e.  this is not an override"
   "Check if we have R1*4-\\markup { .. }, and if applicable convert to
 a property set for MultiMeasureRestNumber."
   (define (script-to-mmrest-text script-music)
-    "Extract 'direction and 'text from SCRIPT-MUSIC, and transform into property sets."
+    "Extract 'direction and 'text from SCRIPT-MUSIC, and transform MultiMeasureTextEvent"
     (let ((dir (ly:music-property script-music 'direction))
          (p   (make-music 'MultiMeasureTextEvent
                           'text (ly:music-property script-music 'text))))
       (if (ly:dir? dir)
          (set! (ly:music-property p 'direction) dir))
       p))
+  
   (if (eq? (ly:music-property music 'name) 'MultiMeasureRestMusicGroup)
       (let* ((text? (lambda (x) (memq 'script-event (ly:music-property x 'types))))
-            (es (ly:music-property  music 'elements))
-            (texts (map script-to-mmrest-text  (filter text? es)))
-            (others (remove text? es)))
-       (if (pair? texts)
+            (event? (lambda (x) (memq 'event (ly:music-property x 'types))))
+            (group-elts (ly:music-property  music 'elements))
+            (texts '())
+            (events '())
+            (others '()))
+
+       (set! texts 
+             (map script-to-mmrest-text (filter text? group-elts)))
+       (set! group-elts
+             (remove text? group-elts))
+
+       (set! events (filter event? group-elts))
+       (set! others (remove event? group-elts))
+       
+       (if (or (pair? texts) (pair? events))
            (set! (ly:music-property music 'elements)
-                 (cons (make-event-chord texts) others)))))
+                 (cons (make-event-chord
+                        (append texts events))
+                       others)))
+
+       ))
+
   music)
 
 
@@ -732,6 +755,39 @@ Syntax:
        (ly:music-length music))
   music)
 
+(define (skip-to-last music parser)
+
+  "Replace MUSIC by
+
+<< { \\set skipTypesetting = ##t
+     LENGTHOF(\\showLastLength)
+     \\set skipTypesetting = ##t  }
+    MUSIC >>
+
+if appropriate.
+ "
+  (let*
+      ((show-last  (ly:parser-lookup parser 'showLastLength)))
+    
+    (if (ly:music? show-last)
+       (let*
+           ((orig-length (ly:music-length music))
+            (skip-length (ly:moment-sub orig-length (ly:music-length show-last))))
+
+         (make-simultaneous-music
+          (list
+           (make-sequential-music
+            (list
+             (context-spec-music (make-property-set 'skipTypesetting #t) 'Score)
+             (make-music 'SkipMusic 'duration
+                         (ly:make-duration 0 0
+                                           (ly:moment-main-numerator skip-length)
+                                           (ly:moment-main-denominator skip-length)))
+             (context-spec-music (make-property-set 'skipTypesetting #f) 'Score)))
+           music)))
+       music)))
+    
+
 (define-public toplevel-music-functions
   (list
    (lambda (music parser) (voicify-music music))
@@ -744,9 +800,10 @@ Syntax:
    
    ;; switch-on-debugging
    (lambda (x parser) (music-map cue-substitute x))
-;   (lambda (x parser) (music-map display-scheme-music x))
-
-   ))
+   (lambda (x parser)
+     (skip-to-last x parser)
+   )))
 
 ;;;;;;;;;;;;;;;;;
 ;; lyrics
@@ -768,12 +825,13 @@ Syntax:
 (define-public ((add-balloon-text object-name text off) grob orig-context cur-context)
   "Usage: see input/regression/balloon.ly "
   (let* ((meta (ly:grob-property grob 'meta))
-        (nm (if (pair? meta) (cdr (assoc 'name meta)) "nonexistant"))
-        (cb (ly:grob-property grob 'print-function)))
-    (if (equal? nm object-name)
+        (cb (ly:grob-property-data grob 'stencil))
+        (nm (if (pair? meta) (cdr (assoc 'name meta)) "nonexistant")))
+    (if (and (equal? nm object-name)
+            (procedure? cb))
        (begin
-         (set! (ly:grob-property grob 'print-function) Balloon_interface::print)
-         (set! (ly:grob-property grob 'balloon-original-callback) cb)
+         (ly:grob-set-property! grob 'stencil  Balloon_interface::print)
+         (set! (ly:grob-property grob 'original-stencil) cb)
          (set! (ly:grob-property grob 'balloon-text) text)
          (set! (ly:grob-property grob 'balloon-text-offset) off)
          (set! (ly:grob-property grob 'balloon-text-props) '((font-family . roman)))))))