X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fchord-generic-names.scm;h=83adcb0e4822d1ebb4501c67931fd90103e5181b;hb=02c66956a342eccc4858111ad587ce8b8a5e44b8;hp=a6d924054a108eb4c92d6979597b3453c457762f;hpb=91ffec26dcda1e4c184ee1393dc2f53193d388e7;p=lilypond.git diff --git a/scm/chord-generic-names.scm b/scm/chord-generic-names.scm index a6d924054a..83adcb0e48 100644 --- a/scm/chord-generic-names.scm +++ b/scm/chord-generic-names.scm @@ -1,8 +1,19 @@ -;;;; chord-generic-names.scm -- Compile chord names +;;;; This file is part of LilyPond, the GNU music typesetter. ;;;; -;;;; source file of the GNU LilyPond music typesetter -;;;; -;;;; (c) 2003 Jan Nieuwenhuizen +;;;; Copyright (C) 2003--2011 Jan Nieuwenhuizen +;;;; +;;;; 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 . ;;;; NOTE: this is experimental code @@ -10,6 +21,10 @@ ;;;; Naming of the base chord (steps 1-5) is handled by exceptions only ;;;; see input/test/chord-names-dpnj.ly + +(define (default-note-namer pitch) + (note-name->markup pitch #f)) + (define (markup-or-empty-markup markup) "Return MARKUP if markup, else empty-markup" (if (markup? markup) markup empty-markup)) @@ -24,47 +39,41 @@ (define-public (banter-chord-names pitches bass inversion context) (ugh-compat-double-plus-new-chord->markup - 'banter pitches bass inversion context '()) - ) - + 'banter pitches bass inversion context '())) (define-public (jazz-chord-names pitches bass inversion context) (ugh-compat-double-plus-new-chord->markup - 'jazz pitches bass inversion context '()) - ) - + 'jazz pitches bass inversion context '())) (define-public (ugh-compat-double-plus-new-chord->markup style pitches bass inversion context options) - "Entry point for New_chord_name_engraver. + "Entry point for @code{New_chord_name_engraver}. FIXME: func, options/context have changed - See -double-plus-new-chord-name.scm for the signature of STYLE. PITCHES, -BASS and INVERSION are lily pitches. OPTIONS is an alist-alist (see -input/test/dpncnt.ly). - " - +See @file{double-plus-new-chord-name.scm} for the signature of @var{style}. +@var{pitches}, @var{bass}, and @var{inversion} are lily pitches. +@var{options} is an alist-alist (see @file{input/@/test/@/dpncnt.ly})." + (define (step-nr pitch) (let* ((pitch-nr (+ (* 7 (ly:pitch-octave pitch)) (ly:pitch-notename pitch))) (root-nr (+ (* 7 (ly:pitch-octave (car pitches))) (ly:pitch-notename (car pitches))))) (+ 1 (- pitch-nr root-nr)))) - + (define (next-third pitch) (ly:pitch-transpose pitch (ly:make-pitch 0 2 (if (or (= (step-nr pitch) 3) (= (step-nr pitch) 5)) - -1 0)))) + FLAT 0)))) (define (step-alteration pitch) (let* ((diff (ly:pitch-diff (ly:make-pitch 0 0 0) (car pitches))) (normalized-pitch (ly:pitch-transpose pitch diff)) (alteration (ly:pitch-alteration normalized-pitch))) - (if (= (step-nr pitch) 7) (+ alteration 1) alteration))) - + (if (= (step-nr pitch) 7) (+ alteration SEMI-TONE) alteration))) + (define (pitch-unalter pitch) (let ((alteration (step-alteration pitch))) (if (= alteration 0) @@ -84,12 +93,12 @@ input/test/dpncnt.ly). (make-simple-markup (number->string (step-nr pitch))) (make-simple-markup (case (step-alteration pitch) - ((-2) "--") - ((-1) "-") - ((0) "") - ((1) "+") - ((2) "++")))))) - + ((DOUBLE-FLAT) "--") + ((FLAT) "-") + ((NATURAL) "") + ((SHARP) "+") + ((DOUBLE-SHARP) "++")))))) + (define (step->markup-accidental pitch) (make-line-markup (list (accidental->markup (step-alteration pitch)) @@ -99,19 +108,19 @@ input/test/dpncnt.ly). (make-line-markup (if (and (= (step-nr pitch) 7) (= (step-alteration pitch) 1)) - (list (ly:get-context-property context 'majorSevenSymbol)) + (list (ly:context-property context 'majorSevenSymbol)) (list (accidental->markup (step-alteration pitch)) (make-simple-markup (number->string (step-nr pitch))))))) - + ;; tja, kennok (define (make-sub->markup step->markup) (lambda (pitch) (make-line-markup (list (make-simple-markup "no") (step->markup pitch))))) - + (define (step-based-sub->markup step->markup pitch) (make-line-markup (list (make-simple-markup "no") (step->markup pitch)))) - + (define (get-full-list pitch) (if (<= (step-nr pitch) (step-nr (last pitches))) (cons pitch (get-full-list (next-third pitch))) @@ -139,19 +148,19 @@ input/test/dpncnt.ly). (if (pair? exceptions) (let* ((e (car exceptions)) (e-pitches (car e))) - (if (equal? e-pitches (take pitches (length e-pitches) )) + (if (equal? e-pitches (take pitches (length e-pitches))) e (partial-match (cdr exceptions)))) #f)) - (if #f (begin + (if #f (begin (write-me "pitches: " pitches))) (let* ((full-exceptions - (ly:get-context-property context 'chordNameExceptionsFull)) + (ly:context-property context 'chordNameExceptionsFull)) (full-exception (full-match full-exceptions)) (full-markup (if full-exception (cadr full-exception) '())) (partial-exceptions - (ly:get-context-property context 'chordNameExceptionsPartial)) + (ly:context-property context 'chordNameExceptionsPartial)) (partial-exception (partial-match partial-exceptions)) (partial-pitches (if partial-exception (car partial-exception) '())) (partial-markup-prefix @@ -165,9 +174,9 @@ input/test/dpncnt.ly). ;; kludge alert: replace partial matched lower part of all with ;; 'normal' pitches from full ;; (all pitches) - (all (append (take full (length partial-pitches) ) - (drop pitches (length partial-pitches) ))) - + (all (append (take full (length partial-pitches)) + (drop pitches (length partial-pitches)))) + (highest (last all)) (missing (list-minus full (map pitch-unalter all))) (consecutive (get-consecutive 1 all)) @@ -175,7 +184,7 @@ input/test/dpncnt.ly). (altered (filter step-even-or-altered? all)) (cons-alt (filter step-even-or-altered? consecutive)) (base (list-minus consecutive altered))) - + (if #f (begin (write-me "full:" full) @@ -195,22 +204,22 @@ input/test/dpncnt.ly). ;; root ;; + steps:altered + (highest all -- if not altered) ;; + subs:missing - - (let* ((root->markup (assoc-get-default - 'root->markup options note-name->markup)) - (step->markup (assoc-get-default + + (let* ((root->markup (assoc-get + 'root->markup options default-note-namer)) + (step->markup (assoc-get 'step->markup options step->markup-plusminus)) - (sub->markup (assoc-get-default + (sub->markup (assoc-get 'sub->markup options (lambda (x) (step-based-sub->markup step->markup x)))) - (sep (assoc-get-default + (sep (assoc-get 'separator options (make-simple-markup "/")))) - + (if (pair? full-markup) (make-line-markup (list (root->markup root) full-markup)) - + (make-line-markup (list (root->markup root) @@ -227,29 +236,29 @@ input/test/dpncnt.ly). (list partial-markup-suffix) (list (map sub->markup missing))) sep))))))) - - + + ((jazz) ;; root ;; + steps:(highest base) + cons-alt ;; + 'add' ;; + steps:rest - (let* ((root->markup (assoc-get-default - 'root->markup options note-name->markup)) + (let* ((root->markup (assoc-get + 'root->markup options default-note-namer)) (step->markup - (assoc-get-default + (assoc-get ;; FIXME: ignatzek ;;'step->markup options step->markup-accidental)) 'step->markup options step->markup-ignatzek)) - (sep (assoc-get-default + (sep (assoc-get 'separator options (make-simple-markup " "))) - (add-prefix (assoc-get-default 'add-prefix options + (add-prefix (assoc-get 'add-prefix options (make-simple-markup " add")))) - + (if (pair? full-markup) (make-line-markup (list (root->markup root) full-markup)) - + (make-line-markup (list (root->markup root) @@ -257,11 +266,11 @@ input/test/dpncnt.ly). (make-normal-size-super-markup (make-line-markup (list - + ;; kludge alert: omit <= 5 ;;(markup-join (map step->markup ;; (cons (last base) cons-alt)) sep) - + ;; This fixes: ;; c C5 -> C ;; c:2 C5 2 -> C2 @@ -273,11 +282,11 @@ input/test/dpncnt.ly). (if (> (step-nr tb) 5) (cons tb cons-alt) cons-alt))) sep) - + (if (pair? rest) add-prefix empty-markup) (markup-join (map step->markup rest) sep) partial-markup-suffix)))))))) - + (else empty-markup))))