X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fchord-name.scm;h=0542893cc02726e42a400f494d861d8dec90ce66;hb=b92ea16ef75d8aaa7bdb9f492b58d7af906e7945;hp=c49443f2ef6e719a9e9cceed856fee193eba9e0d;hpb=5842c0a15dc9683fc74996c6703ea33d4dd43ad0;p=lilypond.git diff --git a/scm/chord-name.scm b/scm/chord-name.scm index c49443f2ef..0542893cc0 100644 --- a/scm/chord-name.scm +++ b/scm/chord-name.scm @@ -1,9 +1,20 @@ -;;;; chord-name.scm -- chord name utility functions +;;;; This file is part of LilyPond, the GNU music typesetter. ;;;; -;;;; source file of the GNU LilyPond music typesetter -;;;; -;;;; (c) 2000--2007 Jan Nieuwenhuizen +;;;; Copyright (C) 2000--2011 Jan Nieuwenhuizen ;;;; Han-Wen Nienhuys +;;;; +;;;; LilyPond is free software: you can redistribute it and/or modify +;;;; it under the terms of the GNU General Public License as published by +;;;; the Free Software Foundation, either version 3 of the License, or +;;;; (at your option) any later version. +;;;; +;;;; LilyPond is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;;; GNU General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU General Public License +;;;; along with LilyPond. If not, see . (define (natural-chord-alteration p) "Return the natural alteration for step P." @@ -11,11 +22,16 @@ FLAT 0)) -;; +(define (conditional-string-downcase str condition) + (if condition + (string-downcase str) + str)) + +;; ;; TODO: make into markup. -;; +;; (define-public (alteration->text-accidental-markup alteration) - + (make-smaller-markup (make-raise-markup (if (= alteration FLAT) @@ -23,7 +39,7 @@ 0.6) (make-musicglyph-markup (assoc-get alteration standard-alteration-glyph-name-alist ""))))) - + (define (accidental->markup alteration) "Return accidental markup for ALTERATION." (if (= alteration 0) @@ -43,18 +59,21 @@ (make-hspace-markup (if (= alteration SHARP) 0.2 0.1)) )))) -(define-public (note-name->markup pitch) - "Return pitch markup for PITCH." +(define-public (note-name->markup pitch lowercase?) + "Return pitch markup for @var{pitch}." (make-line-markup (list (make-simple-markup - (vector-ref #("C" "D" "E" "F" "G" "A" "B") (ly:pitch-notename pitch))) - (accidental->markup (ly:pitch-alteration pitch))))) + (conditional-string-downcase + (vector-ref #("C" "D" "E" "F" "G" "A" "B") (ly:pitch-notename pitch)) + lowercase?)) + (accidental->markup (ly:pitch-alteration pitch))))) (define (pitch-alteration-semitones pitch) (inexact->exact (round (* (ly:pitch-alteration pitch) 2)))) -(define-safe-public ((chord-name->german-markup B-instead-of-Bb) pitch) +(define-safe-public ((chord-name->german-markup B-instead-of-Bb) + pitch lowercase?) "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) @@ -67,11 +86,13 @@ (make-line-markup (list (make-simple-markup - (vector-ref #("C" "D" "E" "F" "G" "A" "H" "B") (car n-a))) + (conditional-string-downcase + (vector-ref #("C" "D" "E" "F" "G" "A" "H" "B") (car n-a)) + lowercase?)) (make-normal-size-super-markup (accidental->markup (/ (cdr n-a) 2))))))) -(define-safe-public (note-name->german-markup pitch) +(define-safe-public (note-name->german-markup pitch lowercase?) (let* ((name (ly:pitch-notename pitch)) (alt-semitones (pitch-alteration-semitones pitch)) (n-a (if (member (cons name alt-semitones) `((6 . -1) (6 . -2))) @@ -85,20 +106,23 @@ (list-ref '( "ses" "s" "" "is" "isis") (+ 2 (cdr n-a))) (list-ref '("eses" "es" "" "is" "isis") (+ 2 (cdr n-a))))))))) -(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' -" +(define-public ((chord-name->italian-markup re-with-eacute) pitch lowercase?) + "Return pitch markup for @var{pitch}, using Italian/@/French note names. +If @var{re-with-eacute} is set to @code{#t}, french `ré' is returned for +pitch@tie{}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)) + (conditional-string-downcase + (vector-ref + (if re-with-eacute + #("Do" "Ré" "Mi" "Fa" "Sol" "La" "Si") + #("Do" "Re" "Mi" "Fa" "Sol" "La" "Si")) + name) + lowercase?)) (accidental->markup-italian alt) )))) @@ -120,7 +144,7 @@ FOOBAR-MARKUP) if OMIT-ROOT is given and non-false. elts))) (sorted (sort pitches ly:pitch ..., @@ -146,3 +170,31 @@ FOOBAR-MARKUP) if OMIT-ROOT is given and non-false. (alist (map chord-to-exception-entry elts))) (filter (lambda (x) (cdr x)) alist))) +(define-public (capo-handler pitches bass inversion context) + (let ((chord-function + (ly:context-property context 'chordNameFunction 'jazz-chord-names)) + (capo-pitch (ly:context-property context 'capoPitch #f))) + (if (not capo-pitch) + (chord-function pitches bass inversion context) ;; call the chordNameFunction as of old + (let* ((new-pitches ;; else transpose the pitches and do the chord twice + (map (lambda (p) + (ly:pitch-transpose p capo-pitch)) + pitches)) + (new-bass + (if (ly:pitch? bass) + (ly:pitch-transpose bass capo-pitch) + '())) + (new-inversion + (if (ly:pitch? inversion) + (ly:pitch-transpose inversion capo-pitch) + '())) + (capo-markup + (make-parenthesize-markup + (chord-function new-pitches new-bass new-inversion context))) + (name-markup (chord-function pitches bass inversion context)) + (capo-vertical (ly:context-property context 'capoVertical #f))) + (if capo-vertical + (make-column-markup (list name-markup capo-markup)) + (make-line-markup (list name-markup + (make-hspace-markup 1) + capo-markup)))))))