]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/music-functions.scm
* ly/music-functions-init.ly (Module): add shiftDurations
[lilypond.git] / scm / music-functions.scm
index 3650dd0e8b0baf4f3cd4c260923a8dc358465f46..2207e18601f6812641f0dad2c7aaa45317e0838a 100644 (file)
@@ -22,9 +22,9 @@
   (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 ly:prob-property
+  (make-procedure-with-setter ly:prob-property
+                             ly:prob-set-property!))
 
 (define-public (music-map function music)
   "Apply @var{function} to @var{music} and all of the music it contains.
@@ -129,11 +129,7 @@ that is, for a music expression, a (make-music ...) form."
           ',(ly:music-property obj 'name)
           ,@(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)))))
+                                   ,(music->make-music (cdr prop))))
                                 (remove (lambda (prop)
                                           (eqv? (car prop) 'origin))
                                         (ly:music-mutable-properties obj))))))
@@ -163,6 +159,13 @@ that is, for a music expression, a (make-music ...) form."
        (;; an empty list (avoid having an unquoted empty list)
         (null? obj)
         `'())
+       (;; a proper list
+        (list? obj)
+        `(list ,@(map music->make-music obj)))
+       (;; a pair
+        (pair? obj)
+        `(cons ,(music->make-music (car obj)) 
+               ,(music->make-music (cdr obj))))
        (else
         obj)))
 
@@ -179,8 +182,8 @@ Returns `obj'.
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(define (shift-one-duration-log music shift dot)
-  "  add SHIFT to ly:duration-log and optionally 
+(define-public (shift-one-duration-log music shift dot)
+  "  add SHIFT to duration-log of 'duration in music and optionally 
   a dot to any note encountered. This scales the music up by a factor 
   2^shift * (2 - (1/2)^dot)"
   (let ((d (ly:music-property music 'duration)))
@@ -668,7 +671,7 @@ without context specification. Called  from parser."
 
 
 (defmacro-public def-grace-function (start stop)
-  `(def-music-function (parser location music) (ly:music?)
+  `(define-music-function (parser location music) (ly:music?)
      (make-music 'GraceMusic
                 'origin location
                 'element (make-music 'SequentialMusic
@@ -676,10 +679,10 @@ without context specification. Called  from parser."
                                                      music
                                                      (ly:music-deep-copy ,stop))))))
 
-(defmacro-public def-music-function (args signature . body)
+(defmacro-public define-music-function (args signature . body)
   "Helper macro for `ly:make-music-function'.
 Syntax:
-  (def-music-function (parser location arg1 arg2 ...) (arg1-type? arg2-type? ...)
+  (define-music-function (parser location arg1 arg2 ...) (arg1-type? arg2-type? ...)
     ...function body...)
 "
   `(ly:make-music-function (list ,@signature)
@@ -841,7 +844,7 @@ if appropriate.
     (if (and (equal? nm object-name)
             (procedure? cb))
        (begin
-         (ly:grob-set-property! grob 'stencil  Balloon_interface::print)
+         (ly:grob-set-property! grob 'stencil  ly: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)
@@ -963,3 +966,14 @@ use GrandStaff as a context. "
           (ly:make-duration 0 0) '())))
     (ly:music-compress skip (ly:music-length mus))
     skip))
+
+(define-public (pitch-of-note event-chord)
+
+  (let*
+      ((evs (filter (lambda (x) (memq 'note-event (ly:music-property x 'types)))
+                   (ly:music-property event-chord 'elements))))
+
+    (if (pair? evs)
+       (ly:music-property (car evs) 'pitch)
+       #f)))
+