- (append
- (list root-markup
- (markup-join prefixes sep)
- (make-super-markup to-be-raised-stuff))
- base-stuff))
- (make-line-markup base-stuff)
-
- ))
-
- (let*
- (
- (root (car in-pitches))
- (pitches (map (lambda (x) (ly:pitch-diff x root)) (cdr in-pitches)))
- (exceptions (ly:get-context-property context 'chordNameExceptions))
- (exception (assoc-get-default pitches exceptions #f))
- (prefixes '())
- (suffixes '())
- (add-steps '())
- (main-name #f)
- (bass-note #f)
- (alterations '())
- )
-
- (if
- exception
- (make-line-markup
- (list (name-root root) exception))
-
- (begin ; no exception.
-
- ; handle sus4 and sus2 suffix: if there is a 3 together with
- ; sus2 or sus4, then we explicitly say add3.
- (map
- (lambda (j)
- (if (get-step j pitches)
- (begin
- (if (get-step 3 pitches)
- (begin
- (set! add-steps (cons (get-step 3 pitches) add-steps))
- (set! pitches (remove-step 3 pitches))
- ))
- (set! suffixes (cons (get-step j pitches) suffixes))
- )
- )
- ) '(2 4) )
-
- ;; do minor-3rd modifier.
- (if (and (get-step 3 pitches)
- (= (ly:pitch-alteration (get-step 3 pitches)) -1))
- (set! prefixes (cons (get-step 3 pitches) prefixes))
- )
-
- ;; lazy bum. Should write loop.
- (cond
- ((get-step 7 pitches) (set! main-name (get-step 7 pitches)))
- ((get-step 6 pitches) (set! main-name (get-step 6 pitches)))
- ((get-step 5 pitches) (set! main-name (get-step 5 pitches)))
- ((get-step 4 pitches) (set! main-name (get-step 4 pitches)))
- ((get-step 3 pitches) (set! main-name (get-step 3 pitches)))
- )
-
- (let*
- (
- (3-diff? (lambda (x y)
- (= (- (pitch-step y) (pitch-step x)) 2)))
- (split (split-at-predicate 3-diff? (remove-uptil-step 5 pitches)))
- )
- (set! alterations (append alterations (car split)))
- (set! add-steps (append add-steps (cdr split)))
- (set! alterations (delq main-name alterations))
- (set! add-steps (delq main-name add-steps))
-
- (if (ly:pitch? inversion)
- (set! bass-note inversion)
- )
-
- (if (ly:pitch? bass)
- (set! bass-note bass)
- )
-
- ;; chords with natural (5 7 9 11 13) or leading subsequence.
- ;; etc. are named by the top pitch, without any further
- ;; alterations.
- (if (and
- (ly:pitch? main-name)
- (= 7 (pitch-step main-name))
- (is-natural-alteration? main-name)
- (pair? (remove-uptil-step 7 alterations))
- (reduce (lambda (x y) (and x y)) #t
- (map is-natural-alteration? alterations)))
- (begin
- (set! main-name (last alterations))
- (set! alterations '())
- ))
-
- (ignatzek-format-chord-name root prefixes main-name alterations add-steps suffixes bass-note)
- )
- ))))
+ (append
+ (list root-markup
+ (conditional-kern-before (markup-join prefixes sep)
+ (and (not (null? prefixes))
+ (= (ly:pitch-alteration root) NATURAL))
+ (ly:context-property context 'chordPrefixSpacer))
+ (make-super-markup to-be-raised-stuff))
+ base-stuff))
+ (make-line-markup base-stuff)))
+
+ (define (ignatzek-format-exception
+ root
+ exception-markup
+ bass-pitch
+ lowercase-root?)
+
+ (make-line-markup
+ `(
+ ,(name-root root lowercase-root?)
+ ,exception-markup
+ .
+ ,(if (ly:pitch? bass-pitch)
+ (list (ly:context-property context 'slashChordSeparator)
+ (name-note bass-pitch #f))
+ '()))))
+
+ (let* ((root (car in-pitches))
+ (pitches (map (lambda (x) (ly:pitch-diff x root)) (cdr in-pitches)))
+ (lowercase-root?
+ (and (ly:context-property context 'chordNameLowercaseMinor)
+ (let ((third (get-step 3 pitches)))
+ (and third (= (ly:pitch-alteration third) FLAT)))))
+ (exceptions (ly:context-property context 'chordNameExceptions))
+ (exception (assoc-get pitches exceptions))
+ (prefixes '())
+ (suffixes '())
+ (add-steps '())
+ (main-name #f)
+ (bass-note
+ (if (ly:pitch? inversion)
+ inversion
+ bass))
+ (alterations '()))
+
+ (if exception
+ (ignatzek-format-exception root exception bass-note lowercase-root?)
+
+ (begin
+ ;; no exception.
+ ;; handle sus4 and sus2 suffix: if there is a 3 together with
+ ;; sus2 or sus4, then we explicitly say add3.
+ (for-each
+ (lambda (j)
+ (if (get-step j pitches)
+ (begin
+ (if (get-step 3 pitches)
+ (begin
+ (set! add-steps (cons (get-step 3 pitches) add-steps))
+ (set! pitches (remove-step 3 pitches))))
+ (set! suffixes (cons (get-step j pitches) suffixes)))))
+ '(2 4))
+
+ ;; do minor-3rd modifier.
+ (if (and (get-step 3 pitches)
+ (= (ly:pitch-alteration (get-step 3 pitches)) FLAT))
+ (set! prefixes (cons (get-step 3 pitches) prefixes)))
+
+ ;; lazy bum. Should write loop.
+ (cond
+ ((get-step 7 pitches) (set! main-name (get-step 7 pitches)))
+ ((get-step 6 pitches) (set! main-name (get-step 6 pitches)))
+ ((get-step 5 pitches) (set! main-name (get-step 5 pitches)))
+ ((get-step 4 pitches) (set! main-name (get-step 4 pitches)))
+ ((get-step 3 pitches) (set! main-name (get-step 3 pitches))))
+
+ (let* ((3-diff? (lambda (x y)
+ (= (- (pitch-step y) (pitch-step x)) 2)))
+ (split (split-at-predicate
+ 3-diff? (remove-uptil-step 5 pitches))))
+ (set! alterations (append alterations (car split)))
+ (set! add-steps (append add-steps (cdr split)))
+ (set! alterations (delq main-name alterations))
+ (set! add-steps (delq main-name add-steps))
+
+
+ ;; chords with natural (5 7 9 11 13) or leading subsequence.
+ ;; etc. are named by the top pitch, without any further
+ ;; alterations.
+ (if (and
+ (ly:pitch? main-name)
+ (= 7 (pitch-step main-name))
+ (is-natural-alteration? main-name)
+ (pair? (remove-uptil-step 7 alterations))
+ (every is-natural-alteration? alterations))
+ (begin
+ (set! main-name (last alterations))
+ (set! alterations '())))