X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fchord-name.scm;h=bdef88a47644f0aef4e3186778a4200ce2536c12;hb=28b03579e5129ba89e9b07d0170dee73202bf110;hp=7986ba5c1c33c16b6c2f9d5731cd40a577d51eb2;hpb=eba82770802a246bca4afab7eab1f78e84785214;p=lilypond.git diff --git a/scm/chord-name.scm b/scm/chord-name.scm index 7986ba5c1c..bdef88a476 100644 --- a/scm/chord-name.scm +++ b/scm/chord-name.scm @@ -1,11 +1,9 @@ -;;; -;;; chord-name.scm -- chord name utility functions -;;; -;;; source file of the GNU LilyPond music typesetter -;;; -;;; (c) 2000--2004 Jan Nieuwenhuizen -;;; -;;; Han-Wen Nienhuys +;;;; chord-name.scm -- chord name utility functions +;;;; +;;;; source file of the GNU LilyPond music typesetter +;;;; +;;;; (c) 2000--2006 Jan Nieuwenhuizen +;;;; Han-Wen Nienhuys (define (natural-chord-alteration p) "Return the natural alteration for step P." @@ -13,7 +11,6 @@ FLAT 0)) - ;; ;; TODO: make into markup. ;; @@ -24,7 +21,7 @@ 0.3 0.6) (make-musicglyph-markup - (string-append "accidentals-" (number->string alteration)))))) + (string-append "accidentals." (number->string alteration)))))) (define (accidental->markup alteration) "Return accidental markup for ALTERATION." @@ -32,9 +29,18 @@ (make-line-markup (list empty-markup)) (conditional-kern-before (alteration->text-accidental-markup alteration) - (= alteration FLAT) 0.2 - ))) + (= alteration FLAT) 0.2))) +(define (accidental->markup-italian alteration) + "Return accidental markup for ALTERATION, for use after an italian chord root name." + (if (= alteration 0) + (make-hspace-markup 0.2) + (make-line-markup + (list + (make-hspace-markup (if (= alteration FLAT) 0.7 0.5)) + (make-raise-markup 0.7 (alteration->text-accidental-markup alteration)) + (make-hspace-markup (if (= alteration SHARP) 0.2 0.1)) + )))) (define-public (note-name->markup pitch) "Return pitch markup for PITCH." @@ -44,8 +50,7 @@ (vector-ref #("C" "D" "E" "F" "G" "A" "B") (ly:pitch-notename pitch))) (accidental->markup (ly:pitch-alteration pitch))))) - -(define-public ((chord-name->german-markup B-instead-of-Bb) pitch) +(define-safe-public ((chord-name->german-markup B-instead-of-Bb) pitch) "Return pitch markup for PITCH, using german note names. If B-instead-of-Bb is set to #t real german names are returned. Otherwise semi-german names (with Bb and below keeping the british names) @@ -62,8 +67,7 @@ (make-normal-size-super-markup (accidental->markup (cdr n-a))))))) - -(define-public (note-name->german-markup pitch) +(define-safe-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 . ,FLAT) (6 . ,DOUBLE-FLAT))) @@ -72,18 +76,31 @@ (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) 2) )) - (list-ref '("eses" "es" "" "is" "isis") (+ 2 (/ (cdr n-a) 2) )) - )))))) + (list-ref '( "ses" "s" "" "is" "isis") (+ 2 (/ (cdr n-a) 2))) + (list-ref '("eses" "es" "" "is" "isis") (+ 2 (/ (cdr n-a) 2))))))))) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; +(define-public ((chord-name->italian-markup re-with-eacute) pitch) + "Return pitch markup for PITCH, using italian/french note names. + If re-with-eacute is set to #t, french 'ré' is returned for D instead of 're' +" + (let* ((name (ly:pitch-notename pitch)) + (alt (ly:pitch-alteration pitch))) + (make-line-markup + (list + (make-simple-markup + (vector-ref + (if re-with-eacute + #("Do" "Ré" "Mi" "Fa" "Sol" "La" "Si") + #("Do" "Re" "Mi" "Fa" "Sol" "La" "Si")) + name)) + (accidental->markup-italian alt) + )))) ;; 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) +;; perhaps the default should also be reversed --hwn +(define-safe-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 is given and non-false. @@ -116,12 +133,12 @@ FOOBAR-MARKUP) if OMIT-ROOT is given and non-false. (text (if (null? texts) #f (if omit-root (car texts) texts)))) (cons (if omit-root (cdr normalized) normalized) text))) - (define (is-req-chord? m) + (define (is-event-chord? m) (and (memq 'event-chord (ly:music-property m 'types)) (not (equal? ZERO-MOMENT (ly:music-length m))))) - (let* ((elts (filter is-req-chord? (ly:music-property seq 'elements))) + (let* ((elts (filter is-event-chord? (ly:music-property seq 'elements))) (alist (map chord-to-exception-entry elts))) (filter (lambda (x) (cdr x)) alist)))