Hello Christophe, > Hello all, > > is there any way to have the mensural accidentals in the figures bass? > > Is there a convenient way to do this?
that is indeed possible. In fact you can provide any logic you want for the
bass figures by setting the `figuredBassFormatter` property to any function of
signature (fn figure event context) -> markup. I have seen you are using
ancient 2.18, and the oldest version I have lying around is 2.20, so I am not
sure if this works exactly in 2.18, but what I have done here is that I have
taken the default formatter from 2.26 and changed the accidental formatting
from
selecting unicode characters for accidentals to using \musicglyph markups for
accidentals:
%%%
#(define figbass-accidental-alist-mensural
`((1/2
. ,(make-general-align-markup
#(define figbass-accidental-alist-mensural
`((1/2
. ,(make-general-align-markup
Y -2
(make-musicglyph-markup "accidentals.mensural1")))
(-1/2
. ,(make-general-align-markup
Y -1.3 (make-musicglyph-markup "accidentals.mensuralM1")))))
#(define (format-bass-figure-mensural figure event context)
(let* (;; User properties controlling the figured bass layout.
(large-number-alignment
(ly:context-property context 'figuredBassLargeNumberAlignment))
(figbass-alist
(ly:context-property context 'figuredBassPlusStrokedAlist))
(alt-dir
(ly:context-property context 'figuredBassAlterationDirection))
(plus-dir
(ly:context-property context 'figuredBassPlusDirection))
(augmented (ly:event-property event 'augmented))
(number-one (make-number-markup "1"))
;; The digit(s), horizontally positioned, or #f.
(fig-markup
(if (number? figure)
((if (<= 10 figure)
(lambda (y)
(make-align-on-other-markup
X
large-number-alignment number-one
large-number-alignment y))
identity)
(cond
((eq? #t (ly:event-property event 'diminished))
(make-slashed-digit-markup figure))
((eq? #t (ly:event-property event 'augmented-slash))
;; Use specially stroked digit if available and wanted.
(or (and-let* (((<= 6 figure 9))
(glyph (assv-ref figbass-alist figure)))
(make-musicglyph-markup glyph))
(make-backslashed-digit-markup figure)))
((eq? #t augmented)
;; Use special digit with plus if available and wanted.
(or (and-let* (((>= 5 figure 2))
((eqv? plus-dir RIGHT))
(glyph (assv-ref figbass-alist figure)))
(set! augmented #f)
(make-musicglyph-markup glyph))
(make-number-markup (number->string figure 10))))
(else (make-number-markup (number->string figure 10)))))
#f))
(alt (ly:event-property event 'alteration))
(alt-bracket (ly:event-property event 'alteration-bracket #f))
;; The alteration, probably bracketed but not positioned yet,
;; or #f.
(alt-markup
(if (number? alt)
(let* ((acc (assoc-get alt figbass-accidental-alist-mensural))
(acc-markup
(if acc
acc
(begin
(ly:warning
(G_ "no accidental glyph found for alteration ~a")
alt)
;; fallback
"?"))))
(if alt-bracket
(make-bracket-markup acc-markup)
acc-markup))
#f))
(plus-markup (if (eq? #t augmented)
(make-number-markup "+")
#f)))
(if (and (not alt-markup) alt-bracket)
(ly:programming-error
"Cannot put brackets around non-existent bass figure alteration."))
;; We treat a solitary alteration similarly to digits.
(if (and (not fig-markup) alt-markup)
(begin
(set! fig-markup
(make-align-on-other-markup
X
CENTER number-one
CENTER alt-markup))
(set! alt-markup #f)))
;; We treat a solitary plus similarly to digits (but enlarged).
(if (and (not fig-markup) plus-markup)
(begin
(set! fig-markup
(make-align-on-other-markup
Y
CENTER number-one
CENTER (make-align-on-other-markup
X
CENTER number-one
CENTER (make-fontsize-markup 3 plus-markup))))
(set! plus-markup #f)))
;; The alteration gets attached either to the left or the right of
;; the digit(s).
(if alt-markup
(set! fig-markup
(make-put-adjacent-markup
X (if (number? alt-dir)
alt-dir
LEFT)
fig-markup
(make-pad-x-markup 0.1 alt-markup))))
;; Ditto for the plus mark.
(if plus-markup
(set! fig-markup
(if fig-markup
(make-put-adjacent-markup
X (if (number? plus-dir)
plus-dir
LEFT)
fig-markup plus-markup)
plus-markup)))
(if (markup? fig-markup)
(make-fontsize-markup -5 fig-markup)
(make-null-markup))))
<<
\new MensuralVoice \relative c''{
cis1
}
\figures{
\set figuredBassFormatter = #format-bass-figure-mensural
< 5+ >1 < 5- >1
}
>>
\layout{}
Y -2
(make-musicglyph-markup "accidentals.mensural1")))
(-1/2
. ,(make-general-align-markup
Y -1.3 (make-musicglyph-markup "accidentals.mensuralM1")))))
#(define (format-bass-figure-mensural figure event context)
(let* (;; User properties controlling the figured bass layout.
(large-number-alignment
(ly:context-property context 'figuredBassLargeNumberAlignment))
(figbass-alist
(ly:context-property context 'figuredBassPlusStrokedAlist))
(alt-dir
(ly:context-property context 'figuredBassAlterationDirection))
(plus-dir
(ly:context-property context 'figuredBassPlusDirection))
(augmented (ly:event-property event 'augmented))
(number-one (make-number-markup "1"))
;; The digit(s), horizontally positioned, or #f.
(fig-markup
(if (number? figure)
((if (<= 10 figure)
(lambda (y)
(make-align-on-other-markup
X
large-number-alignment number-one
large-number-alignment y))
identity)
(cond
((eq? #t (ly:event-property event 'diminished))
(make-slashed-digit-markup figure))
((eq? #t (ly:event-property event 'augmented-slash))
;; Use specially stroked digit if available and wanted.
(or (and-let* (((<= 6 figure 9))
(glyph (assv-ref figbass-alist figure)))
(make-musicglyph-markup glyph))
(make-backslashed-digit-markup figure)))
((eq? #t augmented)
;; Use special digit with plus if available and wanted.
(or (and-let* (((>= 5 figure 2))
((eqv? plus-dir RIGHT))
(glyph (assv-ref figbass-alist figure)))
(set! augmented #f)
(make-musicglyph-markup glyph))
(make-number-markup (number->string figure 10))))
(else (make-number-markup (number->string figure 10)))))
#f))
(alt (ly:event-property event 'alteration))
(alt-bracket (ly:event-property event 'alteration-bracket #f))
;; The alteration, probably bracketed but not positioned yet,
;; or #f.
(alt-markup
(if (number? alt)
(let* ((acc (assoc-get alt figbass-accidental-alist-mensural))
(acc-markup
(if acc
acc
(begin
(ly:warning
(G_ "no accidental glyph found for alteration ~a")
alt)
;; fallback
"?"))))
(if alt-bracket
(make-bracket-markup acc-markup)
acc-markup))
#f))
(plus-markup (if (eq? #t augmented)
(make-number-markup "+")
#f)))
(if (and (not alt-markup) alt-bracket)
(ly:programming-error
"Cannot put brackets around non-existent bass figure alteration."))
;; We treat a solitary alteration similarly to digits.
(if (and (not fig-markup) alt-markup)
(begin
(set! fig-markup
(make-align-on-other-markup
X
CENTER number-one
CENTER alt-markup))
(set! alt-markup #f)))
;; We treat a solitary plus similarly to digits (but enlarged).
(if (and (not fig-markup) plus-markup)
(begin
(set! fig-markup
(make-align-on-other-markup
Y
CENTER number-one
CENTER (make-align-on-other-markup
X
CENTER number-one
CENTER (make-fontsize-markup 3 plus-markup))))
(set! plus-markup #f)))
;; The alteration gets attached either to the left or the right of
;; the digit(s).
(if alt-markup
(set! fig-markup
(make-put-adjacent-markup
X (if (number? alt-dir)
alt-dir
LEFT)
fig-markup
(make-pad-x-markup 0.1 alt-markup))))
;; Ditto for the plus mark.
(if plus-markup
(set! fig-markup
(if fig-markup
(make-put-adjacent-markup
X (if (number? plus-dir)
plus-dir
LEFT)
fig-markup plus-markup)
plus-markup)))
(if (markup? fig-markup)
(make-fontsize-markup -5 fig-markup)
(make-null-markup))))
<<
\new MensuralVoice \relative c''{
cis1
}
\figures{
\set figuredBassFormatter = #format-bass-figure-mensural
< 5+ >1 < 5- >1
}
>>
\layout{}
%%%
(note that this now only handles single flat and single sharp).
Cheers,
Tina
signature.asc
Description: This is a digitally signed message part.
