Oops, somehow I managed to read only the top half of Lukas' post and missed the interesting part :-(
Am Freitag, den 26.06.2020, 15:01 +0200 schrieb Lukas-Fabian Moser: > Hi Urs, hi Moritz, > > > > thanks for the improvements to my code! (I tend to stop thinking > > > about it as soon as it works for my case, which always leaves > > > lots of > > > room for improvement.) > > > > > Seems to be the opposite of my approach. I'm always starting to > > think > > in terms of reusability and "packages" right away - leading to > > working > > code much later than would be good ;-) > When your default working mode is "I need this worksheet tomorrow by > 9 > o'clock", the approach of using the first sort-of viable solution > becomes much more tempting ;-). > > > > (2) There might also be cases where you have more that one row of > > > arabic > > > numbers to indicate other options. My first intention here would > > > be to have a > > > single layer for every key, that is used in the analysis. If > > > there’s an option > > > to hide the layer where it is not used. > > Each layer is a Lyrics or FiguredBass context, [...] > > That's exactly what occurred to me over lunch: Everything we talked > about concerning spacing just expresses the fact that scale degrees > and > bass figures should behave as if they were independent contexts (one > FiguredBass, one Lyrics). > > So let's scrap the idea of inserting scale degrees artificially into > bass figures where they do not belong! > > Hence: > > \version "2.20.0" > > #(define (scale-degree degree) > (if (eqv? degree 0) > (markup #:null) > (markup #:circle #:small #:number (number->string > degree)))) > > #(define (bass-degree? obj) > "A bass degree is either a number between 1 and 7 or 0 (eqv. to > nothing)!" > (and (integer? obj) (> 8 obj) (< -1 obj))) > > #(define (event-chord? obj) > (and (ly:music? obj) (music-is-of-type? obj 'event-chord))) > > > #(define (figure-signature? obj) > "A figure signature is either an EventChord music or a duration." > (or > (event-chord? obj) > (ly:duration? obj))) > > duration-from-event-chord = > #(define-scheme-function (chord) (event-chord?) > (let ((els (ly:music-property chord 'elements))) > (ly:music-property (first els) 'duration))) > > scaledeg = > #(define-music-function (num signature) ((bass-degree? 0) figure- > signature?) > (let ((dur (if (ly:duration? signature) > signature > (duration-from-event-chord signature)))) > #{ > << > #(if (ly:music? signature) > signature > #{ s $signature #}) > \context Lyrics = "scaleDegrees" \lyricmode > { > \markup { #(scale-degree num) } $dur > } > >> > #})) > > > > << > \new Staff { > \time 3/4 > \clef bass > c4 d e f2 g4 as2^"or g sharp?" a4 b4 c'4 % Morgenlich leuchtend > ... > } > \figures \with { \override > VerticalAxisGroup.nonstaff-nonstaff-spacing.padding = 1 } { > \scaledeg 1 4 > \scaledeg 2 <4 3>4 > \scaledeg 3 <6>4 > \scaledeg 4 <7>4 > \scaledeg 0 <6> > \scaledeg 5 4 > \scaledeg 6 <6>2 > \scaledeg 6 <6>4 > \scaledeg 7 <6 5>4 > \scaledeg 1 4 > } > \new Lyrics = "scaleDegrees" { \skip 1*8 } > >> > > > Of course this is just proof-of-concept: It looks like this is very extensible, and I'll definitely have a closer look at it. > The Lyrics context should be > created (and kept alive) automatically ... or, even better: it should > be > user-settable with an interface like: > > \figures { > > \inject-scaledegrees-into-context "scaleDegrees" > > ... > > } > > which would enable all sorts of vertical configuration. This can be done by defining the figures in a variable, say, figs and then doing something like makeDegrees = { << \new FiguredBass \with { \override VerticalAxisGroup.nonstaff-nonstaff-spacing.padding = 1 } \figs \new Lyrics = "scaleDegrees" { #(skip-of-length figs) } >> } In the score definition we use \makeDegrees instead of explicitly creating the contexts. I think I'll really investigate how this can nicely be integrated in an anlysis.harmony package. BestUrs > > Best > Lukas >