]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/music-functions.scm
* Documentation/topdocs/NEWS.texi (Top): add quarter tones.
[lilypond.git] / scm / music-functions.scm
index b7c6730469b51cd283e0413c6129deaf76c48052..4ee3dfe0b5b36b7a2ad62c0bcdcbda5a5553162c 100644 (file)
@@ -1,4 +1,3 @@
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define-public (music-map function music)
        (function music)
        ))
 
+(define-public (music-filter pred? music)
+  "Filter out music expressions that do not satisfy PRED."
+  
+  (define (inner-music-filter pred? music)
+    "Recursive function."
+    (let* ((es (ly:get-mus-property music 'elements))
+          (e (ly:get-mus-property music 'element))
+          (as (ly:get-mus-property music 'articulations))
+          (filtered-as (filter ly:music? (map (lambda (y) (inner-music-filter pred? y)) as)))
+          (filtered-e (if (ly:music? e)
+                          (inner-music-filter pred? e)
+                          e))
+          (filtered-es (filter ly:music? (map (lambda (y) (inner-music-filter pred? y)) es)))
+          )
+
+      (ly:set-mus-property! music 'element filtered-e)
+      (ly:set-mus-property! music 'elements filtered-es)
+      (ly:set-mus-property! music 'articulations filtered-as)
+
+      ;; if filtering emptied the expression, we remove it completely.
+      (if (or (pred? music)
+             (and (eq? filtered-es '()) (not (ly:music? e))
+                  (or (not (eq? es '()))
+                      (ly:music? e))))
+         (set! music '()))
+      
+      music))
+
+  (set! music (inner-music-filter pred? music))
+  (if (ly:music? music)
+      music
+      (make-music-by-name 'Music)      ;must return music.
+      ))
+
+(define-public (remove-tag tag)
+  (lambda (mus)
+    (music-filter
+     (lambda (m)
+       (let* ((tags (ly:get-mus-property m 'tags))
+             (res (memq tag tags)))
+       res)) mus)))
+
 (define-public (display-music music)
   "Display music, not done with music-map for clarity of presentation."
   (display music)
@@ -332,7 +373,7 @@ and set OTTAVATION to `8va', or whatever appropriate."
                ((where (ly:context-property-where-defined context 'centralCPosition))
                 (oc0 (ly:get-context-property context 'originalCentralCPosition)))
 
-             (ly:set-context-property context 'centralCPosition oc0)
+             (ly:set-context-property! context 'centralCPosition oc0)
              (ly:unset-context-property where 'originalCentralCPosition)
              (ly:unset-context-property where 'ottavation))
 
@@ -347,14 +388,14 @@ and set OTTAVATION to `8va', or whatever appropriate."
                                              (-1 . "8va bassa")
                                              (-2 . "15ma bassa"))))))
 
-             (ly:set-context-property context 'centralCPosition new-c0)
-             (ly:set-context-property context 'originalCentralCPosition c0)
-             (ly:set-context-property context 'ottavation string)
+             (ly:set-context-property! context 'centralCPosition new-c0)
+             (ly:set-context-property! context 'originalCentralCPosition c0)
+             (ly:set-context-property! context 'ottavation string)
              
              ))))
 
   (ly:set-mus-property! m 'procedure  ottava-modify)
-  (context-spec-music m "Staff")
+  (context-spec-music m 'Staff)
   ))
 
 (define-public (set-octavation ottavation)
@@ -379,7 +420,7 @@ Rest can contain a list of beat groupings
        (basic  (list set1 set2 set3 set4)))
 
     (context-spec-music
-     (make-sequential-music basic) "Timing")))
+     (make-sequential-music basic) 'Timing)))
 
 (define-public (set-time-signature num den . rest)
   (ly:export (apply make-time-signature-set `(,num ,den . ,rest))))
@@ -446,7 +487,7 @@ Rest can contain a list of beat groupings
                (make-voice-props-set number)
                (make-simultaneous-music (car lst))))
 
-             "Voice"  (number->string number))
+             'Voice  (number->string number))
              (voicify-list (cdr lst) (+ number 1))
        ))
    )
@@ -454,8 +495,7 @@ Rest can contain a list of beat groupings
 (define (voicify-chord ch)
   "Split the parts of a chord into different Voices using separator"
    (let* ((es (ly:get-mus-property ch 'elements)))
-
-
+     
      (ly:set-mus-property!  ch 'elements
        (voicify-list (split-list es music-separator?) 0))
      ch
@@ -497,6 +537,9 @@ Rest can contain a list of beat groupings
     ;;(eq? #t (ly:get-grob-property elt symbol))
     (not (eq? #f (memq symbol (ly:get-grob-property elt 'interfaces))))))
 
+(define-public ((outputproperty-compatibility func sym val) grob g-context ao-context)
+  (if (func grob)
+      (ly:set-grob-property! grob sym val)))
 
 ;;
 (define-public (smart-bar-check n)
@@ -612,7 +655,7 @@ Rest can contain a list of beat groupings
         )
       (ly:set-context-property! where 'graceSettings new-settings)))
     
-    (ly:export (context-spec-music (make-apply-context set-prop) "Voice")))
+    (ly:export (context-spec-music (make-apply-context set-prop) 'Voice)))
 
 
 (define-public (set-start-grace-properties context)