X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fparser-clef.scm;h=ea9f67fade20959cfb49300c21e52aba51770d2b;hb=97a0169312a260933246ab224e4f8b0969871dd5;hp=b2c6dc20849a47eddc2a73fa02c45860bdff88cd;hpb=01df8ad908c92687d0c352e5ad5f067e52809423;p=lilypond.git diff --git a/scm/parser-clef.scm b/scm/parser-clef.scm index b2c6dc2084..ea9f67fade 100644 --- a/scm/parser-clef.scm +++ b/scm/parser-clef.scm @@ -1,6 +1,6 @@ ;;;; This file is part of LilyPond, the GNU music typesetter. ;;;; -;;;; Copyright (C) 2004--2012 Han-Wen Nienhuys +;;;; Copyright (C) 2004--2015 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 @@ -16,27 +16,35 @@ ;;;; along with LilyPond. If not, see . -;; (name . (glyph clef-position octavation)) +;; (name . (glyph clef-position transposition)) ;; -;; -- the name clefOctavation is misleading. The value 7 is 1 octave, -;; not 7 Octaves. +;; -- the name clefTransposition is a bit misleading. Value 7 means +;; a transposition of an octave, not a seventh. (define-public supported-clefs '(("treble" . ("clefs.G" -2 0)) ("violin" . ("clefs.G" -2 0)) ("G" . ("clefs.G" -2 0)) ("G2" . ("clefs.G" -2 0)) + ("GG" . ("clefs.GG" -2 0)) + ("tenorG" . ("clefs.tenorG" -2 0)) ("french" . ("clefs.G" -4 0)) ("soprano" . ("clefs.C" -4 0)) ("mezzosoprano" . ("clefs.C" -2 0)) ("alto" . ("clefs.C" 0 0)) ("C" . ("clefs.C" 0 0)) + ("varC" . ("clefs.varC" 0 0)) + ("altovarC" . ("clefs.varC" 0 0)) ("tenor" . ("clefs.C" 2 0)) + ("tenorvarC" . ("clefs.varC" 2 0)) ("baritone" . ("clefs.C" 4 0)) + ("baritonevarC" . ("clefs.varC" 4 0)) ("varbaritone" . ("clefs.F" 0 0)) + ("baritonevarF" . ("clefs.F" 0 0)) ("bass" . ("clefs.F" 2 0)) ("F" . ("clefs.F" 2 0)) ("subbass" . ("clefs.F" 4 0)) ("percussion" . ("clefs.percussion" 0 0)) + ("varpercussion" . ("clefs.varpercussion" 0 0)) ("tab" . ("clefs.tab" 0 0)) ;; should move mensural stuff to separate file? @@ -90,9 +98,13 @@ ;; that symbol" (define c0-pitch-alist '(("clefs.G" . -4) + ("clefs.GG" . 3) + ("clefs.tenorG" . 3) ("clefs.C" . 0) + ("clefs.varC" . 0) ("clefs.F" . 4) ("clefs.percussion" . 0) + ("clefs.varpercussion" . 0) ("clefs.tab" . 0 ) ("clefs.vaticana.do" . 0) ("clefs.vaticana.fa" . 4) @@ -117,133 +129,67 @@ (define-public (make-clef-set 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) - m)) - (let ((e '()) - (c0 0) - (oct 0) - (style 'default) - (match (string-match "^(.*)([_^])([^0-9a-zA-Z]*)([1-9][0-9]*)([^0-9a-zA-Z]*)$" 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 4)) 1))) - (set! style - (cond ((equal? (match:substring match 3) "(") 'parenthesized) + (let* ((match (string-match "^(.*)([_^])([^0-9a-zA-Z]*)([1-9][0-9]*)([^0-9a-zA-Z]*)$" clef-name)) + (e (assoc-get (if match (match:substring match 1) clef-name) supported-clefs)) + (oct (if match + ((if (equal? (match:substring match 2) "^") - +) + (1- (string->number (match:substring match 4)))) + 0)) + (style (cond ((not match) 'default) + ((equal? (match:substring match 3) "(") 'parenthesized) ((equal? (match:substring match 3) "[") 'bracketed) - (else style))))) - (set! e (assoc-get clef-name supported-clefs)) + (else 'default)))) (if e - (let* ((prop-list `(((symbol . clefGlyph) (value . ,(car e))) - ((symbol . middleCClefPosition) - (value . ,(+ oct - (cadr e) - (assoc-get (car e) c0-pitch-alist)))) - ((symbol . clefPosition) (value . ,(cadr e))) - ((symbol . clefOctavation) (value . ,(- oct))))) - ;; the clefOctavationStyle property is set only when - ;; not 'default to calm display-lily-tests.scm - (prop-list (if (eq? style 'default) - prop-list - (append - prop-list - `(((symbol . clefOctavationStyle) - (value . ,style)))))) - (musics (map make-prop-set prop-list)) - (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) stringnumber (match:substring match 4)) 1))) - (set! style - (cond ((equal? (match:substring match 3) "(") 'parenthesized) - ((equal? (match:substring match 3) "[") 'bracketed) - (else style))))) - (set! e (assoc-get clef-name supported-clefs)) - (if e - (let* ((prop-list `(((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))))) - (prop-list (if (eq? style 'default) - prop-list - (append - prop-list - `(((symbol . cueClefOctavationStyle) - (value . ,style)))))) - (musics (map make-prop-set prop-list)) - (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