]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/music-functions.scm
patch::: 1.5.25.rz1: accidentals 1.5.25.rz1
[lilypond.git] / scm / music-functions.scm
index 52a9a4a5e3f66a1cbe73648d0e13fd01ff0372f6..6d2257b7e6c837362b14d0a171d3da7c00e6ceee 100644 (file)
 
 (define (unfold-repeats music)
 "
-[Rune Zedeler]
-
-Han-Wen Nienhuys wrote:
-
-> It shouldn't be hard to write a Scheme function to replace all repeats
-> with unfold repeats.
-[...]
-> Left to the reader as an exercise.
-
-With thanks to Han-Wen:
-
-
-"
+This function replaces all repeats  with unfold repeats. It was 
+written by Rune Zedeler. "
   (let* ((es (ly-get-mus-property music 'elements))
          (e (ly-get-mus-property music 'element))
-         (body (ly-get-mus-property music 'body))
-         (alts (ly-get-mus-property music 'alternatives))
          (n  (ly-music-name music)))
 
     (if (equal? n "Repeated_music")
@@ -41,21 +28,42 @@ With thanks to Han-Wen:
          music 'elements
          (map unfold-repeats es)))
 
-    (if (music? alts)
+    (if (music? e)
         (ly-set-mus-property
-         music 'alternatives
-         (unfold-repeats alts)))
+         music 'element
+         (unfold-repeats e)))
 
-    (if (music? body)
+
+    music))
+
+(define  (pitchify-scripts music)
+  "Copy the pitch fields of the Note_requests into  Text_script_requests, to aid
+Fingering_engraver."
+  (define (find-note musics)
+    (filter-list (lambda (m) (equal? (ly-music-name m) "Note_req")) musics)
+    )
+  (define (find-scripts musics)
+    (filter-list (lambda (m) (equal? (ly-music-name m) "Text_script_req")) musics))
+
+  (let* (
+        (e (ly-get-mus-property music 'element))
+        (es (ly-get-mus-property music 'elements))
+        (notes (find-note es))
+        (pitch (if (pair? notes) (ly-get-mus-property (car  notes) 'pitch) #f))
+        )
+
+    (if pitch
+       (map (lambda (x) (ly-set-mus-property x 'pitch pitch)) (find-scripts es))
+       )
+       
+    (if (pair? es)
         (ly-set-mus-property
-         music 'body
-         (unfold-repeats body)))
+         music 'elements
+         (map pitchify-scripts es)))
 
     (if (music? e)
         (ly-set-mus-property
          music 'element
-         (unfold-repeats e)))
-
+         (pitchify-scripts e)))
 
     music))
-