1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 2010--2012 Mike Solomon <mikesol@stanfordalumni.org>
4 ;;;; Clarinet drawings copied from diagrams created by
5 ;;;; Gilles Thibault <gilles.thibault@free.fr>
7 ;;;; LilyPond is free software: you can redistribute it and/or modify
8 ;;;; it under the terms of the GNU General Public License as published by
9 ;;;; the Free Software Foundation, either version 3 of the License, or
10 ;;;; (at your option) any later version.
12 ;;;; LilyPond is distributed in the hope that it will be useful,
13 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;;; GNU General Public License for more details.
17 ;;;; You should have received a copy of the GNU General Public License
18 ;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 (define HOLE-FILL-LIST '((R . 3) (1q . 5) (1h . 7) (3q . 11) (F . 13)))
24 (define-public (symbol-concatenate . names)
25 "Like @code{string-concatenate}, but for symbols."
26 (string->symbol (apply string-append (map symbol->string names))))
28 (define-public (function-chain arg function-list)
29 "Applies a list of functions in @var{function-list} to @var{arg}.
30 Each element of @var{function-list} is structured @code{(cons function
31 '(arg2 arg3 ...))}. If function takes arguments besides @var{arg}, they
32 are provided in @var{function-list}.
34 Example: Executing @samp{(function-chain 1 `((,+ 1) (,- 2) (,+ 3) (,/)))}
36 (if (null? function-list)
39 (apply (caar function-list) (append `(,arg) (cdar function-list)))
40 (cdr function-list))))
42 (define (rotunda-map function inlist rotunda)
43 "Like map, but with a rotating last argument to function.
45 @code{guile> (rotunda-map + '(1 2 3 4) '(1 -10))}
47 (define (rotunda-map-chain function inlist outlist rotunda)
53 (append outlist (list (function (car inlist) (car rotunda))))
54 (append (cdr rotunda) (list (car rotunda))))))
55 (rotunda-map-chain function inlist '() rotunda))
57 (define (assoc-keys alist)
58 "Gets the keys of an alist."
59 (map (lambda (x) (car x)) alist))
61 (define (assoc-values alist)
62 "Gets the values of an alist."
63 (map (lambda (x) (cdr x)) alist))
65 (define (get-slope-offset p1 p2)
66 "Gets the slope and offset for p1 and p2.
68 @code{(get-slope-offset '(1 . 2) '(3 . -5.1))}
69 @code{(-3.55 . 5.55)}"
71 ((slope (/ (- (cdr p1) (cdr p2)) (- (car p1) (car p2))))
72 (offset (- (cdr p1) (* slope (car p1)))))
75 (define (is-square? x input-list)
76 "Returns true if x is the square of a value in input-list."
77 (pair? (memv (inexact->exact (sqrt x)) input-list)))
79 (define (true-entry? input-list)
80 "Is there a true entry in @code{input-list}?"
81 (any identity input-list))
83 (define (entry-greater-than-x? input-list x)
84 "Is there an entry greater than @code{x} in @code{input-list}?"
85 (any (lambda (y) (> y x)) input-list))
87 (define (n-true-entries input-list)
88 "Returns number of true entries in @code{input-list}."
89 (count identity input-list))
91 (define (bezier-head-for-stencil bezier cut-point)
92 "Prepares a split-bezier to be used in a connected path stencil."
93 (list-tail (flatten-list (car (split-bezier bezier cut-point))) 2))
95 ;; Translators for keys
97 ; Translates a "normal" key (open, closed, trill)
98 (define (key-fill-translate fill)
102 ((= fill (expt (assoc-get 'F HOLE-FILL-LIST) 2)) 0.5)
103 ((= fill (assoc-get 'F HOLE-FILL-LIST)) #t)))
105 ; Similar to above, but trans vs opaque doesn't matter
106 (define (text-fill-translate fill)
109 ((= fill (expt (assoc-get 'F HOLE-FILL-LIST) 2)) 0.5)
110 ((= fill (assoc-get 'F HOLE-FILL-LIST)) 0.0)))
112 ; Emits a list for the central-column-hole maker
113 ; (not-full?, 1-quarter-full?, 1-half-full?, 3-quarters-full?, full?)
114 ; Multiple values, such as (#t #f #f #t #f), mean a trill between
115 ; not-full and 3-quarters-full
116 (define (process-fill-value fill)
117 (let* ((avals (list-tail (assoc-values HOLE-FILL-LIST) 1)))
118 (append `(,(or (< fill 3) (is-square? fill avals)))
119 (map (lambda (x) (= 0 (remainder fill x))) avals))))
121 ; Color a stencil gray
122 (define (gray-colorize stencil)
123 (apply ly:stencil-in-color (cons stencil (x11-color 'grey))))
125 ; A connected path stencil that is surrounded by proc
126 (define (rich-path-stencil ls x-stretch y-stretch proc)
127 (lambda (radius thick fill layout props)
129 ((fill-translate (key-fill-translate fill))
130 (gray? (eqv? fill-translate 0.5)))
132 ((if gray? gray-colorize identity)
134 (make-connected-path-stencil
140 (if gray? #t fill-translate))))
143 ((rich-path-stencil ls x-stretch y-stretch proc)
150 ; A connected path stencil without a surrounding proc
151 (define (standard-path-stencil ls x-stretch y-stretch)
152 (rich-path-stencil ls x-stretch y-stretch identity))
154 ; An ellipse stencil that is surrounded by a proc
155 (define (rich-pe-stencil x-stretch y-stretch start end proc)
156 (lambda (radius thick fill layout props)
158 ((fill-translate (key-fill-translate fill))
159 (gray? (eqv? fill-translate 0.5)))
161 ((if gray? gray-colorize identity)
163 (make-partial-ellipse-stencil
170 (if gray? #t fill-translate))))
173 ((rich-pe-stencil x-stretch y-stretch start end proc)
180 (define (rich-e-stencil x-stretch y-stretch proc)
181 (lambda (radius thick fill layout props)
183 ((fill-translate (key-fill-translate fill))
184 (gray? (eqv? fill-translate 0.5)))
186 ((if gray? gray-colorize identity)
188 (make-ellipse-stencil
192 (if gray? #t fill-translate))))
195 ((rich-e-stencil x-stretch y-stretch proc)
202 ; An ellipse stencil without a surrounding proc
203 (define (standard-e-stencil x-stretch y-stretch)
204 (rich-e-stencil x-stretch y-stretch identity))
206 ; Translates all possible representations of symbol.
207 ; If simple? then the only representations are open, closed, and trill.
208 ; Otherwise, there can be various levels of "closure" on the holes
209 ; ring? allows for a ring around the holes as well
210 (define (make-symbol-alist symbol simple? ring?)
215 `(,(symbol-concatenate symbol 'T 'F) .
216 ,(expt (assoc-get 'F HOLE-FILL-LIST) 2)))))
218 `((,symbol . ,(assoc-get 'F HOLE-FILL-LIST))
219 (,(symbol-concatenate symbol 'T) .
220 ,(expt (assoc-get 'F HOLE-FILL-LIST) 2)))
226 `((,(symbol-concatenate symbol (car x) 'T)
228 (,(symbol-concatenate symbol 'T (car x))
229 . ,(* (cdr x) (assoc-get 'F HOLE-FILL-LIST)))
230 (,(symbol-concatenate symbol (car x))
235 `(,(symbol-concatenate symbol
239 . ,(* (cdr a) (cdr b))))
241 (cdr (member x HOLE-FILL-LIST))))))
242 (if ring? HOLE-FILL-LIST (cdr HOLE-FILL-LIST))))))))
244 ;;; Commands for text layout
246 ; Draws a circle around markup if (= trigger 0.5)
247 (define-markup-command
248 (conditional-circle-markup layout props trigger in-markup)
250 (interpret-markup layout props
251 (if (eqv? trigger 0.5)
252 (markup #:circle (markup in-markup))
253 (markup in-markup))))
255 ; Makes a list of named-keys
256 (define (make-name-keylist input-list key-list font-size)
259 (markup #:conditional-circle-markup
263 (markup #:abs-fontsize font-size (car y))
264 (if (and (< x 1) (cdr y))
284 input-list key-list))
286 ; Makes a list of number-keys
287 (define (make-number-keylist input-list key-list font-size)
291 #:conditional-circle-markup
293 (markup #:abs-fontsize font-size #:number y))
298 ; Creates a named-key list with a certain alignment
299 (define (aligned-text-stencil-function dir hv)
300 (lambda (key-name-list radius fill-list layout props)
304 (make-general-align-markup
307 ((if hv make-concat-markup make-center-column-markup)
309 (map text-fill-translate fill-list)
313 (define number-column-stencil
314 (lambda (key-name-list radius fill-list layout props)
318 (make-general-align-markup
321 (make-general-align-markup
324 (make-override-markup
328 (map text-fill-translate fill-list)
332 ; Utility function for the left-hand keys
333 (define lh-woodwind-text-stencil
334 (aligned-text-stencil-function LEFT #t))
336 ; Utility function for the right-hand keys
337 (define rh-woodwind-text-stencil
338 (aligned-text-stencil-function RIGHT #t))
340 (define octave-woodwind-text-stencil
341 (aligned-text-stencil-function CENTER #f))
345 (define (rich-group-draw-rule alist target-part change-part)
347 (entry-greater-than-x?
348 (map (lambda (key) (assoc-get key alist)) target-part) 3)
349 (map-selected-alist-keys (lambda (x) (if (= x 0) 1 x)) change-part alist)
352 (define (bassoon-midline-rule alist target-part)
354 (entry-greater-than-x?
355 (map (lambda (key) (assoc-get key alist)) target-part) 0)
356 (map-selected-alist-keys (lambda (x) 1) '((hidden . long-midline)) alist)
357 (map-selected-alist-keys (lambda (x) 1) '((hidden . midline)) alist)))
359 (define (group-draw-rule alist target-part)
360 (rich-group-draw-rule alist target-part target-part))
362 (define (group-automate-rule alist change-part)
363 (map-selected-alist-keys (lambda (x) (if (= x 0) 1 x)) change-part alist))
365 (define (apply-group-draw-rule-series alist target-part-list)
366 (if (null? target-part-list)
368 (apply-group-draw-rule-series
369 (group-draw-rule alist (car target-part-list))
370 (cdr target-part-list))))
372 ;; Extra-offset rules
374 (define (rich-group-extra-offset-rule alist target-part change-part eos)
376 (entry-greater-than-x?
377 (map (lambda (key) (assoc-get key alist)) target-part) 0)
378 (map-selected-alist-keys (lambda (x) eos) change-part alist)
381 (define (group-extra-offset-rule alist target-part eos)
382 (rich-group-extra-offset-rule alist target-part target-part eos))
384 (define (uniform-extra-offset-rule alist eos)
385 (map-selected-alist-keys
386 (lambda (x) (if (pair? x) x eos))
390 ;;; General drawing commands
392 ; Used all the time for a dividing line
393 (define (midline-stencil radius thick fill layout props)
394 (make-line-stencil (* thick 2) (* -0.80 radius) 0 (* 0.80 radius) 0))
396 (define (long-midline-stencil radius thick fill layout props)
397 (make-line-stencil (* thick 2) (* -5.75 radius) 0 (* 0.75 radius) 0))
399 ; Used all the time for a small, between-hole key
400 (define little-elliptical-key-stencil (standard-e-stencil 0.75 0.2))
402 ; Used for several upper keys in the clarinet and sax
403 (define (upper-key-stencil tailw tailh bodyw bodyh)
405 ((xmove (lambda (x) (+ tailw (+ 0.2 (* bodyw (- x 0.2))))))
406 (ymove (lambda (x) (+ (- tailh) (+ -0.05 (* bodyh (+ x 0.05)))))))
407 (standard-path-stencil
423 ,(- -0.025 (/ tailh 2))
429 ; Utility function for the column-hole maker.
430 ; Returns the left and right degrees for the drawing of a given
431 ; fill level (1-quarter, 1-half, etc...)
432 (define (degree-first-true fill-list left? reverse?)
433 (define (dfl-crawler fill-list os-list left?)
435 ((if left? car cdr) (car os-list))
436 (dfl-crawler (cdr fill-list) (cdr os-list) left?)))
438 ((if reverse? reverse identity) fill-list)
439 ((if reverse? reverse identity)
440 '((0 . 0) (215 . 325) (180 . 0) (145 . 35) (90 . 90)))
443 ; Gets the position of the first (or last if reverse?) element of a list.
444 (define (position-true-endpoint in-list reverse?)
445 (define (pte-crawler in-list n)
448 (pte-crawler (cdr in-list) (+ n 1))))
450 (if reverse? (length in-list) 0)
451 (pte-crawler ((if reverse? reverse identity) in-list) 0)))
453 ; Huge, kind-of-ugly maker of a circle in a column.
454 ; I think this is the clearest way to write it, though...
456 (define (column-circle-stencil radius thick fill layout props)
457 (let* ((fill-list (process-fill-value fill)))
460 (list-ref fill-list 0)
461 (not (true-entry? (list-tail fill-list 1)))) ; is it empty?
462 ((standard-e-stencil 1.0 1.0) radius thick fill layout props))
464 (list-ref fill-list 4)
465 (not (true-entry? (list-head fill-list 4)))) ; is it full?
466 ((standard-e-stencil 1.0 1.0) radius thick fill layout props))
468 (list-ref fill-list 0)
469 (list-ref fill-list 4)) ; is it a trill between empty and full?
470 ((standard-e-stencil 1.0 1.0) radius thick fill layout props))
471 (else ;If none of these, it is partially full.
473 ((rich-pe-stencil 1.0 1.0 0 360 identity)
476 (if (list-ref fill-list 4)
477 (expt (assoc-get 'F HOLE-FILL-LIST) 2)
484 (degree-first-true fill-list #t #t)
485 (degree-first-true fill-list #f #t)
491 (list-head fill-list (position-true-endpoint fill-list #t)))
492 (expt (assoc-get 'F HOLE-FILL-LIST) 2)
493 (assoc-get 'F HOLE-FILL-LIST))
497 (= 2 (n-true-entries (list-tail fill-list 1))) ; trill?
501 (degree-first-true fill-list #t #f)
502 (degree-first-true fill-list #f #f)
506 (assoc-get 'F HOLE-FILL-LIST)
511 (define (variable-column-circle-stencil scaler)
512 (lambda (radius thick fill layout props)
513 (column-circle-stencil (* radius scaler) thick fill layout props)))
515 ; A stencil for ring-column circles that combines two of the above
516 (define (ring-column-circle-stencil radius thick fill layout props)
517 (if (= 0 (remainder fill (assoc-get 'R HOLE-FILL-LIST)))
520 (= fill (expt (assoc-get 'R HOLE-FILL-LIST) 2))
524 (* (+ (- 1.0 (* 2 thick)) (/ thick 2)))
525 (* (+ (- 1.0 (* 2 thick)) (/ thick 2))))
527 (* (* 4 radius) thick)
531 ((standard-e-stencil 1.0 1.0) radius thick 1 layout props)
532 (column-circle-stencil
533 (+ (* (- 1.0 (* 4 thick)) radius) (/ thick 2))
536 (if (= 0 (remainder fill (assoc-get 'F HOLE-FILL-LIST)))
537 (assoc-get 'F HOLE-FILL-LIST)
539 (if (= fill (expt (assoc-get 'R HOLE-FILL-LIST) 2))
540 (/ fill (expt (assoc-get 'R HOLE-FILL-LIST) 2))
541 (/ fill (assoc-get 'R HOLE-FILL-LIST))))
544 (column-circle-stencil radius thick fill layout props)))
546 ;;; Flute family stencils
548 (define flute-lh-b-key-stencil
549 (standard-path-stencil
551 (0 1.625 -0.125 1.75 -0.25 1.75)
552 (-0.55 1.75 -0.55 0.95 -0.25 0.7)
557 (define flute-lh-bes-key-stencil
558 (standard-path-stencil
560 (0 1.625 -0.125 1.75 -0.25 1.75)
561 (-0.55 1.75 -0.55 0.95 -0.25 0.7)
566 (define (flute-lh-gis-rh-bes-key-stencil deg)
568 '((0.1 0.1 0.2 0.4 0.3 0.6)
569 (0.3 1.0 0.8 1.0 0.8 0.7)
570 (0.8 0.3 0.5 0.3 0 0))
573 (lambda (stencil) (ly:stencil-rotate stencil deg 0 0))))
575 (define flute-lh-gis-key-stencil (flute-lh-gis-rh-bes-key-stencil 0))
577 (define flute-rh-bes-key-stencil (flute-lh-gis-rh-bes-key-stencil 200))
579 (define flute-rh-d-key-stencil little-elliptical-key-stencil)
581 (define flute-rh-dis-key-stencil little-elliptical-key-stencil)
583 (define flute-rh-ees-key-stencil
584 (standard-path-stencil
585 '((0.8 0) (1.1 0 1.1 0.75 0.7 0.75) (0.5 0.75) (0.15 0.75 0.1 0.2 0 0))
589 (define (piccolo-rh-x-key-stencil radius thick fill layout props)
593 (make-general-align-markup
598 `(,(text-fill-translate fill))
602 (define flute-lower-row-stretch 1.4)
604 (define flute-rh-cis-key-stencil
605 (standard-path-stencil
606 '((0 0.75) (-0.8 0.75 -0.8 0 0 0))
607 flute-lower-row-stretch
608 flute-lower-row-stretch))
610 (define flute-rh-c-key-stencil
611 (standard-path-stencil
612 '((0 0.75) (0.4 0.75) (0.4 0) (0 0))
613 flute-lower-row-stretch
614 flute-lower-row-stretch))
616 (define flute-rh-b-key-stencil
617 (standard-path-stencil
618 '((0 0.75) (0.25 0.75) (0.25 0) (0 0))
619 flute-lower-row-stretch
620 flute-lower-row-stretch))
622 (define flute-rh-gz-key-stencil
624 '((0.1 0.1 0.4 0.2 0.6 0.3)
625 (1.0 0.3 1.0 0.8 0.7 0.8)
626 (0.3 0.8 0.3 0.5 0 0))
627 flute-lower-row-stretch
628 flute-lower-row-stretch
629 (lambda (stencil) (ly:stencil-rotate stencil 160 0 0))))
631 ;;; Shared oboe/clarinet stencils
633 (define (oboe-lh-gis-lh-low-b-key-stencil gis?)
641 `((0.0 . 0.0) (0.0 . ,y) (,x . ,y) (,x . 0.0))
646 `((,x . 0.0) (,x . ,(- y)) (0.0 . ,(- y)) (0.0 . 0.0))
649 (standard-path-stencil
652 `((0.25 ,(/ y -2) 0.75 ,(/ y -2) 1.0 0.0))
657 (coord-rotate x (atan (/ y (* 2 0.25))))
660 `(((0 . ,y) (,x . ,y) (,x . 0))
661 ((,x . ,(- y)) (0 . ,(- y)) (0 . 0)))))
662 `((0.75 ,(/ y -2) 0.25 ,(/ y -2) 0.0 0.0)))
665 (standard-path-stencil
669 (coord-rotate x (atan (/ y (* 2 0.25)))))
671 `(,(list-tail up-part 1)
672 ,(list-head down-part 1)
673 ,(list-tail down-part 1)))
675 (- scaling-factor)))))
677 (define oboe-lh-gis-key-stencil (oboe-lh-gis-lh-low-b-key-stencil #t))
679 (define oboe-lh-low-b-key-stencil (oboe-lh-gis-lh-low-b-key-stencil #f))
681 (define (oboe-lh-ees-lh-bes-key-stencil ees?)
682 (standard-path-stencil
684 (0 1.625 -0.125 1.75 -0.25 1.75)
685 (-0.5 1.75 -0.5 0.816 -0.25 0.5)
687 (0 ,(if ees? -0.6 -0.3)))
688 (* (if ees? -1.0 1.0) -1.8)
691 (define oboe-lh-ees-key-stencil (oboe-lh-ees-lh-bes-key-stencil #t))
693 (define oboe-lh-bes-key-stencil (oboe-lh-ees-lh-bes-key-stencil #f))
695 ;;; Oboe family stencils
697 (define (oboe-lh-octave-key-stencil long?)
698 (let* ((h (if long? 1.4 1.2)))
699 (standard-path-stencil
700 `((-0.4 0 -0.4 1.0 -0.1 1.0)
708 (define oboe-lh-I-key-stencil (oboe-lh-octave-key-stencil #f))
710 (define oboe-lh-II-key-stencil (oboe-lh-octave-key-stencil #f))
712 (define oboe-lh-III-key-stencil (oboe-lh-octave-key-stencil #t))
714 (define oboe-lh-b-key-stencil (standard-e-stencil 0.6 0.8))
716 (define oboe-lh-d-key-stencil little-elliptical-key-stencil)
718 (define oboe-lh-cis-key-stencil little-elliptical-key-stencil)
720 (define oboe-lh-f-key-stencil (standard-e-stencil 0.5 1.0))
722 (define oboe-rh-a-key-stencil (standard-e-stencil 1.0 0.45))
724 (define oboe-rh-gis-key-stencil (standard-e-stencil 0.45 1.2))
726 (define oboe-rh-d-key-stencil little-elliptical-key-stencil)
728 (define oboe-rh-f-key-stencil little-elliptical-key-stencil)
730 (define (oboe-rh-c-rh-ees-key-stencil c?)
732 '((1.0 0.0 1.0 0.70 1.5 0.70)
733 (2.25 0.70 2.25 -0.4 1.5 -0.4)
738 (lambda (stencil) (ly:stencil-rotate stencil (if c? 170 180) 0 0))))
740 (define oboe-rh-banana-key-stencil oboe-rh-gis-key-stencil)
742 (define oboe-rh-c-key-stencil (oboe-rh-c-rh-ees-key-stencil #t))
744 (define oboe-rh-cis-key-stencil
746 '((0.6 0.0 0.6 0.50 1.25 0.50)
747 (2.25 0.50 2.25 -0.4 1.25 -0.4)
748 (0.6 -0.4 0.6 0 0 0))
751 (lambda (stencil) (ly:stencil-rotate stencil 0 0 0))))
753 (define oboe-rh-ees-key-stencil (oboe-rh-c-rh-ees-key-stencil #f))
755 ;;; Clarinet family stencils
757 (define clarinet-lh-thumb-key-stencil
758 (variable-column-circle-stencil 0.9))
760 (define clarinet-lh-R-key-stencil
761 (let* ((halfbase (cos (/ PI 10)))
764 (/ (sin (/ (* 4 PI) 10)) (cos (/ (* 4 PI) 10))))))
765 (standard-path-stencil
767 (0 ,(/ -4.0 3.0) -2.0 ,(/ -4.0 3.0) -2.0 0.0)
768 (-1.5 ,(* 0.5 height) -1.25 ,(* 0.75 height) -1.0 ,height)
769 (-0.75 ,(* 0.75 height) -0.5 ,(* 0.5 height) 0.0 0.0))
773 (define (clarinet-lh-a-key-stencil radius thick fill layout props)
774 (let* ((width 0.4) (height 0.75) (linelen 0.45))
776 ((standard-e-stencil width height) radius thick fill layout props)
777 (ly:stencil-translate
778 (make-line-stencil thick 0 0 0 (* linelen radius))
779 (cons 0 (* height radius))))))
781 (define clarinet-lh-gis-key-stencil (upper-key-stencil 0.0 0.0 1.3 2.0))
783 (define clarinet-lh-ees-key-stencil little-elliptical-key-stencil)
785 (define clarinet-lh-cis-key-stencil oboe-lh-gis-key-stencil)
787 (define clarinet-lh-f-key-stencil oboe-lh-low-b-key-stencil)
789 (define clarinet-lh-e-key-stencil oboe-lh-ees-key-stencil)
791 (define clarinet-lh-fis-key-stencil oboe-lh-bes-key-stencil)
793 (define clarinet-lh-d-key-stencil (standard-e-stencil 1.0 0.4))
795 (define clarinet-rh-low-c-key-stencil
796 (standard-path-stencil
798 (0.0 2.5 -1.0 2.5 -1.0 0.75)
799 (-1.0 0.1 0.0 0.25 0.0 0.3)
804 (define clarinet-rh-low-cis-key-stencil
805 (standard-path-stencil
807 (0.0 1.67 -1.0 1.67 -1.0 0.92)
808 (-1.0 0.47 0.0 0.52 0.0 0.62)
813 (define clarinet-rh-low-d-key-stencil
814 (standard-path-stencil
816 (0.0 1.55 -1.0 1.55 -1.0 0.8)
817 (-1.0 0.35 0.0 0.4 0.0 0.5)
822 (define clarinet-rh-one-key-stencil (standard-e-stencil 0.5 0.25))
824 (define clarinet-rh-two-key-stencil clarinet-rh-one-key-stencil)
826 (define clarinet-rh-three-key-stencil clarinet-rh-one-key-stencil)
828 (define clarinet-rh-four-key-stencil clarinet-rh-one-key-stencil)
830 (define clarinet-rh-b-key-stencil little-elliptical-key-stencil)
833 (define CL-RH-HAIR 0.09)
834 (define CL-RH-H-STRETCH 2.7)
835 (define CL-RH-V-STRETCH 0.9)
838 ; there is some unnecessary information duplication here.
839 ; need a way to control all of the below stencils so that if one
840 ; changes, all change...
842 (define clarinet-rh-fis-key-stencil
843 (standard-path-stencil
844 `(,(bezier-head-for-stencil
845 '((0.0 . 0.0) (0.0 . -1.0) (1.0 . -1.0) (1.0 . 0.0))
847 ,(bezier-head-for-stencil
848 '((0.5 . -0.75) (0.5 . 0.25) (1.5 . 0.25) (1.5 . -0.75))
850 (1.0 1.0 0.0 1.0 0.0 0.0))
854 (define clarinet-rh-gis-key-stencil
855 (standard-path-stencil
856 '((0.0 1.0 1.0 1.0 1.0 0.0) (1.0 -1.0 0.0 -1.0 0.0 0.0))
860 (define clarinet-rh-e-key-stencil
861 (standard-path-stencil
862 `(,(bezier-head-for-stencil
863 '((0.0 . 0.0) (0.0 . -1.0) (1.0 . -1.0) (1.0 . 0.0))
865 ,(bezier-head-for-stencil
866 '((0.5 . -0.75) (0.5 . 0.25) (1.5 . 0.25) (1.5 . -0.75))
868 ,(bezier-head-for-stencil
869 `((1.0 . 0.0) (,(/ 1 3) . 0.0) (,(/ 1 3) . 1.5) (1.0 . 1.5))
871 ,(bezier-head-for-stencil
872 `((0.5 . 0.75) (,(/ -1 6) . 0.75) (,(/ -1 6) . -0.75) (0.5 . -0.75))
877 (define clarinet-rh-f-key-stencil clarinet-rh-gis-key-stencil)
879 (define bass-clarinet-rh-ees-key-stencil
880 (standard-path-stencil
881 `(,(bezier-head-for-stencil
882 '((0.0 . 0.0) (0.0 . -1.0) (1.0 . -1.0) (1.0 . 0.0))
884 ,(bezier-head-for-stencil
885 '((0.5 . -0.75) (0.5 . 0.25) (1.5 . 0.25) (1.5 . -0.75))
887 (1.0 1.0 0.0 1.0 0.0 0.0))
889 (- CL-RH-V-STRETCH)))
891 (define low-bass-clarinet-rh-ees-key-stencil clarinet-rh-e-key-stencil)
893 (define clarinet-rh-d-key-stencil clarinet-rh-gis-key-stencil)
895 ;;; Saxophone family stencils
897 (define saxophone-lh-ees-key-stencil (upper-key-stencil 0.0 0.0 1.3 2.0))
899 (define saxophone-lh-f-key-stencil (upper-key-stencil 0.0 0.0 1.3 2.0))
901 (define saxophone-lh-d-key-stencil (upper-key-stencil 0.0 0.0 1.3 2.0))
903 (define saxophone-lh-front-f-key-stencil (standard-e-stencil 0.7 0.7))
905 (define saxophone-lh-bes-key-stencil (standard-e-stencil 0.5 0.5))
907 (define saxophone-lh-T-key-stencil (standard-e-stencil 0.75 0.75))
909 (define saxophone-lh-gis-key-stencil
910 (standard-path-stencil
912 (0.0 0.8 3.0 0.8 3.0 0.4)
914 (3.0 -0.4 0.0 -0.4 0.0 0.0))
918 (define (saxophone-lh-b-cis-key-stencil flip?)
919 (standard-path-stencil
921 (0.4 1.0 0.8 0.9 1.35 0.8)
924 (* (if flip? -1 1) 0.8)
927 (define saxophone-lh-cis-key-stencil (saxophone-lh-b-cis-key-stencil #t))
929 (define saxophone-lh-b-key-stencil (saxophone-lh-b-cis-key-stencil #f))
931 (define saxophone-lh-low-bes-key-stencil
932 (standard-path-stencil
933 '((3.0 0.0) (3.0 -1.5 0.0 -1.5 0.0 0.0))
937 (define (saxophone-rh-side-key-stencil width height)
938 (standard-path-stencil
940 (0.05 ,(+ height 0.05) 0.1 ,(+ height 0.1) 0.15 ,(+ height 0.15))
941 (,(- width 0.15) ,(+ height 0.15))
949 (,(- width 0.05) -0.05 ,(- width 0.1) -0.1 ,(- width 0.15) -0.15)
951 (0.1 -0.1 0.05 -0.05 0.0 0.0))
955 (define saxophone-rh-e-key-stencil (saxophone-rh-side-key-stencil 0.9 1.2))
957 (define saxophone-rh-c-key-stencil (saxophone-rh-side-key-stencil 0.9 0.6))
959 (define saxophone-rh-bes-key-stencil (saxophone-rh-side-key-stencil 0.9 0.45))
961 (define saxophone-rh-high-fis-key-stencil
962 (standard-path-stencil
964 '((0.0 1.0) (0.0 1.4 0.6 1.4 0.6 1.0) (0.6 0.0))
968 (coord-rotate x (atan (* -1 (/ PI 6)))))
971 ((0.6 . -1.4) (0.0 . -1.4) (0.0 . -1.0))
976 (define saxophone-rh-fis-key-stencil (standard-e-stencil 1.0 0.5))
978 (define saxophone-rh-ees-key-stencil (standard-e-stencil 1.2 0.5))
980 (define saxophone-rh-low-c-key-stencil
981 (standard-path-stencil
982 '((3.0 0.0) (3.0 -1.5 0.0 -1.5 0.0 0.0))
986 (define (saxophone-lh-low-a-key-stencil radius thick fill layout props)
990 (make-general-align-markup
995 `(,(text-fill-translate fill))
999 ;;; Bassoon family stencils
1001 (define (bassoon-bend-info-maker height gap cut)
1007 `((0.0 . ,(+ height gap))
1008 (0.0 . ,(+ height (+ gap 1.0)))
1009 (1.0 . ,(+ height (+ gap 2.0)))
1010 (2.0 . ,(+ height (+ gap 2.0))))
1018 (1.0 . ,(+ 0.5 height))
1019 (1.5 . ,(+ 1.0 height))
1020 (2.0 . ,(+ 1.0 height)))
1024 `(,(list-ref first-bezier 4) . ,(list-ref first-bezier 5))
1025 `(,(list-ref first-bezier 6) . ,(list-ref first-bezier 7))))
1028 `(,(list-ref second-bezier 0) . ,(list-ref second-bezier 1))
1029 `(,(list-ref second-bezier 2) . ,(list-ref second-bezier 3)))))
1030 (list first-bezier second-bezier slope-offset1 slope-offset2)))
1033 (make-tilted-portion
1041 `((,(+ keylen (list-ref first-bezier 6))
1045 (+ keylen (list-ref first-bezier 6))) (cdr slope-offset1))))
1046 ((if bezier? (lambda (x) `(,(apply append x))) identity)
1047 `((,(+ (+ keylen 1.75) (list-ref first-bezier 6))
1051 (+ (+ keylen 1.75) (list-ref first-bezier 6)))
1052 (cdr slope-offset1)))
1053 (,(+ (+ keylen 1.75) (list-ref second-bezier 0))
1057 (+ (+ keylen 1.75) (list-ref second-bezier 0)))
1058 (cdr slope-offset2)))
1059 (,(+ keylen (list-ref second-bezier 0))
1061 (* (car slope-offset2) (+ keylen (list-ref second-bezier 0)))
1062 (cdr slope-offset2)))))
1063 `(,(list-head second-bezier 2))))
1065 (define (rich-bassoon-uber-key-stencil height gap cut keylen d1 d2 proc bezier?)
1066 (let* ((info-list (bassoon-bend-info-maker height gap cut))
1067 (first-bezier (car info-list))
1068 (second-bezier (cadr info-list))
1069 (slope-offset1 (caddr info-list))
1070 (slope-offset2 (cadddr info-list)))
1073 `((0.0 ,(+ height gap))
1074 ,(list-tail first-bezier 2))
1075 (make-tilted-portion
1082 `(,(list-tail second-bezier 2)
1089 (define (bassoon-uber-key-stencil height gap cut keylen d1 d2)
1090 (rich-bassoon-uber-key-stencil height gap cut keylen d1 d2 identity #t))
1092 (define bassoon-cc-one-key-stencil (standard-e-stencil 1.5 0.8))
1094 (define bassoon-lh-he-key-stencil little-elliptical-key-stencil)
1096 (define bassoon-lh-hees-key-stencil little-elliptical-key-stencil)
1098 (define bassoon-lh-ees-key-stencil
1102 (lambda (stencil) (ly:stencil-rotate stencil 30 0 0))))
1104 (define bassoon-lh-cis-key-stencil
1108 (lambda (stencil) (ly:stencil-rotate stencil 30 0 0))))
1110 (define bassoon-lh-lbes-key-stencil
1111 (bassoon-uber-key-stencil 1.0 0.5 0.7 0.5 0.6 -0.6))
1113 (define bassoon-lh-lb-key-stencil
1114 (bassoon-uber-key-stencil 2.0 0.5 0.9 1.2 0.6 -0.6))
1116 (define bassoon-lh-lc-key-stencil
1117 (rich-pe-stencil 1.0 1.0 135 315 identity))
1119 (define bassoon-lh-ld-key-stencil
1120 (standard-path-stencil
1121 '((-0.8 4.0 1.4 4.0 0.6 0.0)
1122 (0.5 -0.5 0.5 -0.8 0.6 -1.0)
1123 (0.7 -1.2 0.8 -1.3 0.8 -1.8)
1125 (0.5 -1.4 0.4 -1.2 0.3 -1.1)
1126 (0.2 -1.0 0.1 -0.5 0.0 0.0))
1130 (define bassoon-lh-d-flick-key-stencil
1132 (standard-path-stencil
1134 (0.2 ,(+ height 1.6) 0.8 ,(+ height 1.8) 1.0 ,(+ height 1.8))
1135 (1.4 ,(+ height 1.8) 1.9 ,(+ height 1.3) 1.9 ,(+ height 1.0))
1136 (1.9 ,(+ height 0.7) 1.0 ,(+ height 0.4) 0.8 ,(+ height 0.3))
1137 (0.6 ,(+ height 0.2) 0.4 ,(+ height 0.1) 0.4 ,(- height 0.1))
1143 (define bassoon-lh-c-flick-key-stencil
1145 (standard-path-stencil
1147 (0.0 ,(+ height 1.6) 0.4 ,(+ height 1.8) 0.5 ,(+ height 1.8))
1148 (0.7 ,(+ height 1.8) 0.9 ,(+ height 1.3) 0.9 ,(+ height 1.0))
1149 (0.9 ,(+ height 0.5) 0.7 ,(+ height 0.4) 0.6 ,(+ height 0.3))
1150 (0.5 ,(+ height 0.2) 0.4 ,(+ height 0.1) 0.4 ,(- height 0.1))
1156 (define bassoon-lh-a-flick-key-stencil
1157 (bassoon-uber-key-stencil 5.0 1.0 0.3 0.6 -0.5 -0.5))
1159 (define bassoon-lh-thumb-cis-key-stencil
1160 (bassoon-uber-key-stencil 1.5 1.5 0.6 0.6 -0.6 0.6))
1162 (define bassoon-lh-whisper-key-stencil (variable-column-circle-stencil 0.7))
1164 (define bassoon-rh-cis-key-stencil
1165 (rich-bassoon-uber-key-stencil
1172 (lambda (stencil) (ly:stencil-rotate stencil -76 0 0))
1175 (define bassoon-rh-bes-key-stencil little-elliptical-key-stencil)
1177 (define bassoon-rh-fis-key-stencil
1178 (rich-bassoon-uber-key-stencil 0.5 1.0 0.8 1.5 -0.7 0.7 identity #f))
1180 (define bassoon-rh-f-key-stencil
1181 (let* ((height 0.5) (gap 1.0) (cut 0.8) (keylen 1.5)
1182 (info-list (bassoon-bend-info-maker height gap cut))
1183 (first-bezier (car info-list))
1184 (second-bezier (cadr info-list))
1185 (slope-offset1 (caddr info-list))
1186 (slope-offset2 (cadddr info-list)))
1187 (standard-path-stencil
1194 (list-tail first-bezier 6)))
1195 (make-tilted-portion
1206 (define bassoon-rh-gis-key-stencil
1207 (bassoon-uber-key-stencil 0.3 1.0 0.8 1.0 -0.7 0.7))
1209 (define bassoon-rh-thumb-bes-key-stencil
1210 (bassoon-uber-key-stencil 1.0 1.0 0.9 1.0 0.7 0.7))
1212 (define bassoon-rh-thumb-e-key-stencil (variable-column-circle-stencil 0.7))
1214 (define bassoon-rh-thumb-fis-key-stencil
1215 (bassoon-uber-key-stencil 1.0 1.2 0.9 1.0 0.7 0.7))
1217 (define bassoon-rh-thumb-gis-key-stencil
1218 (bassoon-uber-key-stencil 1.2 0.8 0.9 0.4 0.7 0.7))