From: Reinhold Kainhofer Date: Tue, 10 Jun 2008 17:44:47 +0000 (+0200) Subject: figured bass: Implement backslashed figures (raised 6th steps) X-Git-Tag: release/2.11.50-1~49 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=7b716659ab09847e998528c2afdde6aa34c7d24c;p=lilypond.git figured bass: Implement backslashed figures (raised 6th steps) raised 6th steps are typically shown as 6 with a backslash through it (rather than with a '+'). This patch implements this by adding the \\ modifier to bass figures: <6\\> The back-slashed digit is printed out using the new markup function backslashed-digit (copied from slashed-digit and adapted to backslashes). Both forward and backward slashes uses the same internal function. I also increased the slope of forward slashes to make it easier to distinguish the direction of the slash. For some numbers I also enlarge the slash in X directions to make it more visible (my hand-engraved scores use an even larger slash than lilypond, anyway). I also move the slash up/down for some numbers to make it more visible. Also use the real Y extents of the slash rather than the whole interval for the number. As we shift the slash for some numbers, otherwise it would make the whole digit larger and shift it down for no apparent visual reason. Signed-off-by: Reinhold Kainhofer --- diff --git a/input/regression/figured-bass-slashed-numbers.ly b/input/regression/figured-bass-slashed-numbers.ly new file mode 100644 index 0000000000..257170bf9d --- /dev/null +++ b/input/regression/figured-bass-slashed-numbers.ly @@ -0,0 +1,32 @@ +\version "2.11.47" + +bassfigures = \figuremode { + <0/ 1/ 2/> <3/ 4/ 5/> <6/ 7/ 8/> <9/ 10/ 11/> <12/ 13/ 100/> + <0\\ 1\\ 2\\> <3\\ 4\\ 5\\> <6\\ 7\\ 8\\> <9\\ 10\\ 11\\> <12\\ 13\\ 100\\> + <3\\\+ 6\\/ 7\\+! > +} + +<< + \new FiguredBass \bassfigures +>> + +%{ +% Override the exceptions: + +#(define (horizontal-slash-interval-default num forward number-interval mag) + (interval-widen number-interval (* mag 0.25))) + +#(define (adjust-slash-stencil-default num forward stencil mag) + stencil) + +unsetExceptions = #(define-music-function (parser location) () +; (set! horizontal-slash-interval horizontal-slash-interval-default) +; (set! adjust-slash-stencil adjust-slash-stencil-default) + (make-music 'Music 'void #t) +) + +<< + \unsetExceptions + \new FiguredBass <<\unsetExceptions \bassfigures>> +>> +%} diff --git a/input/regression/figured-bass.ly b/input/regression/figured-bass.ly index b710399117..a78a197a9b 100644 --- a/input/regression/figured-bass.ly +++ b/input/regression/figured-bass.ly @@ -6,7 +6,7 @@ texidoc = " Figured bass is created by the FiguredBass context which responds to figured bass events and rest events. You must enter these using the special @code{\figuremode @{ @}} mode, which allows you to -type numbers, like @code{<4 6+>} and add slashes and pluses. +type numbers, like @code{<4 6+>} and add slashes, backslashes and pluses. You can also enter markup strings. The vertical alignment may also be tuned. @@ -32,6 +32,7 @@ You can also enter markup strings. The vertical alignment may also be tuned. <3 _! 5 _- 7> <3 _ 5 _ 7> <3 6/ > + <3 6\\ > <"V7" ["bla" 6] \markup{ \musicglyph #"rests.2"} > \once \override BassFigureAlignment #'stacking-dir = #UP diff --git a/lily/parser.yy b/lily/parser.yy index 3b690e8980..9a78c74437 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -1907,6 +1907,10 @@ bass_figure: { m->set_property ("no-continuation", SCM_BOOL_T); } + else if ($2 == ly_symbol2scm ("backslash")) + { + m->set_property ("augmented-slash", SCM_BOOL_T); + } } ; @@ -1921,6 +1925,9 @@ figured_bass_modification: | '/' { $$ = ly_symbol2scm ("slash"); } + | E_BACKSLASH { + $$ = ly_symbol2scm ("backslash"); + } ; br_bass_figure: diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index eb96aee845..d09df9e0a5 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -1709,6 +1709,71 @@ and continue with double letters. (ly:text-interface::interpret-markup layout props (number->markletter-string number->mark-alphabet-vector num))) +(define-public (horizontal-slash-interval num forward number-interval mag) + (ly:message "Mag step: ~a" mag) + (if forward + (cond ;((= num 6) (interval-widen number-interval (* mag 0.5))) + ;((= num 5) (interval-widen number-interval (* mag 0.5))) + (else (interval-widen number-interval (* mag 0.25)))) + (cond ((= num 6) (interval-widen number-interval (* mag 0.5))) + ;((= num 5) (interval-widen number-interval (* mag 0.5))) + (else (interval-widen number-interval (* mag 0.25)))) + )) + +(define-public (adjust-slash-stencil num forward stencil mag) + (if forward + (cond ((= num 2) + (ly:stencil-translate stencil (cons (* mag -0.00) (* mag 0.2)))) + ((= num 3) + (ly:stencil-translate stencil (cons (* mag -0.00) (* mag 0.2)))) + ;((= num 5) + ;(ly:stencil-translate stencil (cons (* mag -0.00) (* mag -0.07)))) + ;((= num 7) + ; (ly:stencil-translate stencil (cons (* mag -0.00) (* mag -0.15)))) + (else stencil)) + (cond ((= num 6) + (ly:stencil-translate stencil (cons (* mag -0.00) (* mag 0.15)))) + ;((= num 8) + ; (ly:stencil-translate stencil (cons (* mag -0.00) (* mag -0.15)))) + (else stencil)) + ) +) + +(define (slashed-digit-internal layout props num forward font-size thickness) + (let* ((mag (magstep font-size)) + (thickness (* mag + (ly:output-def-lookup layout 'line-thickness) + thickness)) + ; backward slashes might use slope and point in the other direction! + (dy (* mag (if forward 0.4 -0.4))) + (number-stencil (interpret-markup layout + (prepend-alist-chain 'font-encoding 'fetaNumber props) + (number->string num))) + (num-x (horizontal-slash-interval num forward (ly:stencil-extent number-stencil X) mag)) + (center (interval-center (ly:stencil-extent number-stencil Y))) + ; Use the real extents of the slash, not the whole number, because we + ; might translate the slash later on! + (num-y (interval-widen (cons center center) (abs dy))) + (is-sane (and (interval-sane? num-x) (interval-sane? num-y))) + (slash-stencil (if is-sane + (ly:make-stencil + `(draw-line ,thickness + ,(car num-x) ,(- (interval-center num-y) dy) + ,(cdr num-x) ,(+ (interval-center num-y) dy)) + num-x num-y) + #f))) +(ly:message "Num: ~a, X-interval: ~a" num num-x) + (if (ly:stencil? slash-stencil) + (begin + ; for some numbers we need to shift the slash/backslash up or down to make + ; the slashed digit look better + (set! slash-stencil (adjust-slash-stencil num forward slash-stencil mag)) + (set! number-stencil + (ly:stencil-add number-stencil slash-stencil))) + (ly:warning "Unable to create slashed digit ~a" num)) + number-stencil)) + + (define-builtin-markup-command (slashed-digit layout props num) (integer?) other @@ -1727,42 +1792,28 @@ figured bass notation. \\slashed-digit #7 } @end lilypond" - (let* ((mag (magstep font-size)) - (thickness (* mag - (ly:output-def-lookup layout 'line-thickness) - thickness)) - (dy (* mag 0.15)) - (number-stencil (interpret-markup layout - (prepend-alist-chain 'font-encoding 'fetaNumber props) - (number->string num))) - (num-x (interval-widen (ly:stencil-extent number-stencil X) - (* mag 0.2))) - (num-y (ly:stencil-extent number-stencil Y)) - (is-sane (and (interval-sane? num-x) (interval-sane? num-y))) - (slash-stencil (if is-sane - (ly:make-stencil - `(draw-line ,thickness - ,(car num-x) ,(- (interval-center num-y) dy) - ,(cdr num-x) ,(+ (interval-center num-y) dy)) - num-x num-y) - #f))) - (set! slash-stencil - (cond ((not (ly:stencil? slash-stencil)) #f) - ((= num 5) - (ly:stencil-translate slash-stencil - ;;(cons (* mag -0.05) (* mag 0.42)) - (cons (* mag -0.00) (* mag -0.07)))) - ((= num 7) - (ly:stencil-translate slash-stencil - ;;(cons (* mag -0.05) (* mag 0.42)) - (cons (* mag -0.00) (* mag -0.15)))) - (else slash-stencil))) - (if slash-stencil - (set! number-stencil - (ly:stencil-add number-stencil slash-stencil)) - (ly:warning "invalid number for slashed digit ~a" num)) - number-stencil)) + (slashed-digit-internal layout props num #t font-size thickness)) + +(define-builtin-markup-command (backslashed-digit layout props num) + (integer?) + other + ((font-size 0) + (thickness 1.6)) + " +@cindex backslashed digits +A feta number, with backslash. This is for use in the context of +figured bass notation. +@lilypond[verbatim,quote] +\\markup { + \\backslashed-digit #5 + \\hspace #2 + \\override #'(thickness . 3) + \\backslashed-digit #7 +} +@end lilypond" + (slashed-digit-internal layout props num #f font-size thickness)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; the note command. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/scm/define-music-properties.scm b/scm/define-music-properties.scm index d6202d79ff..357dd73f04 100644 --- a/scm/define-music-properties.scm +++ b/scm/define-music-properties.scm @@ -31,6 +31,8 @@ TODO: Consider making type into symbol.") (augmented ,boolean? "This figure is for an augmented figured bass (with @code{+} sign).") + (augmented-slash ,boolean? "This figure is for an augmented figured bass +(back-slashed number).") (associated-context ,string? "Name of the Voice context associated with this @code{\\newaddlyrics} section.") diff --git a/scm/translation-functions.scm b/scm/translation-functions.scm index 366f44fa3b..2ceee74ab7 100644 --- a/scm/translation-functions.scm +++ b/scm/translation-functions.scm @@ -72,9 +72,12 @@ (lambda (y) (make-translate-scaled-markup (cons -0.7 0) y)) identity) - (if (eq? #t (ly:event-property event 'diminished)) - (markup #:slashed-digit figure) - (markup #:number (number->string figure 10)))) + (cond + ((eq? #t (ly:event-property event 'diminished)) + (markup #:slashed-digit figure)) + ((eq? #t (ly:event-property event 'augmented-slash)) + (markup #:backslashed-digit figure)) + (else (markup #:number (number->string figure 10))))) #f )) (alt (ly:event-property event 'alteration))