X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fparser-clef.scm;h=a731e7459e7e6a38e6f796998d3f3b12b3852122;hb=refs%2Fheads%2Fbugs%2F567849;hp=aeb34db579e7114cd82eb2f7b37e4fe96f3f89ed;hpb=4a4b9008d4e571eb5714314661f5eaf35b117ef0;p=lilypond.git diff --git a/scm/parser-clef.scm b/scm/parser-clef.scm index aeb34db579..a731e7459e 100644 --- a/scm/parser-clef.scm +++ b/scm/parser-clef.scm @@ -1,8 +1,19 @@ -;;;; clef.scm -- Clef settings +;;;; This file is part of LilyPond, the GNU music typesetter. ;;;; -;;;; source file of the GNU LilyPond music typesetter +;;;; Copyright (C) 2004--2011 Han-Wen Nienhuys ;;;; -;;;; (c) 2004--2005 Han-Wen Nienhuys +;;;; LilyPond is free software: you can redistribute it and/or modify +;;;; it under the terms of the GNU General Public License as published by +;;;; the Free Software Foundation, either version 3 of the License, or +;;;; (at your option) any later version. +;;;; +;;;; LilyPond is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;;; GNU General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU General Public License +;;;; along with LilyPond. If not, see . ;; (name . (glyph clef-position octavation)) @@ -33,6 +44,7 @@ ("vaticana-do2" . ("clefs.vaticana.do" 1 0)) ("vaticana-do3" . ("clefs.vaticana.do" 3 0)) ("vaticana-fa1" . ("clefs.vaticana.fa" -1 0)) + ("vaticana-fa2" . ("clefs.vaticana.fa" 1 0)) ("medicaea-do1" . ("clefs.medicaea.do" -1 0)) ("medicaea-do2" . ("clefs.medicaea.do" 1 0)) @@ -60,6 +72,9 @@ ("petrucci-c3" . ("clefs.petrucci.c3" 0 0)) ("petrucci-c4" . ("clefs.petrucci.c4" 2 0)) ("petrucci-c5" . ("clefs.petrucci.c5" 4 0)) + ("petrucci-f3" . ("clefs.petrucci.f" 0 0)) + ("petrucci-f4" . ("clefs.petrucci.f" 2 0)) + ("petrucci-f5" . ("clefs.petrucci.f" 4 0)) ("petrucci-f" . ("clefs.petrucci.f" 2 0)) ("petrucci-g" . ("clefs.petrucci.g" -2 0)))) @@ -91,7 +106,7 @@ ("clefs.petrucci.g" . -4))) (define-public (make-clef-set clef-name) - "Generate the clef setting commands for a clef with name CLEF-NAME." + "Generate the clef setting commands for a clef with name @var{clef-name}." (define (make-prop-set props) (let ((m (make-music 'PropertySet))) (map (lambda (x) (set! (ly:music-property m (car x)) (cdr x))) props) @@ -99,29 +114,101 @@ (let ((e '()) (c0 0) (oct 0) - (match (string-match "^(.*)([_^])([0-9]+)$" clef-name))) + (match (string-match "^(.*)([_^])([1-9][0-9]*)$" clef-name))) (if match (begin (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) + (set! e (assoc-get clef-name supported-clefs)) + (if e (let* ((musics (map make-prop-set - `(((symbol . clefGlyph) (value . ,(cadr e))) - ((symbol . middleCPosition) + `(((symbol . clefGlyph) (value . ,(car e))) + ((symbol . middleCClefPosition) (value . ,(+ oct - (caddr e) - (cdr (assoc (cadr e) c0-pitch-alist))))) - ((symbol . clefPosition) (value . ,(caddr e))) + (cadr e) + (assoc-get (car e) c0-pitch-alist)))) + ((symbol . clefPosition) (value . ,(cadr e))) ((symbol . clefOctavation) (value . ,(- oct)))))) + (recalc-mid-C (make-music 'ApplyContext)) (seq (make-music 'SequentialMusic - 'elements musics)) + 'elements (append musics (list recalc-mid-C)))) (csp (make-music 'ContextSpeccedMusic))) + (set! (ly:music-property recalc-mid-C 'procedure) ly:set-middle-C!) (context-spec-music seq 'Staff)) (begin (ly:warning (_ "unknown clef type `~a'") clef-name) - (ly:warning (_ "see scm/clef.scm for supported clefs")) + (ly:warning (_ "supported clefs: ~a") + (string-join + (sort (map car supported-clefs) stringnumber (match:substring match 3)) 1))))) + (set! e (assoc-get clef-name supported-clefs)) + (if e + (let* ((musics (map make-prop-set + `(((symbol . cueClefGlyph) (value . ,(car e))) + ((symbol . middleCCuePosition) + (value . ,(+ oct + (cadr e) + (assoc-get (car e) c0-pitch-alist)))) + ((symbol . cueClefPosition) (value . ,(cadr e))) + ((symbol . cueClefOctavation) (value . ,(- oct)))))) + (recalc-mid-C (make-music 'ApplyContext)) + (seq (make-music 'SequentialMusic + 'elements (append musics (list recalc-mid-C)))) + (csp (make-music 'ContextSpeccedMusic))) + (set! (ly:music-property recalc-mid-C 'procedure) ly:set-middle-C!) + (context-spec-music seq 'Staff)) + (begin + (ly:warning (_ "unknown clef type `~a'") clef-name) + (ly:warning (_ "supported clefs: ~a") + (string-join + (sort (map car supported-clefs) string