1 ;;;; figured bass support ...
3 ;;;; todo: make interfaces as 1st level objects in LilyPond.
5 (define (brew-one-figure grob fig-music)
6 "Brew a single column for a music figure"
8 (mf (ly:get-font grob '( (font-family . music) )))
9 (nf (ly:get-font grob '( (font-family . number) )))
10 (mol (ly:make-molecule '() '(0 . 0) '(0 . 1.0)))
11 (fig (ly:get-mus-property fig-music 'figure))
12 (acc (ly:get-mus-property fig-music 'alteration))
17 (set! mol (fontify-text nf (number->string fig)))
18 (ly:align-to! mol Y CENTER)
23 (ly:combine-molecule-at-edge
24 mol 0 1 (ly:find-glyph-by-name mf (string-append "accidentals-" (number->string acc)))
27 (if (ly:molecule? mol)
28 (ly:align-to! mol X CENTER)
32 (define (brew-bass-figure grob)
33 "Make a molecule for a Figured Bass grob"
35 (figs (ly:get-grob-property grob 'causes ))
36 (mol (ly:make-molecule '() '(0 . 0) '(0 . 0)))
37 (padding (ly:get-grob-property grob 'padding))
38 (kerning (ly:get-grob-property grob 'kern))
40 (ly:get-paper-variable grob 'linethickness)
41 (ly:get-grob-property grob 'thickness))
45 (define (brew-complete-figure grob figs mol)
46 "recursive function: take some stuff from FIGS, and add it to MOL."
47 (define (end-bracket? fig)
48 (eq? (ly:get-mus-property fig 'bracket-stop) #t)
53 (if (eq? (ly:get-mus-property (car figs) 'bracket-start) #t)
55 (gather-todo (take-from-list-until figs '() end-bracket?))
58 (lambda (x) (brew-one-figure grob x))
59 (reverse! (car gather-todo) '())))
60 (br-mol (bracketify-molecule
61 (stack-molecules Y UP kerning unbr-mols)
62 Y thickness (* 2 padding) padding))
65 grob (cdr gather-todo)
66 (ly:combine-molecule-at-edge mol Y UP br-mol kerning)
71 (ly:combine-molecule-at-edge mol Y UP (brew-one-figure grob (car figs))
77 (set! mol (brew-complete-figure grob (reverse figs) mol))
78 (ly:align-to! mol Y DOWN)
84 'bass-figure-interface
85 "A bass figure, including bracket"
86 '(padding thickness ))