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 (cons '((font-family . music))
9 Font_interface::get_property_alist_chain
12 (cons '((font-family . number))
13 Font_interface::get_property_alist_chain)))
14 (mol (ly:make-molecule '() '(0 . 0) '(0 . 1.0)))
15 (fig (ly:get-mus-property fig-music 'figure))
16 (acc (ly:get-mus-property fig-music 'alteration))
21 (set! mol (fontify-text nf (number->string fig)))
22 (ly:molecule-align-to! mol Y CENTER)
27 (ly:molecule-combine-at-edge
28 mol X RIGHT (ly:find-glyph-by-name mf (string-append "accidentals-" (number->string acc)))
31 (if (ly:molecule? mol)
32 (ly:molecule-align-to! mol X CENTER)
36 (define (brew-bass-figure grob)
37 "Make a molecule for a Figured Bass grob"
39 (figs (ly:get-grob-property grob 'causes ))
40 (mol (ly:make-molecule '() '(0 . 0) '(0 . 0)))
41 (padding (ly:get-grob-property grob 'padding))
42 (kerning (ly:get-grob-property grob 'kern))
44 (ly:get-paper-variable grob 'linethickness)
45 (ly:get-grob-property grob 'thickness))
47 (dir (ly:get-grob-property grob 'direction))
50 (define (brew-complete-figure grob figs mol)
51 "recursive function: take some stuff from FIGS, and add it to MOL."
52 (define (end-bracket? fig)
53 (eq? (ly:get-mus-property fig 'bracket-stop) #t)
58 (if (eq? (ly:get-mus-property (car figs) 'bracket-start) #t)
60 (gather-todo (take-from-list-until figs '() end-bracket?))
63 (lambda (x) (brew-one-figure grob x))
64 (reverse! (car gather-todo) '())))
65 (br-mol (bracketify-molecule
66 (stack-molecules Y dir kerning unbr-mols)
67 Y thickness (* 2 padding) padding))
70 grob (cdr gather-todo)
71 (ly:molecule-combine-at-edge mol Y dir br-mol kerning)
76 (ly:molecule-combine-at-edge mol Y dir (brew-one-figure grob (car figs))
82 (set! mol (brew-complete-figure grob (reverse figs) mol))
83 (ly:molecule-align-to! mol Y (- dir))
89 'bass-figure-interface
90 "A bass figure, including bracket"
91 '(padding thickness direction))