]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/clef.scm
* lily/auto-change-iterator.cc: move contents from
[lilypond.git] / scm / clef.scm
index 50d853c0df2315e68d5d083093ad7af9502aa577..d58fd237082e38e50f21b938fb4f30bea3187baa 100644 (file)
   )
 )
 
-(define (clef-name-to-properties cl)
+(define-public (make-clef-set clef-name)
+  "Generate the clef setting commands for a clef with name CL."
+  (define (make-prop-set props)
+    (let*
+       (
+        (m (make-music-by-name 'PropertySet))
+        )
+
+      (map (lambda (x) (ly:set-mus-property! m (car x) (cdr x))) props)
+      m
+    ))
+    
   (let ((e '())
        (c0 0)
        (oct 0)
-       (l (string-length cl))
-       )
+       (match (string-match "^(.*)([_^])([0-9]+)$" clef-name)))
 
-    ;; ugh. cleanme
-    (if (equal? "8" (substring cl (- l 1) l))
+    (if match
        (begin
-       (if (equal? "^" (substring cl (- l 2) (- l 1)))
-           (set! oct -7)
-           (set! oct 7))
-       
-       (set! cl (substring cl 0 (- l 2)))))
-
-
-    (set! e  (assoc cl supported-clefs))
+         (set! clef-name (match:substring match 1))
+         (set! oct
+               (*
+                (if (equal? (match:substring match 2) "^")
+                    -1 1)
+                (- (string->number (match:substring match 3)) 1))
+         )))
+    
 
+    (set! e  (assoc clef-name supported-clefs))
+    
     (if (pair? e)
-       `(((symbol . clefGlyph)
-          (iterator-ctor . ,Property_iterator::constructor)
-          (value . ,(cadr e))
-          )
+       (let* 
+           (
+            (musics (map make-prop-set  
          
-         ((symbol . centralCPosition)
-          (iterator-ctor . ,Property_iterator::constructor)
-          (value . ,(+ oct (caddr e) (cdr  (assoc  (cadr e) c0-pitch-alist))))
-          )
-         ((symbol . clefPosition)
-          (iterator-ctor . ,Property_iterator::constructor)
-          (value . ,(caddr e))
-          )
-         ((symbol . clefOctavation)
-                (iterator-ctor . ,Property_iterator::constructor)
-                (value . ,(- oct))
-              )
-         )
+                         `(((symbol . clefGlyph)
+                            (value . ,(cadr e))
+                            )
+                           ((symbol . centralCPosition)
+                            (value . ,(+ oct (caddr e) (cdr  (assoc  (cadr e) c0-pitch-alist))))
+                            )
+                           ((symbol . clefPosition)
+                            (value . ,(caddr e))
+                            )
+                           ((symbol . clefOctavation)
+                            (value . ,(- oct))
+                            )
+                           )))
+            (seq (make-music-by-name 'SequentialMusic))
+            (csp (make-music-by-name 'ContextSpeccedMusic))
+            )
+
+         (ly:set-mus-property! seq 'elements musics)
+         (context-spec-music seq 'Staff))
        (begin
-         (ly-warn (string-append "Unknown clef type `" cl "'\nSee scm/lily.scm for supported clefs"))
-         '())
+         (ly:warn (format "Unknown clef type `~a'
+See scm/lily.scm for supported clefs" clef-name))
+         (make-music-by-name 'Music)
+         
+       )
     )))
-
-