Underlining Chordnames in chordmode

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Underlining Chordnames in chordmode

In standard Accordion bass notation counterbasses are notated underlined. In the German Lilypond forum users figured out a solution for this task. I added the German chord notation.

Here is the code

\version "2.19.54"
\language "english"

#(define ((chord-name->german-markup-text-alteration B-instead-of-Bb) pitch lowercase?)

   (define (pitch-alteration-semitones pitch)
     (inexact->exact (round (* (ly:pitch-alteration pitch) 2))))

   (define (conditional-string-downcase str condition)
     (if condition
         (string-downcase str)

   (let* ((name (ly:pitch-notename pitch))
          (alt-semitones  (pitch-alteration-semitones pitch))
          (n-a (if (member (cons name alt-semitones) `((6 . -1) (6 . -1)))
                   (cons 7 (+ (if B-instead-of-Bb 1 1) alt-semitones))
                   (cons name alt-semitones))))
         (vector-ref #("C" "D" "E" "F" "G" "A" "H" "B") (car n-a))
       (let ((alteration (/ (cdr n-a) 2)))
          ((and (equal? lowercase? #f) (= alteration FLAT) (= (car n-a) 7)) (make-simple-markup ""))
          ((and (= alteration FLAT) (or (= (car n-a) 5) (= (car n-a) 2) )) (make-simple-markup "s"))
          ((= alteration FLAT) (make-simple-markup "es"))
          ((and (= alteration DOUBLE-FLAT) (or (= (car n-a) 5)(= (car n-a) 2) )) (make-simple-markup "ses"))
          ((= alteration DOUBLE-FLAT) (make-simple-markup "eses"))
          ((= alteration SHARP) (make-simple-markup "is"))
          ((= alteration DOUBLE-SHARP) (make-simple-markup "isis"))
          (else empty-markup)))))))

#(define (accidental->markup alteration)
   "Return accidental markup for ALTERATION."
   (if (= alteration 0)
       (make-line-markup (list empty-markup))
        (alteration->text-accidental-markup alteration)
        (= alteration FLAT) 0.094725)))

#(define (conditional-string-downcase str condition)
   (if condition
       (string-downcase str)

#(define (note-name->underlined-markup pitch lowercase?)
   "Return pitch markup for @var{pitch}."
        (vector-ref #("C" "D" "E" "F" "G" "A" "B") (ly:pitch-notename pitch))
      (accidental->markup (ly:pitch-alteration pitch))))))

#(define (note-name->german-underlined-markup pitch lowercase?)
      ((chord-name->german-markup-text-alteration #t) pitch lowercase?)))))

counterbass= \once \set ChordNames.chordRootNamer = #note-name->underlined-markup

%% underline German chordnames
%% you might add any language you like
gRootNote = \once \set ChordNames.chordRootNamer = #note-name->german-underlined-markup
%% underline bassnotes German notation
gBassNote = \once \set ChordNames.chordNoteNamer = #note-name->german-underlined-markup

\markup "Underline Chordnames in Chordmode"
\new ChordNames \chordmode { g \counterbass g \gRootNote b:7 \gBassNote f/b }



Output example als GIF

lilypond-user mailing list
[hidden email]

underlineChords.gif (11K) Download Attachment