Hi Urs,


Hey, that looks promising - I didn't know that.
Now I'd only need a way to properly do the vertical alignment against the baseline of the lowest markup:

\figures {
  <6 4 \markup { \circle \number 5 }>
  <3+ \markup { \circle \number 6 }>
}

This might be achieved using an inversed stacking direction. Harm's figure reversal function can then be used to enable the user to still enter bass figures in the "usual" way.

With a bit of syntactic sugar, this might look as below.

Problems so far:

1) The figures are still down-aligned. This might be remedied for instance by defining a "maximal" number of figures for which to leave space and inserting placeholders. (This reminds me of one of my long-time wishes, namely to have a dedicated "empty" figure for use in FiguredBass, which is sometimes needed to leave space for figures that are added later in a chord. I once patched my LilyPond to allow for this, but this was an ugly hack involving transparent figures...)

2) The "get-current-duration" function is simply awful: I didn't know how to find out which duration the parser would assign to a duration-less note/bass figure, so I just let it create a note and see what its duration becomes. There must be a decent way to achieve this. (I need to give the bassStufe-function a duration because otherwise it does not work with figure \none.)

Best
Lukas



\version "2.20.0"

\layout {
  \override BassFigureAlignment.stacking-dir = #UP
}

reverseFigures = % by Harm
#(define-music-function (mus)(ly:music?)
   (music-map
    (lambda (m)
      (if (music-is-of-type? m 'event-chord)
          (let ((ev-chrd-elts (ly:music-property m 'elements)))
            (ly:music-set-property! m 'elements
                                    (reverse
                                     (map
                                      (lambda (e)
                                        (cond ((and (eq? #t (ly:music-property e 'bracket-start))                                                     (eq? #t (ly:music-property e 'bracket-stop)))
                                               '())
                                              ((eq? #t (ly:music-property e 'bracket-start))
                                               (begin
(ly:music-set-property! e 'bracket-start '())
(ly:music-set-property! e 'bracket-stop #t)))
                                              ((eq? #t (ly:music-property e 'bracket-stop))
                                               (begin
(ly:music-set-property! e 'bracket-stop '())
(ly:music-set-property! e 'bracket-start #t))))
                                        e)
                                      ev-chrd-elts)))
            m)
          m))
    mus))

get-current-duration =
#(define-scheme-function () ()
   (let* ((tempmusic #{ {a} #})
          (els (ly:music-property tempmusic 'elements)))
     (ly:music-property (car els) 'duration)))

bassStufe =
#(define-music-function (num) (integer?)
   (let ((scale-markup
          (if (> num 0)
              #{ \markup \circle \small \number #(number->string num) #}
              (markup #:null))))

     (make-music
      'BassFigureEvent
      'duration
      (get-current-duration)
      'text
      #{ \markup
         \with-dimensions #'(0 . 1) #'(0 . 5)
         #scale-markup
      #})))

scaledeg =
#(define-music-function (num signatur) ((integer? 0) ly:music?)
   (let ((signatur-reversed (reverseFigures signatur)))
     (make-music
      'EventChord
      'elements
      (cons (bassStufe num)
            (ly:music-property signatur-reversed 'elements)))))

none = {}

<<
  \new Staff { \clef bass d2 e4 fis g2 a b cis' d' g2 fis1 }
  \figures {
    \scaledeg 1 <5 3>2
    \scaledeg 2 <6>4
    \scaledeg 3 <6>
    \scaledeg 4 <6 5>2
    \scaledeg 5 \none
    \scaledeg 6 <6>2
    \scaledeg 7 <6>4
    \scaledeg <6 5>
    \scaledeg 1 <5 3>2
    \scaledeg 4 <4 2>
    \scaledeg 3 <6>1
  }
>>




Reply via email to