X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fchord-name.scm;h=7986ba5c1c33c16b6c2f9d5731cd40a577d51eb2;hb=3c9561d788078f7ee4a6e1d973cf549d8f258935;hp=e43123cd6713c908748f40d5df0782652fd3efba;hpb=55abb833082b6871d8c1b7c3e52f8eceb6362039;p=lilypond.git diff --git a/scm/chord-name.scm b/scm/chord-name.scm index e43123cd67..7986ba5c1c 100644 --- a/scm/chord-name.scm +++ b/scm/chord-name.scm @@ -3,20 +3,24 @@ ;;; ;;; source file of the GNU LilyPond music typesetter ;;; -;;; (c) 2000--2003 Jan Nieuwenhuizen -;;; Han-Wen Nienhuys +;;; (c) 2000--2004 Jan Nieuwenhuizen +;;; +;;; Han-Wen Nienhuys (define (natural-chord-alteration p) "Return the natural alteration for step P." (if (= (ly:pitch-steps p) 6) - -1 + FLAT 0)) +;; +;; TODO: make into markup. +;; (define-public (alteration->text-accidental-markup alteration) (make-smaller-markup (make-raise-markup - (if (= alteration -1) + (if (= alteration FLAT) 0.3 0.6) (make-musicglyph-markup @@ -28,7 +32,7 @@ (make-line-markup (list empty-markup)) (conditional-kern-before (alteration->text-accidental-markup alteration) - (= alteration -1) 0.2 + (= alteration FLAT) 0.2 ))) @@ -38,8 +42,7 @@ (list (make-simple-markup (vector-ref #("C" "D" "E" "F" "G" "A" "B") (ly:pitch-notename pitch))) - (make-normal-size-super-markup - (accidental->markup (ly:pitch-alteration pitch)))))) + (accidental->markup (ly:pitch-alteration pitch))))) (define-public ((chord-name->german-markup B-instead-of-Bb) pitch) @@ -49,8 +52,8 @@ " (let* ((name (ly:pitch-notename pitch)) (alt (ly:pitch-alteration pitch)) - (n-a (if (member (cons name alt) '((6 . -1) (6 . -2))) - (cons 7 (+ (if B-instead-of-Bb 1 0) alt)) + (n-a (if (member (cons name alt) `((6 . ,FLAT) (6 . ,DOUBLE-FLAT))) + (cons 7 (+ (if B-instead-of-Bb SEMI-TONE 0) alt)) (cons name alt)))) (make-line-markup (list @@ -63,123 +66,62 @@ (define-public (note-name->german-markup pitch) (let* ((name (ly:pitch-notename pitch)) (alt (ly:pitch-alteration pitch)) - (n-a (if (member (cons name alt) '((6 . -1) (6 . -2))) - (cons 7 (+ 1 alt)) + (n-a (if (member (cons name alt) `((6 . ,FLAT) (6 . ,DOUBLE-FLAT))) + (cons 7 (+ SEMI-TONE alt)) (cons name alt)))) (make-line-markup (list (string-append - (list-ref '("c" "d" "e" "f" "g" "a" "h" "b") (car n-a)) + (list-ref '("c" "d" "e" "f" "g" "a" "h" "b") (car n-a) ) (if (or (equal? (car n-a) 2) (equal? (car n-a) 5)) - (list-ref '( "ses" "s" "" "is" "isis") (+ 2 (cdr n-a))) - (list-ref '("eses" "es" "" "is" "isis") (+ 2 (cdr n-a))))))))) + (list-ref '( "ses" "s" "" "is" "isis") (+ 2 (/ (cdr n-a) 2) )) + (list-ref '("eses" "es" "" "is" "isis") (+ 2 (/ (cdr n-a) 2) )) + )))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; -(define-public (sequential-music-to-chord-exceptions seq omit-root) - "Transform sequential music SEQ of type <>-\markup{ foobar } +;; fixme we should standardize on omit-root (or the other one.) +;; perhaps the default should also be reversed --hwn +(define-public (sequential-music-to-chord-exceptions seq . rest) + "Transform sequential music SEQ of type <>-\\markup{ foobar } to (cons CDE-PITCHES FOOBAR-MARKUP), or to (cons DE-PITCHES -FOOBAR-MARKUP) if OMIT-ROOT. +FOOBAR-MARKUP) if OMIT-ROOT is given and non-false. " + (define (chord-to-exception-entry m) - (let* ((elts (ly:get-mus-property m 'elements)) - (pitches (map (lambda (x) (ly:get-mus-property x 'pitch)) - (filter-list + (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:get-mus-property y 'types))) + (ly:music-property y 'types))) elts))) (sorted (sort pitches ly:pitch ..., + ;; 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:get-mus-property y 'types))) + (ly:music-property y 'types))) elts))) - (text (if (null? texts) #f (car texts)))) + + (text (if (null? texts) #f (if omit-root (car texts) texts)))) (cons (if omit-root (cdr normalized) normalized) text))) (define (is-req-chord? m) (and - (memq 'event-chord (ly:get-mus-property m 'types)) - (not (equal? (ly:make-moment 0 1) (ly:get-music-length m))))) + (memq 'event-chord (ly:music-property m 'types)) + (not (equal? ZERO-MOMENT (ly:music-length m))))) - (let* ((elts (filter-list is-req-chord? (ly:get-mus-property seq 'elements))) + (let* ((elts (filter is-req-chord? (ly:music-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))))) + (filter (lambda (x) (cdr x)) alist)))