- (let*
- (
- (elts (ly:get-mus-property m 'elements))
- (pitches (map
- (lambda (x)
- (ly:get-mus-property x 'pitch)
- )
- (filter-list
- (lambda (y) (memq 'note-event (ly:get-mus-property y 'types)))
- elts)))
- (sorted (sort pitches ly:pitch<? ))
- (root (car sorted))
- (non-root (map (lambda (x) (ly:pitch-diff x root)) (cdr sorted)))
- (texts (map
- (lambda (x)
- (ly:get-mus-property x 'text)
- )
-
- (filter-list
- (lambda (y)
- (memq 'text-script-event
- (ly:get-mus-property y 'types))) elts)
- ))
- (text (if (null? texts)
- #f
- (car texts)))
-
- )
- (cons non-root text)
- ))
-
- (let*
- (
- (elts (filter-list is-req-chord? (ly:get-mus-property seq 'elements)))
- (alist (map chord-to-exception-entry elts))
- )
- (filter-list (lambda (x) (cdr x)) alist)
- ))
-
-
-
-
-(define-public (new-chord-name-brew-molecule grob)
- (let*
- (
- (ws (ly:get-grob-property grob 'word-space))
- (markup (ly:get-grob-property grob 'text))
- (molecule (interpret-markup grob
- (cons '((word-space . 0.0))
- (Font_interface::get_property_alist_chain grob))
- markup))
- )
-
- ;;
- ;; chord names aren't in staffs, so WS is in global staff space.
- (if (number? ws)
- (ly:molecule-combine-at-edge
- molecule
- X RIGHT (ly:make-molecule "" (cons 0 ws) '(-1 . 1) )
- 0.0)
- molecule)
- ))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(define-public (set-chord-name-style sym)
- "Return music expressions that set the chord naming style. For
-inline use in .ly file"
-
- (define (chord-name-style-setter function exceptions)
- (context-spec-music
- (make-sequential-music
- (list (make-property-set 'chordNameFunction function)
- (make-property-set 'chordNameExceptions exceptions)))
- "ChordNames"
- )
- )
-
- (ly:export
- (case sym
- ((ignatzek)
- (chord-name-style-setter ignatzek-chord-names
- '()))
- ((banter)
- (chord-name-style-setter double-plus-new-chord->markup-banter
- chord::exception-alist-banter))
-
- ((jazz)
- (chord-name-style-setter double-plus-new-chord->markup-jazz
- chord::exception-alist-jazz))
- )))
-
-;; can't put this in double-plus-new-chord-name.scm, because we can't
-;; ly:load that very easily.
-(define-public (set-double-plus-new-chord-name-style style options)
- "Return music expressions that set the chord naming style. For
-inline use in .ly file"
-
- (define (chord-name-style-setter function)
- (context-spec-music
- (make-sequential-music
- (list (make-property-set 'chordNameFunction function)
-
- ;; urg , misuse of chordNameExceptions function.
- (make-property-set 'chordNameExceptions options)))
- "ChordNames"))
-
- (ly:export
- (case style
- ((banter)
- (chord-name-style-setter double-plus-new-chord->markup-banter))
-
- ((jazz)
- (chord-name-style-setter double-plus-new-chord->markup-jazz)))))
+ (let* ((elts (ly:music-property m 'elements))
+ (omit-root (and (pair? rest) (car rest)))
+ (pitches (map (lambda (x) (ly:music-property x 'pitch))
+ (filter
+ (lambda (y) (memq 'note-event
+ (ly:music-property y 'types)))
+ elts)))
+ (sorted (sort pitches ly:pitch<?))
+ (root (car sorted))
+
+ ;; ugh?
+ ;;(diff (ly:pitch-diff root (ly:make-pitch -1 0 0)))
+ ;; FIXME. This results in #<Pitch c> ...,
+ ;; but that is what we need because default octave for
+ ;; \chords has changed to c' too?
+ (diff (ly:pitch-diff root (ly:make-pitch 0 0 0)))
+ (normalized (map (lambda (x) (ly:pitch-diff x diff)) sorted))
+ (texts (map (lambda (x) (ly:music-property x 'text))
+ (filter
+ (lambda (y) (memq 'text-script-event
+ (ly:music-property y 'types)))
+ elts)))
+
+ (text (if (null? texts) #f (if omit-root (car texts) texts))))
+ (cons (if omit-root (cdr normalized) normalized) text)))
+
+ (define (is-event-chord? m)
+ (and
+ (memq 'event-chord (ly:music-property m 'types))
+ (not (equal? ZERO-MOMENT (ly:music-length m)))))