1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 2010--2015 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 (string-concatenate (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) (,/)))}
37 (lambda (fun arg) (apply (car fun) arg (cdr fun)))
41 (define (assoc-keys alist)
42 "Gets the keys of an alist."
45 (define (assoc-values alist)
46 "Gets the values of an alist."
49 (define (get-slope-offset p1 p2)
50 "Gets the slope and offset for p1 and p2.
52 @code{(get-slope-offset '(1 . 2) '(3 . -5.1))}
53 @code{(-3.55 . 5.55)}"
55 ((slope (/ (- (cdr p1) (cdr p2)) (- (car p1) (car p2))))
56 (offset (- (cdr p1) (* slope (car p1)))))
59 (define (is-square? x input-list)
60 "Returns true if x is the square of a value in input-list."
61 (pair? (memv (inexact->exact (sqrt x)) input-list)))
63 (define (true-entry? input-list)
64 "Is there a true entry in @code{input-list}?"
65 (any identity input-list))
67 (define (entry-greater-than-x? input-list x)
68 "Is there an entry greater than @code{x} in @code{input-list}?"
69 (member x input-list <))
71 (define (n-true-entries input-list)
72 "Returns number of true entries in @code{input-list}."
73 (count identity input-list))
75 (define (bezier-head-for-stencil bezier cut-point)
76 "Prepares a split-bezier to be used in a connected path stencil."
77 (list-tail (flatten-list (car (split-bezier bezier cut-point))) 2))
79 ;; Translators for keys
81 ;; Translates a "normal" key (open, closed, trill)
82 (define (key-fill-translate fill)
86 ((= fill (expt (assoc-get 'F HOLE-FILL-LIST) 2)) 0.5)
87 ((= fill (assoc-get 'F HOLE-FILL-LIST)) #t)))
89 ;; Similar to above, but trans vs opaque doesn't matter
90 (define (text-fill-translate fill)
93 ((= fill (expt (assoc-get 'F HOLE-FILL-LIST) 2)) 0.5)
94 ((= fill (assoc-get 'F HOLE-FILL-LIST)) 0.0)))
96 ;; Emits a list for the central-column-hole maker
97 ;; (not-full?, 1-quarter-full?, 1-half-full?, 3-quarters-full?, full?)
98 ;; Multiple values, such as (#t #f #f #t #f), mean a trill between
99 ;; not-full and 3-quarters-full
100 (define (process-fill-value fill)
101 (let* ((avals (list-tail (assoc-values HOLE-FILL-LIST) 1)))
102 (append `(,(or (< fill 3) (is-square? fill avals)))
103 (map (lambda (x) (= 0 (remainder fill x))) avals))))
105 ;; Color a stencil gray
106 (define (gray-colorize stencil)
107 (apply ly:stencil-in-color stencil (x11-color 'grey)))
109 ;; A connected path stencil that is surrounded by proc
110 (define (rich-path-stencil ls x-stretch y-stretch proc)
111 (lambda (radius thick fill layout props)
113 ((fill-translate (key-fill-translate fill))
114 (gray? (eqv? fill-translate 0.5)))
116 ((if gray? gray-colorize identity)
118 (make-connected-path-stencil
124 (if gray? #t fill-translate))))
127 ((rich-path-stencil ls x-stretch y-stretch proc)
134 ;; A connected path stencil without a surrounding proc
135 (define (standard-path-stencil ls x-stretch y-stretch)
136 (rich-path-stencil ls x-stretch y-stretch identity))
138 ;; An ellipse stencil that is surrounded by a proc
139 (define (rich-pe-stencil x-stretch y-stretch start end proc)
140 (lambda (radius thick fill layout props)
142 ((fill-translate (key-fill-translate fill))
143 (gray? (eqv? fill-translate 0.5)))
145 ((if gray? gray-colorize identity)
147 (make-partial-ellipse-stencil
154 (if gray? #t fill-translate))))
157 ((rich-pe-stencil x-stretch y-stretch start end proc)
164 (define (rich-e-stencil x-stretch y-stretch proc)
165 (lambda (radius thick fill layout props)
167 ((fill-translate (key-fill-translate fill))
168 (gray? (eqv? fill-translate 0.5)))
170 ((if gray? gray-colorize identity)
172 (make-ellipse-stencil
176 (if gray? #t fill-translate))))
179 ((rich-e-stencil x-stretch y-stretch proc)
186 ;; An ellipse stencil without a surrounding proc
187 (define (standard-e-stencil x-stretch y-stretch)
188 (rich-e-stencil x-stretch y-stretch identity))
190 ;; Translates all possible representations of symbol.
191 ;; If simple? then the only representations are open, closed, and trill.
192 ;; Otherwise, there can be various levels of "closure" on the holes
193 ;; ring? allows for a ring around the holes as well
194 (define (make-symbol-alist symbol simple? ring?)
195 (delete `(,(symbol-concatenate symbol 'T 'F) .
196 ,(expt (assoc-get 'F HOLE-FILL-LIST) 2))
197 `((,symbol . ,(assoc-get 'F HOLE-FILL-LIST))
198 (,(symbol-concatenate symbol 'T) .
199 ,(expt (assoc-get 'F HOLE-FILL-LIST) 2))
204 `((,(symbol-concatenate symbol (car x) 'T)
206 (,(symbol-concatenate symbol 'T (car x))
207 . ,(* (cdr x) (assoc-get 'F HOLE-FILL-LIST)))
208 (,(symbol-concatenate symbol (car x))
213 `(,(symbol-concatenate symbol
217 . ,(* (cdr a) (cdr b))))
219 (cdr (member x HOLE-FILL-LIST)))))
220 (if ring? HOLE-FILL-LIST (cdr HOLE-FILL-LIST)))))))
222 ;;; Commands for text layout
224 ;; Draws a circle around markup if (= trigger 0.5)
225 (define-markup-command
226 (conditional-circle-markup layout props trigger in-markup)
228 (interpret-markup layout props
229 (if (eqv? trigger 0.5)
230 (markup #:circle (markup in-markup))
231 (markup in-markup))))
233 ;; Makes a list of named-keys
234 (define (make-name-keylist input-list key-list font-size)
237 (markup #:conditional-circle-markup
241 (markup #:abs-fontsize font-size (car y))
242 (if (and (< x 1) (cdr y))
262 input-list key-list))
264 ;; Makes a list of number-keys
265 (define (make-number-keylist input-list key-list font-size)
269 #:conditional-circle-markup
271 (markup #:abs-fontsize font-size #:number y))
276 ;; Creates a named-key list with a certain alignment
277 (define (aligned-text-stencil-function dir hv)
278 (lambda (key-name-list radius fill-list layout props)
282 (make-general-align-markup
285 ((if hv make-concat-markup make-center-column-markup)
287 (map text-fill-translate fill-list)
291 (define number-column-stencil
292 (lambda (key-name-list radius fill-list layout props)
296 (make-general-align-markup
299 (make-general-align-markup
302 (make-override-markup
306 (map text-fill-translate fill-list)
310 ;; Utility function for the left-hand keys
311 (define lh-woodwind-text-stencil
312 (aligned-text-stencil-function LEFT #t))
314 ;; Utility function for the right-hand keys
315 (define rh-woodwind-text-stencil
316 (aligned-text-stencil-function RIGHT #t))
318 (define octave-woodwind-text-stencil
319 (aligned-text-stencil-function CENTER #f))
323 (define (rich-group-draw-rule alist target-part change-part)
325 (entry-greater-than-x?
326 (map (lambda (key) (assoc-get key alist)) target-part) 3)
327 (map-selected-alist-keys (lambda (x) (if (= x 0) 1 x)) change-part alist)
330 (define (bassoon-midline-rule alist target-part)
332 (entry-greater-than-x?
333 (map (lambda (key) (assoc-get key alist)) target-part) 0)
334 (map-selected-alist-keys (lambda (x) 1) '((hidden . long-midline)) alist)
335 (map-selected-alist-keys (lambda (x) 1) '((hidden . midline)) alist)))
337 (define (group-draw-rule alist target-part)
338 (rich-group-draw-rule alist target-part target-part))
340 (define (group-automate-rule alist change-part)
341 (map-selected-alist-keys (lambda (x) (if (= x 0) 1 x)) change-part alist))
343 (define (apply-group-draw-rule-series alist target-part-list)
344 (if (null? target-part-list)
346 (apply-group-draw-rule-series
347 (group-draw-rule alist (car target-part-list))
348 (cdr target-part-list))))
350 ;; Extra-offset rules
352 (define (rich-group-extra-offset-rule alist target-part change-part eos)
354 (entry-greater-than-x?
355 (map (lambda (key) (assoc-get key alist)) target-part) 0)
356 (map-selected-alist-keys (lambda (x) eos) change-part alist)
359 (define (group-extra-offset-rule alist target-part eos)
360 (rich-group-extra-offset-rule alist target-part target-part eos))
362 (define (uniform-extra-offset-rule alist eos)
363 (map-selected-alist-keys
364 (lambda (x) (if (pair? x) x eos))
368 ;;; General drawing commands
370 ;; Used all the time for a dividing line
371 (define (midline-stencil radius thick fill layout props)
372 (make-line-stencil (* thick 2) (* -0.80 radius) 0 (* 0.80 radius) 0))
374 (define (long-midline-stencil radius thick fill layout props)
375 (make-line-stencil (* thick 2) (* -5.75 radius) 0 (* 0.75 radius) 0))
377 ;; Used all the time for a small, between-hole key
378 (define little-elliptical-key-stencil (standard-e-stencil 0.75 0.2))
380 ;; Used for several upper keys in the clarinet and sax
381 (define (upper-key-stencil tailw tailh bodyw bodyh)
383 ((xmove (lambda (x) (+ tailw (+ 0.2 (* bodyw (- x 0.2))))))
384 (ymove (lambda (x) (+ (- tailh) (+ -0.05 (* bodyh (+ x 0.05)))))))
385 (standard-path-stencil
401 ,(- -0.025 (/ tailh 2))
407 ;; Utility function for the column-hole maker.
408 ;; Returns the left and right degrees for the drawing of a given
409 ;; fill level (1-quarter, 1-half, etc...)
410 (define (degree-first-true fill-list left? reverse?)
411 (define (dfl-crawler fill-list os-list left?)
413 ((if left? car cdr) (car os-list))
414 (dfl-crawler (cdr fill-list) (cdr os-list) left?)))
416 ((if reverse? reverse identity) fill-list)
417 ((if reverse? reverse identity)
418 '((0 . 0) (215 . 325) (180 . 0) (145 . 35) (90 . 90)))
421 ;; Gets the position of the first (or last if reverse?) element of a list.
422 (define (position-true-endpoint in-list reverse?)
423 (define (pte-crawler in-list n)
426 (pte-crawler (cdr in-list) (+ n 1))))
428 (if reverse? (length in-list) 0)
429 (pte-crawler ((if reverse? reverse identity) in-list) 0)))
431 ;; Huge, kind-of-ugly maker of a circle in a column.
432 ;; I think this is the clearest way to write it, though...
434 (define (column-circle-stencil radius thick fill layout props)
435 (let* ((fill-list (process-fill-value fill)))
438 (list-ref fill-list 0)
439 (not (true-entry? (list-tail fill-list 1)))) ; is it empty?
440 ((standard-e-stencil 1.0 1.0) radius thick fill layout props))
442 (list-ref fill-list 4)
443 (not (true-entry? (list-head fill-list 4)))) ; is it full?
444 ((standard-e-stencil 1.0 1.0) radius thick fill layout props))
446 (list-ref fill-list 0)
447 (list-ref fill-list 4)) ; is it a trill between empty and full?
448 ((standard-e-stencil 1.0 1.0) radius thick fill layout props))
449 (else ;If none of these, it is partially full.
451 ((rich-pe-stencil 1.0 1.0 0 360 identity)
454 (if (list-ref fill-list 4)
455 (expt (assoc-get 'F HOLE-FILL-LIST) 2)
462 (degree-first-true fill-list #t #t)
463 (degree-first-true fill-list #f #t)
469 (list-head fill-list (position-true-endpoint fill-list #t)))
470 (expt (assoc-get 'F HOLE-FILL-LIST) 2)
471 (assoc-get 'F HOLE-FILL-LIST))
475 (= 2 (n-true-entries (list-tail fill-list 1))) ; trill?
479 (degree-first-true fill-list #t #f)
480 (degree-first-true fill-list #f #f)
484 (assoc-get 'F HOLE-FILL-LIST)
489 (define (variable-column-circle-stencil scaler)
490 (lambda (radius thick fill layout props)
491 (column-circle-stencil (* radius scaler) thick fill layout props)))
493 ;; A stencil for ring-column circles that combines two of the above
494 (define (ring-column-circle-stencil radius thick fill layout props)
495 (if (= 0 (remainder fill (assoc-get 'R HOLE-FILL-LIST)))
498 (= fill (expt (assoc-get 'R HOLE-FILL-LIST) 2))
502 (* (+ (- 1.0 (* 2 thick)) (/ thick 2)))
503 (* (+ (- 1.0 (* 2 thick)) (/ thick 2))))
505 (* (* 4 radius) thick)
509 ((standard-e-stencil 1.0 1.0) radius thick 1 layout props)
510 (column-circle-stencil
511 (+ (* (- 1.0 (* 4 thick)) radius) (/ thick 2))
514 (if (= 0 (remainder fill (assoc-get 'F HOLE-FILL-LIST)))
515 (assoc-get 'F HOLE-FILL-LIST)
517 (if (= fill (expt (assoc-get 'R HOLE-FILL-LIST) 2))
518 (/ fill (expt (assoc-get 'R HOLE-FILL-LIST) 2))
519 (/ fill (assoc-get 'R HOLE-FILL-LIST))))
522 (column-circle-stencil radius thick fill layout props)))
524 ;;; Flute family stencils
526 (define flute-lh-b-key-stencil
527 (standard-path-stencil
529 (0 1.625 -0.125 1.75 -0.25 1.75)
530 (-0.55 1.75 -0.55 0.95 -0.25 0.7)
535 (define flute-lh-bes-key-stencil
536 (standard-path-stencil
538 (0 1.625 -0.125 1.75 -0.25 1.75)
539 (-0.55 1.75 -0.55 0.95 -0.25 0.7)
544 (define (flute-lh-gis-rh-bes-key-stencil deg)
546 '((0.1 0.1 0.2 0.4 0.3 0.6)
547 (0.3 1.0 0.8 1.0 0.8 0.7)
548 (0.8 0.3 0.5 0.3 0 0))
551 (lambda (stencil) (ly:stencil-rotate stencil deg 0 0))))
553 (define flute-lh-gis-key-stencil (flute-lh-gis-rh-bes-key-stencil 0))
555 (define flute-rh-bes-key-stencil (flute-lh-gis-rh-bes-key-stencil 200))
557 (define flute-rh-d-key-stencil little-elliptical-key-stencil)
559 (define flute-rh-dis-key-stencil little-elliptical-key-stencil)
561 (define flute-rh-ees-key-stencil
562 (standard-path-stencil
563 '((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))
567 (define (piccolo-rh-x-key-stencil radius thick fill layout props)
571 (make-general-align-markup
576 `(,(text-fill-translate fill))
580 (define flute-lower-row-stretch 1.4)
582 (define flute-rh-cis-key-stencil
583 (standard-path-stencil
584 '((0 0.75) (-0.8 0.75 -0.8 0 0 0))
585 flute-lower-row-stretch
586 flute-lower-row-stretch))
588 (define flute-rh-c-key-stencil
589 (standard-path-stencil
590 '((0 0.75) (0.4 0.75) (0.4 0) (0 0))
591 flute-lower-row-stretch
592 flute-lower-row-stretch))
594 (define flute-rh-b-key-stencil
595 (standard-path-stencil
596 '((0 0.75) (0.25 0.75) (0.25 0) (0 0))
597 flute-lower-row-stretch
598 flute-lower-row-stretch))
600 (define flute-rh-gz-key-stencil
602 '((0.1 0.1 0.4 0.2 0.6 0.3)
603 (1.0 0.3 1.0 0.8 0.7 0.8)
604 (0.3 0.8 0.3 0.5 0 0))
605 flute-lower-row-stretch
606 flute-lower-row-stretch
607 (lambda (stencil) (ly:stencil-rotate stencil 160 0 0))))
609 ;;; Shared oboe/clarinet stencils
611 (define (oboe-lh-gis-lh-low-b-key-stencil gis?)
619 `((0.0 . 0.0) (0.0 . ,y) (,x . ,y) (,x . 0.0))
624 `((,x . 0.0) (,x . ,(- y)) (0.0 . ,(- y)) (0.0 . 0.0))
627 (standard-path-stencil
630 `((0.25 ,(/ y -2) 0.75 ,(/ y -2) 1.0 0.0))
635 (coord-rotated x (cons y (* 2 0.25)))
638 `(((0 . ,y) (,x . ,y) (,x . 0))
639 ((,x . ,(- y)) (0 . ,(- y)) (0 . 0)))))
640 `((0.75 ,(/ y -2) 0.25 ,(/ y -2) 0.0 0.0)))
643 (standard-path-stencil
647 (coord-rotated x (cons y (* 2 0.25))))
649 `(,(list-tail up-part 1)
650 ,(list-head down-part 1)
651 ,(list-tail down-part 1)))
653 (- scaling-factor)))))
655 (define oboe-lh-gis-key-stencil (oboe-lh-gis-lh-low-b-key-stencil #t))
657 (define oboe-lh-low-b-key-stencil (oboe-lh-gis-lh-low-b-key-stencil #f))
659 (define (oboe-lh-ees-lh-bes-key-stencil ees?)
660 (standard-path-stencil
662 (0 1.625 -0.125 1.75 -0.25 1.75)
663 (-0.5 1.75 -0.5 0.816 -0.25 0.5)
665 (0 ,(if ees? -0.6 -0.3)))
666 (* (if ees? -1.0 1.0) -1.8)
669 (define oboe-lh-ees-key-stencil (oboe-lh-ees-lh-bes-key-stencil #t))
671 (define oboe-lh-bes-key-stencil (oboe-lh-ees-lh-bes-key-stencil #f))
673 ;;; Oboe family stencils
675 (define (oboe-lh-octave-key-stencil long?)
676 (let* ((h (if long? 1.4 1.2)))
677 (standard-path-stencil
678 `((-0.4 0 -0.4 1.0 -0.1 1.0)
686 (define oboe-lh-I-key-stencil (oboe-lh-octave-key-stencil #f))
688 (define oboe-lh-II-key-stencil (oboe-lh-octave-key-stencil #f))
690 (define oboe-lh-III-key-stencil (oboe-lh-octave-key-stencil #t))
692 (define oboe-lh-b-key-stencil (standard-e-stencil 0.6 0.8))
694 (define oboe-lh-d-key-stencil little-elliptical-key-stencil)
696 (define oboe-lh-cis-key-stencil little-elliptical-key-stencil)
698 (define oboe-lh-f-key-stencil (standard-e-stencil 0.5 1.0))
700 (define oboe-rh-a-key-stencil (standard-e-stencil 1.0 0.45))
702 (define oboe-rh-gis-key-stencil (standard-e-stencil 0.45 1.2))
704 (define oboe-rh-d-key-stencil little-elliptical-key-stencil)
706 (define oboe-rh-f-key-stencil little-elliptical-key-stencil)
708 (define (oboe-rh-c-rh-ees-key-stencil c?)
710 '((1.0 0.0 1.0 0.70 1.5 0.70)
711 (2.25 0.70 2.25 -0.4 1.5 -0.4)
716 (lambda (stencil) (ly:stencil-rotate stencil (if c? 170 180) 0 0))))
718 (define oboe-rh-banana-key-stencil oboe-rh-gis-key-stencil)
720 (define oboe-rh-c-key-stencil (oboe-rh-c-rh-ees-key-stencil #t))
722 (define oboe-rh-cis-key-stencil
724 '((0.6 0.0 0.6 0.50 1.25 0.50)
725 (2.25 0.50 2.25 -0.4 1.25 -0.4)
726 (0.6 -0.4 0.6 0 0 0))
729 (lambda (stencil) (ly:stencil-rotate stencil 0 0 0))))
731 (define oboe-rh-ees-key-stencil (oboe-rh-c-rh-ees-key-stencil #f))
733 ;;; Clarinet family stencils
735 (define clarinet-lh-thumb-key-stencil
736 (variable-column-circle-stencil 0.9))
738 (define clarinet-lh-R-key-stencil
739 (let* ((halfbase (cos (/ PI 10)))
742 (/ (sin (/ (* 4 PI) 10)) (cos (/ (* 4 PI) 10))))))
743 (standard-path-stencil
745 (0 ,(/ -4.0 3.0) -2.0 ,(/ -4.0 3.0) -2.0 0.0)
746 (-1.5 ,(* 0.5 height) -1.25 ,(* 0.75 height) -1.0 ,height)
747 (-0.75 ,(* 0.75 height) -0.5 ,(* 0.5 height) 0.0 0.0))
751 (define (clarinet-lh-a-key-stencil radius thick fill layout props)
752 (let* ((width 0.4) (height 0.75) (linelen 0.45))
754 ((standard-e-stencil width height) radius thick fill layout props)
755 (ly:stencil-translate
756 (make-line-stencil thick 0 0 0 (* linelen radius))
757 (cons 0 (* height radius))))))
759 (define clarinet-lh-gis-key-stencil (upper-key-stencil 0.0 0.0 1.3 2.0))
761 (define clarinet-lh-ees-key-stencil little-elliptical-key-stencil)
763 (define clarinet-lh-cis-key-stencil oboe-lh-gis-key-stencil)
765 (define clarinet-lh-f-key-stencil oboe-lh-low-b-key-stencil)
767 (define clarinet-lh-e-key-stencil oboe-lh-ees-key-stencil)
769 (define clarinet-lh-fis-key-stencil oboe-lh-bes-key-stencil)
771 (define clarinet-lh-d-key-stencil (standard-e-stencil 1.0 0.4))
773 (define clarinet-rh-low-c-key-stencil
774 (standard-path-stencil
776 (0.0 2.5 -1.0 2.5 -1.0 0.75)
777 (-1.0 0.1 0.0 0.25 0.0 0.3)
782 (define clarinet-rh-low-cis-key-stencil
783 (standard-path-stencil
785 (0.0 1.67 -1.0 1.67 -1.0 0.92)
786 (-1.0 0.47 0.0 0.52 0.0 0.62)
791 (define clarinet-rh-low-d-key-stencil
792 (standard-path-stencil
794 (0.0 1.55 -1.0 1.55 -1.0 0.8)
795 (-1.0 0.35 0.0 0.4 0.0 0.5)
800 (define clarinet-rh-one-key-stencil (standard-e-stencil 0.5 0.25))
802 (define clarinet-rh-two-key-stencil clarinet-rh-one-key-stencil)
804 (define clarinet-rh-three-key-stencil clarinet-rh-one-key-stencil)
806 (define clarinet-rh-four-key-stencil clarinet-rh-one-key-stencil)
808 (define clarinet-rh-b-key-stencil little-elliptical-key-stencil)
811 (define CL-RH-HAIR 0.09)
812 (define CL-RH-H-STRETCH 2.7)
813 (define CL-RH-V-STRETCH 0.9)
816 ;; there is some unnecessary information duplication here.
817 ;; need a way to control all of the below stencils so that if one
818 ;; changes, all change...
820 (define clarinet-rh-fis-key-stencil
821 (standard-path-stencil
822 `(,(bezier-head-for-stencil
823 '((0.0 . 0.0) (0.0 . -1.0) (1.0 . -1.0) (1.0 . 0.0))
825 ,(bezier-head-for-stencil
826 '((0.5 . -0.75) (0.5 . 0.25) (1.5 . 0.25) (1.5 . -0.75))
828 (1.0 1.0 0.0 1.0 0.0 0.0))
832 (define clarinet-rh-gis-key-stencil
833 (standard-path-stencil
834 '((0.0 1.0 1.0 1.0 1.0 0.0) (1.0 -1.0 0.0 -1.0 0.0 0.0))
838 (define clarinet-rh-e-key-stencil
839 (standard-path-stencil
840 `(,(bezier-head-for-stencil
841 '((0.0 . 0.0) (0.0 . -1.0) (1.0 . -1.0) (1.0 . 0.0))
843 ,(bezier-head-for-stencil
844 '((0.5 . -0.75) (0.5 . 0.25) (1.5 . 0.25) (1.5 . -0.75))
846 ,(bezier-head-for-stencil
847 `((1.0 . 0.0) (,(/ 1 3) . 0.0) (,(/ 1 3) . 1.5) (1.0 . 1.5))
849 ,(bezier-head-for-stencil
850 `((0.5 . 0.75) (,(/ -1 6) . 0.75) (,(/ -1 6) . -0.75) (0.5 . -0.75))
855 (define clarinet-rh-f-key-stencil clarinet-rh-gis-key-stencil)
857 (define bass-clarinet-rh-ees-key-stencil
858 (standard-path-stencil
859 `(,(bezier-head-for-stencil
860 '((0.0 . 0.0) (0.0 . -1.0) (1.0 . -1.0) (1.0 . 0.0))
862 ,(bezier-head-for-stencil
863 '((0.5 . -0.75) (0.5 . 0.25) (1.5 . 0.25) (1.5 . -0.75))
865 (1.0 1.0 0.0 1.0 0.0 0.0))
867 (- CL-RH-V-STRETCH)))
869 (define low-bass-clarinet-rh-ees-key-stencil clarinet-rh-e-key-stencil)
871 (define clarinet-rh-d-key-stencil clarinet-rh-gis-key-stencil)
873 ;;; Saxophone family stencils
875 (define saxophone-lh-ees-key-stencil (upper-key-stencil 0.0 0.0 1.3 2.0))
877 (define saxophone-lh-f-key-stencil (upper-key-stencil 0.0 0.0 1.3 2.0))
879 (define saxophone-lh-d-key-stencil (upper-key-stencil 0.0 0.0 1.3 2.0))
881 (define saxophone-lh-front-f-key-stencil (standard-e-stencil 0.7 0.7))
883 (define saxophone-lh-bes-key-stencil (standard-e-stencil 0.5 0.5))
885 (define saxophone-lh-T-key-stencil (standard-e-stencil 0.75 0.75))
887 (define saxophone-lh-gis-key-stencil
888 (standard-path-stencil
890 (0.0 0.8 3.0 0.8 3.0 0.4)
892 (3.0 -0.4 0.0 -0.4 0.0 0.0))
896 (define (saxophone-lh-b-cis-key-stencil flip?)
897 (standard-path-stencil
899 (0.4 1.0 0.8 0.9 1.35 0.8)
902 (* (if flip? -1 1) 0.8)
905 (define saxophone-lh-cis-key-stencil (saxophone-lh-b-cis-key-stencil #t))
907 (define saxophone-lh-b-key-stencil (saxophone-lh-b-cis-key-stencil #f))
909 (define saxophone-lh-low-bes-key-stencil
910 (standard-path-stencil
911 '((3.0 0.0) (3.0 -1.5 0.0 -1.5 0.0 0.0))
915 (define (saxophone-rh-side-key-stencil width height)
916 (standard-path-stencil
918 (0.05 ,(+ height 0.05) 0.1 ,(+ height 0.1) 0.15 ,(+ height 0.15))
919 (,(- width 0.15) ,(+ height 0.15))
927 (,(- width 0.05) -0.05 ,(- width 0.1) -0.1 ,(- width 0.15) -0.15)
929 (0.1 -0.1 0.05 -0.05 0.0 0.0))
933 (define saxophone-rh-e-key-stencil (saxophone-rh-side-key-stencil 0.9 1.2))
935 (define saxophone-rh-c-key-stencil (saxophone-rh-side-key-stencil 0.9 0.6))
937 (define saxophone-rh-bes-key-stencil (saxophone-rh-side-key-stencil 0.9 0.45))
939 (define saxophone-rh-high-fis-key-stencil
940 (standard-path-stencil
942 (dir2 (ly:directed (* -0.5 angle)))
943 ;; This comparatively awful expression calculates how far
944 ;; along the tangents opened by 'angle' with a radius of 0.6
945 ;; the control points need to move in order to have the
946 ;; middle of the bezier curve exactly on radius.
947 (out (* 0.6 (coord-y dir2) (- 4/3 (* 1/3 (coord-x dir2))))))
949 '((0.0 1.0) (0.0 1.4 0.6 1.4 0.6 1.0) (0.6 0.0))
951 ,@(flatten-list (map (lambda (x) (coord-rotated x angle))
957 (coord-rotated x angle))
960 ((0.6 . -1.4) (0.0 . -1.4) (0.0 . -1.0))
965 (define saxophone-rh-fis-key-stencil (standard-e-stencil 1.0 0.5))
967 (define saxophone-rh-ees-key-stencil (standard-e-stencil 1.2 0.5))
969 (define saxophone-rh-low-c-key-stencil
970 (standard-path-stencil
971 '((3.0 0.0) (3.0 -1.5 0.0 -1.5 0.0 0.0))
975 (define (saxophone-lh-low-a-key-stencil radius thick fill layout props)
979 (make-general-align-markup
984 `(,(text-fill-translate fill))
988 ;;; Bassoon family stencils
990 (define (bassoon-bend-info-maker height gap cut)
996 `((0.0 . ,(+ height gap))
997 (0.0 . ,(+ height (+ gap 1.0)))
998 (1.0 . ,(+ height (+ gap 2.0)))
999 (2.0 . ,(+ height (+ gap 2.0))))
1007 (1.0 . ,(+ 0.5 height))
1008 (1.5 . ,(+ 1.0 height))
1009 (2.0 . ,(+ 1.0 height)))
1013 `(,(list-ref first-bezier 4) . ,(list-ref first-bezier 5))
1014 `(,(list-ref first-bezier 6) . ,(list-ref first-bezier 7))))
1017 `(,(list-ref second-bezier 0) . ,(list-ref second-bezier 1))
1018 `(,(list-ref second-bezier 2) . ,(list-ref second-bezier 3)))))
1019 (list first-bezier second-bezier slope-offset1 slope-offset2)))
1022 (make-tilted-portion
1030 `((,(+ keylen (list-ref first-bezier 6))
1034 (+ keylen (list-ref first-bezier 6))) (cdr slope-offset1))))
1035 ((if bezier? (lambda (x) `(,(concatenate x))) identity)
1036 `((,(+ (+ keylen 1.75) (list-ref first-bezier 6))
1040 (+ (+ keylen 1.75) (list-ref first-bezier 6)))
1041 (cdr slope-offset1)))
1042 (,(+ (+ keylen 1.75) (list-ref second-bezier 0))
1046 (+ (+ keylen 1.75) (list-ref second-bezier 0)))
1047 (cdr slope-offset2)))
1048 (,(+ keylen (list-ref second-bezier 0))
1050 (* (car slope-offset2) (+ keylen (list-ref second-bezier 0)))
1051 (cdr slope-offset2)))))
1052 `(,(list-head second-bezier 2))))
1054 (define (rich-bassoon-uber-key-stencil height gap cut keylen d1 d2 proc bezier?)
1055 (let* ((info-list (bassoon-bend-info-maker height gap cut))
1056 (first-bezier (car info-list))
1057 (second-bezier (cadr info-list))
1058 (slope-offset1 (caddr info-list))
1059 (slope-offset2 (cadddr info-list)))
1062 `((0.0 ,(+ height gap))
1063 ,(list-tail first-bezier 2))
1064 (make-tilted-portion
1071 `(,(list-tail second-bezier 2)
1078 (define (bassoon-uber-key-stencil height gap cut keylen d1 d2)
1079 (rich-bassoon-uber-key-stencil height gap cut keylen d1 d2 identity #t))
1081 (define bassoon-cc-one-key-stencil (standard-e-stencil 1.5 0.8))
1083 (define bassoon-lh-he-key-stencil little-elliptical-key-stencil)
1085 (define bassoon-lh-hees-key-stencil little-elliptical-key-stencil)
1087 (define bassoon-lh-ees-key-stencil
1091 (lambda (stencil) (ly:stencil-rotate stencil 30 0 0))))
1093 (define bassoon-lh-cis-key-stencil
1097 (lambda (stencil) (ly:stencil-rotate stencil 30 0 0))))
1099 (define bassoon-lh-lbes-key-stencil
1100 (bassoon-uber-key-stencil 1.0 0.5 0.7 0.5 0.6 -0.6))
1102 (define bassoon-lh-lb-key-stencil
1103 (bassoon-uber-key-stencil 2.0 0.5 0.9 1.2 0.6 -0.6))
1105 (define bassoon-lh-lc-key-stencil
1106 (rich-pe-stencil 1.0 1.0 135 315 identity))
1108 (define bassoon-lh-ld-key-stencil
1109 (standard-path-stencil
1110 '((-0.8 4.0 1.4 4.0 0.6 0.0)
1111 (0.5 -0.5 0.5 -0.8 0.6 -1.0)
1112 (0.7 -1.2 0.8 -1.3 0.8 -1.8)
1114 (0.5 -1.4 0.4 -1.2 0.3 -1.1)
1115 (0.2 -1.0 0.1 -0.5 0.0 0.0))
1119 (define bassoon-lh-d-flick-key-stencil
1121 (standard-path-stencil
1123 (0.2 ,(+ height 1.6) 0.8 ,(+ height 1.8) 1.0 ,(+ height 1.8))
1124 (1.4 ,(+ height 1.8) 1.9 ,(+ height 1.3) 1.9 ,(+ height 1.0))
1125 (1.9 ,(+ height 0.7) 1.0 ,(+ height 0.4) 0.8 ,(+ height 0.3))
1126 (0.6 ,(+ height 0.2) 0.4 ,(+ height 0.1) 0.4 ,(- height 0.1))
1132 (define bassoon-lh-c-flick-key-stencil
1134 (standard-path-stencil
1136 (0.0 ,(+ height 1.6) 0.4 ,(+ height 1.8) 0.5 ,(+ height 1.8))
1137 (0.7 ,(+ height 1.8) 0.9 ,(+ height 1.3) 0.9 ,(+ height 1.0))
1138 (0.9 ,(+ height 0.5) 0.7 ,(+ height 0.4) 0.6 ,(+ height 0.3))
1139 (0.5 ,(+ height 0.2) 0.4 ,(+ height 0.1) 0.4 ,(- height 0.1))
1145 (define bassoon-lh-a-flick-key-stencil
1146 (bassoon-uber-key-stencil 5.0 1.0 0.3 0.6 -0.5 -0.5))
1148 (define bassoon-lh-thumb-cis-key-stencil
1149 (bassoon-uber-key-stencil 1.5 1.5 0.6 0.6 -0.6 0.6))
1151 (define bassoon-lh-whisper-key-stencil (variable-column-circle-stencil 0.7))
1153 (define bassoon-rh-cis-key-stencil
1154 (rich-bassoon-uber-key-stencil
1161 (lambda (stencil) (ly:stencil-rotate stencil -76 0 0))
1164 (define bassoon-rh-bes-key-stencil little-elliptical-key-stencil)
1166 (define bassoon-rh-fis-key-stencil
1167 (rich-bassoon-uber-key-stencil 0.5 1.0 0.8 1.5 -0.7 0.7 identity #f))
1169 (define bassoon-rh-f-key-stencil
1170 (let* ((height 0.5) (gap 1.0) (cut 0.8) (keylen 1.5)
1171 (info-list (bassoon-bend-info-maker height gap cut))
1172 (first-bezier (car info-list))
1173 (second-bezier (cadr info-list))
1174 (slope-offset1 (caddr info-list))
1175 (slope-offset2 (cadddr info-list)))
1176 (standard-path-stencil
1183 (apply circular-list (list-tail first-bezier 6))))
1184 (make-tilted-portion
1195 (define bassoon-rh-gis-key-stencil
1196 (bassoon-uber-key-stencil 0.3 1.0 0.8 1.0 -0.7 0.7))
1198 (define bassoon-rh-thumb-bes-key-stencil
1199 (bassoon-uber-key-stencil 1.0 1.0 0.9 1.0 0.7 0.7))
1201 (define bassoon-rh-thumb-e-key-stencil (variable-column-circle-stencil 0.7))
1203 (define bassoon-rh-thumb-fis-key-stencil
1204 (bassoon-uber-key-stencil 1.0 1.2 0.9 1.0 0.7 0.7))
1206 (define bassoon-rh-thumb-gis-key-stencil
1207 (bassoon-uber-key-stencil 1.2 0.8 0.9 0.4 0.7 0.7))