1 ;;;; clef.scm -- Clef settings
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 ;; (name . (glyph clef-position octavation))
10 ;; -- the name clefOctavation is misleading. The value 7 is 1 octave,
12 (define supported-clefs
13 '(("treble" . ("clefs-G" -2 0))
14 ("violin" . ("clefs-G" -2 0))
15 ("G" . ("clefs-G" -2 0))
16 ("G2" . ("clefs-G" -2 0))
17 ("french" . ("clefs-G" -4 0))
18 ("soprano" . ("clefs-C" -4 0))
19 ("mezzosoprano" . ("clefs-C" -2 0))
20 ("alto" . ("clefs-C" 0 0))
21 ("C" . ("clefs-C" 0 0))
22 ("tenor" . ("clefs-C" 2 0))
23 ("baritone" . ("clefs-C" 4 0))
24 ("varbaritone" . ("clefs-F" 0 0))
25 ("bass" . ("clefs-F" 2 0))
26 ("F" . ("clefs-F" 2 0))
27 ("subbass" . ("clefs-F" 4 0))
28 ("percussion" . ("clefs-percussion" 0 0))
29 ("tab" . ("clefs-tab" 0 0))
31 ;; should move mensural stuff to separate file?
32 ("vaticana_do1" . ("clefs-vaticana_do" -1 0))
33 ("vaticana_do2" . ("clefs-vaticana_do" 1 0))
34 ("vaticana_do3" . ("clefs-vaticana_do" 3 0))
35 ("vaticana_fa1" . ("clefs-vaticana_fa" -1 0))
36 ("vaticana_fa2" . ("clefs-vaticana_fa" 1 0))
37 ("medicaea_do1" . ("clefs-medicaea_do" -1 0))
38 ("medicaea_do2" . ("clefs-medicaea_do" 1 0))
39 ("medicaea_do3" . ("clefs-medicaea_do" 3 0))
40 ("medicaea_fa1" . ("clefs-medicaea_fa" -1 0))
41 ("medicaea_fa2" . ("clefs-medicaea_fa" 1 0))
42 ("hufnagel_do1" . ("clefs-hufnagel_do" -1 0))
43 ("hufnagel_do2" . ("clefs-hufnagel_do" 1 0))
44 ("hufnagel_do3" . ("clefs-hufnagel_do" 3 0))
45 ("hufnagel_fa1" . ("clefs-hufnagel_fa" -1 0))
46 ("hufnagel_fa2" . ("clefs-hufnagel_fa" 1 0))
47 ("hufnagel_do_fa" . ("clefs-hufnagel_do_fa" 4 0))
48 ("mensural_c1" . ("clefs-mensural_c" -2 0))
49 ("mensural_c2" . ("clefs-mensural_c" 0 0))
50 ("mensural_c3" . ("clefs-mensural_c" 2 0))
51 ("mensural_c4" . ("clefs-mensural_c" 4 0))
52 ("mensural_f" . ("clefs-mensural_f" 2 0))
53 ("mensural_g" . ("clefs-mensural_g" -2 0))
54 ("neo_mensural_c1" . ("clefs-neo_mensural_c" -4 0))
55 ("neo_mensural_c2" . ("clefs-neo_mensural_c" -2 0))
56 ("neo_mensural_c3" . ("clefs-neo_mensural_c" 0 0))
57 ("neo_mensural_c4" . ("clefs-neo_mensural_c" 2 0))
58 ("petrucci_c1" . ("clefs-petrucci_c1" -4 0))
59 ("petrucci_c2" . ("clefs-petrucci_c2" -2 0))
60 ("petrucci_c3" . ("clefs-petrucci_c3" 0 0))
61 ("petrucci_c4" . ("clefs-petrucci_c4" 2 0))
62 ("petrucci_c5" . ("clefs-petrucci_c5" 4 0))
63 ("petrucci_f" . ("clefs-petrucci_f" 2 0))
64 ("petrucci_g" . ("clefs-petrucci_g" -2 0))))
66 ;; "an alist mapping GLYPHNAME to the position of the middle C for
68 (define c0-pitch-alist
72 ("clefs-percussion" . 0)
74 ("clefs-vaticana_do" . 0)
75 ("clefs-vaticana_fa" . 4)
76 ("clefs-medicaea_do" . 0)
77 ("clefs-medicaea_fa" . 4)
78 ("clefs-hufnagel_do" . 0)
79 ("clefs-hufnagel_fa" . 4)
80 ("clefs-hufnagel_do_fa" . 0)
81 ("clefs-mensural_c" . 0)
82 ("clefs-mensural_f" . 4)
83 ("clefs-mensural_g" . -4)
84 ("clefs-neo_mensural_c" . 0)
85 ("clefs-petrucci_c1" . 0)
86 ("clefs-petrucci_c2" . 0)
87 ("clefs-petrucci_c3" . 0)
88 ("clefs-petrucci_c4" . 0)
89 ("clefs-petrucci_c5" . 0)
90 ("clefs-petrucci_f" . 4)
91 ("clefs-petrucci_g" . -4)))
93 (define-public (make-clef-set clef-name)
94 "Generate the clef setting commands for a clef with name CL."
95 (define (make-prop-set props)
96 (let ((m (make-music 'PropertySet)))
97 (map (lambda (x) (set! (ly:music-property m (car x)) (cdr x))) props)
102 (match (string-match "^(.*)([_^])([0-9]+)$" clef-name)))
105 (set! clef-name (match:substring match 1))
107 (* (if (equal? (match:substring match 2) "^") -1 1)
108 (- (string->number (match:substring match 3)) 1)))))
109 (set! e (assoc clef-name supported-clefs))
111 (let* ((musics (map make-prop-set
112 `(((symbol . clefGlyph) (value . ,(cadr e)))
113 ((symbol . middleCPosition)
116 (cdr (assoc (cadr e) c0-pitch-alist)))))
117 ((symbol . clefPosition) (value . ,(caddr e)))
118 ((symbol . clefOctavation) (value . ,(- oct))))))
119 (seq (make-music 'SequentialMusic
121 (csp (make-music 'ContextSpeccedMusic)))
122 (context-spec-music seq 'Staff))
124 (ly:warn (format "Unknown clef type `~a'
125 See scm/lily.scm for supported clefs" clef-name))
126 (make-music 'Music)))))