Underlining Chordnames in chordmode

Aus Lilypond Wiki
Wechseln zu: Navigation, Suche

Deutsch

Zuerst im Lilypondforum diskutiert, später in der Mailingsliste gepostet.

Immer wieder tauchte die Fragestellung auf, wie man Akkordbezeichnungen im Chordmodus unterstreichen könne, ohne befriedigende Lösung.

English

There was the question how to underline ChordNames when using ChordMode. This problem popped up in the mailinglist every now and then without providing a solution, later it was discussed in the German Lilypondforum. After getting there a solution by some members I posted this code on the mailinglist.

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

\paper {
  ragged-right = ##t
}

\new ChordNames \chordmode {
  \override Score.RehearsalMark.self-alignment-X = #-1
  \override Score.BarNumber.stencil = ##f
  s1
  \break
  \mark \markup "Chordname"
  g1 \break
  \mark \markup "Underline Chordname"
  \counterbass g \break
  \mark \markup "Underline Chordname in Chordname, German Version"
  \gRootNote b:7 \break
  \mark \markup { "Underline Rootnote in Chordname, German Version" }
  \gBassNote f/b
}

Output

LilyWiki underlineChordname

Links

Kategorien

Wer verlinkt auf diese Seite?