]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/clef.scm
* input/regression/clef-oct.ly: new file.
[lilypond.git] / scm / clef.scm
index a9c7ef79b34cba0be4748aabd93dfb81dad5f837..d58fd237082e38e50f21b938fb4f30bea3187baa 100644 (file)
@@ -88,7 +88,7 @@
   )
 )
 
-(define-public (make-clef-set 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*
   (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! 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 cl supported-clefs))
+    (set! e  (assoc clef-name supported-clefs))
     
     (if (pair? e)
        (let* 
          (context-spec-music seq 'Staff))
        (begin
          (ly:warn (format "Unknown clef type `~a'
-See scm/lily.scm for supported clefs" cl))
+See scm/lily.scm for supported clefs" clef-name))
          (make-music-by-name 'Music)
          
        )