lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Underlining Chordnames in chordmode


From: Manuela Gößnitzer
Subject: Underlining Chordnames in chordmode
Date: Sat, 8 Apr 2017 23:29:15 -0700

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)
         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))))
     (make-line-markup
      (list
       (make-simple-markup
        (conditional-string-downcase
         (vector-ref #("C" "D" "E" "F" "G" "A" "H" "B") (car n-a))
         lowercase?))
       (let ((alteration (/ (cdr n-a) 2)))
         (cond
          ((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))
       (conditional-kern-before
        (alteration->text-accidental-markup alteration)
        (= alteration FLAT) 0.094725)))

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

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

#(define (note-name->german-underlined-markup pitch lowercase?)
   (make-underline-markup
    (make-line-markup
     (list
      ((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 }


greetings,

Manuela

Output example als GIF

Attachment: underlineChords.gif
Description: GIF image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]