Underlining Chordnames in chordmode

Aus Lilypond Wiki
Version vom 29. August 2017, 13:11 Uhr von Lilyadmin (Diskussion | Beiträge) (Kategorien)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche


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.


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.


\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

\paper {
  ragged-right = ##t

\new ChordNames \chordmode {
  \override Score.RehearsalMark.self-alignment-X = #-1
  \override Score.BarNumber.stencil = ##f
  \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


LilyWiki underlineChordname



Wer verlinkt auf diese Seite?