From 2e0e6425fe50aeecff81b46b75373b141b6d0018 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 22 Feb 2003 12:54:46 +0000 Subject: [PATCH] (construct-chord): mark inversion as bass if not present in chord. --- ChangeLog | 3 + NEWS | 4 +- input/regression/chord-name-entry.ly | 11 ++- input/regression/chord-name-styles.ly | 89 ----------------------- input/regression/chord-names.ly | 39 ---------- input/regression/chords-funky-ignatzek.ly | 1 + input/regression/chords-ignatzek.ly | 17 +++-- input/test/Cc-chords.ly | 48 ------------ input/test/chord-changes.ly | 29 -------- input/test/chord-inversion.ly | 25 ------- input/test/chord-table.ly | 48 ------------ input/test/chord-taxonomy.ly | 26 ------- scm/chord-entry.scm | 55 +++++++++----- 13 files changed, 60 insertions(+), 335 deletions(-) delete mode 100644 input/test/Cc-chords.ly delete mode 100644 input/test/chord-changes.ly delete mode 100644 input/test/chord-inversion.ly delete mode 100644 input/test/chord-table.ly delete mode 100644 input/test/chord-taxonomy.ly diff --git a/ChangeLog b/ChangeLog index 266dca26a5..27d6637f21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2003-02-22 Han-Wen Nienhuys + * scm/chord-entry.scm (construct-chord): mark inversion as bass if + not present in chord. + * lily/chord.cc: junk contents. 2003-02-17 Heikki Junes diff --git a/NEWS b/NEWS index 9c0cbc3ab2..8ee9458265 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ New features in 1.7 since 1.6 * INPUT +** Completely rewritten support for chord entry. Cleaner and more flexible. + ** Text entry is now done in a separate mode, and is more ergonomic than the previous Scheme texts. @@ -41,7 +43,7 @@ for a beamed slurred pair of eighth notes. ** Completely rewritten text formatting support. It is implemented in a completely modular way. -** Better chord names. +** Chord name formatting completely rewritten. ** Texts on multimeasure rests can be set by the user. diff --git a/input/regression/chord-name-entry.ly b/input/regression/chord-name-entry.ly index d6daa3d85e..bf08d58994 100644 --- a/input/regression/chord-name-entry.ly +++ b/input/regression/chord-name-entry.ly @@ -1,14 +1,15 @@ \header { -texidoc = "Test file for the new chordname entry code: the suffixes are printed below the pitches." +texidoc = "Test file for the new chordname entry code (@code{\chords} +mode): the suffixes are printed below the pitches." } \score { \notes { \context Voice \chords { -c1_"1" -c:7_"7" +c1_"(nothing)" +c:7_":7" c:m_":m" c:m7_":m7" c:aug_":aug" @@ -19,6 +20,7 @@ c:sus4_":sus4" c:sus2_":sus2" c:6_":6" c:m6_":m6" +c:7sus4_":7sus4" c:3-_":3-" c:3+_":3+" c:5+.3-_":5+.3-" @@ -30,7 +32,10 @@ c:m13_":m13" c:7^5_":7\\^{ }5" c^3_"\\^{ }3" c/g_"/g" +c/gis_"/gis" +c/a_"/a" c/+f_"/+f" +c/+g_"/+g" } } } diff --git a/input/regression/chord-name-styles.ly b/input/regression/chord-name-styles.ly index 63ed44f19c..e69de29bb2 100644 --- a/input/regression/chord-name-styles.ly +++ b/input/regression/chord-name-styles.ly @@ -1,89 +0,0 @@ -\header { - texidoc = " show different naming conventions" -} - -\version "1.7.10" - -scheme = \chords { - % major chords - c1 - c:6 % 6 = major triad with added sixth - c:maj % triangle = maj - c:6.9^7 % 6/9 - c:9^7 % add9 - - % minor chords - c:m % m = minor triad - c:m.6 % m6 = minor triad with added sixth - c:m.7+ % m triangle = minor major seventh chord - c:3-.6.9^7 % m6/9 - c:m.7 % m7 - c:3-.9 % m9 - c:3-.9^7 % madd9 - - % dominant chords - c:7 % 7 = dominant - c:7.5+ % +7 = augmented dominant - c:7.5- % 7b5 = hard diminished dominant - c:7+.5- % - c:7+.5+ % - - % ninth chords - c:9 % 7(9) - c:9- % 7(b9) - c:9+ % 7(#9) - c:13^9.11 % 7(13) - c:13-^9.11 % 7(b13) - c:13^11 % 7(9,13) - c:13.9-^11 % 7(b9,13) - c:13.9+^11 % 7(#9,13) - c:13-^11 % 7(9,b13) - c:13-.9-^11 % 7(b9,b13) - c:13-.9+^11 % 7(#9,b13) - - % half diminished chords - c:m5-.7 % slashed o = m7b5 - c:9.3-.5- % o/7(pure 9) - - % diminished chords - c:m5-.7- % o = diminished seventh chord - - - % suspended (?) 4ths - c:sus c:m.sus c:m7.sus - c:m7.sus^3 - c:7.4.3 - c:7.4^3.5 - c:2^3 - c:2.7^3 - c:4^5.3 - -} - -\score { - \notes < - \context ChordNames = bn { - #(set-chord-name-style 'banter) - \property ChordNames.instrument = # "Banter" - \property ChordNames.instr = #"Bn" - \scheme } - \context ChordNames = jz { - #(set-chord-name-style 'jazz) - \property ChordNames.instrument = #"Jazz" - \property ChordNames.instr = #"Jz" - \scheme } - \context ChordNames = am { - #(set-chord-name-style 'american) - \property ChordNames.instr = #"Am" - \property ChordNames.instrument = #"American" - \scheme } - \context Staff \transpose c c' \scheme - > -\paper { -linewidth = 16.0\cm - -\translator { - \ChordNamesContext \consists Instrument_name_engraver } -} -} -%% new-chords-done %% diff --git a/input/regression/chord-names.ly b/input/regression/chord-names.ly index a352c3da2f..e69de29bb2 100644 --- a/input/regression/chord-names.ly +++ b/input/regression/chord-names.ly @@ -1,39 +0,0 @@ -\version "1.7.10" -\header{ -texidoc=" -Chord names are generated from a list pitches, and are customisable -from guile. For some unlogical names, guile customisation is used -by default. -" -} - -chord = \notes\transpose c c'\chords{ - c1 - c:m - c:m5- - c:m5-.7- - c:7+ - c:m5-.7 - c:5-.7+ - c:m7 - c:7 - d - d/a - d/+gis -} - -\score{ - < - \context ChordNames \chord - \context Staff \chord - > - \paper{ - - \translator { - \ChordNamesContext - ChordName \override #'word-space = #1 - } - } -} - -%% new-chords-done %% \ No newline at end of file diff --git a/input/regression/chords-funky-ignatzek.ly b/input/regression/chords-funky-ignatzek.ly index d585c90665..1e77c4fd3a 100644 --- a/input/regression/chords-funky-ignatzek.ly +++ b/input/regression/chords-funky-ignatzek.ly @@ -12,6 +12,7 @@ chs = \notes <>1 <>1 <>1 +<>1 } diff --git a/input/regression/chords-ignatzek.ly b/input/regression/chords-ignatzek.ly index 4d7e939bb1..cf104c3968 100644 --- a/input/regression/chords-ignatzek.ly +++ b/input/regression/chords-ignatzek.ly @@ -1,28 +1,29 @@ \header { -texidoc = "Jazz chords, following [Ignatzek1995], page 17 and 18." +texidoc = " Chord names are generated from a list pitches. The +functions constructing the names are customisable. This file shows +Jazz chords, following [Ignatzek1995], page 17 and 18." } - chs = \notes \transpose c' c' { <>1 - <> + <>% m = minor triad <> <> \break <> <> - <> + <> % triangle = maj <> <> \break <> <> <> <>\break - <> - <> - <> % ?? + <> % 6 = major triad with added sixth + <> % m6 = minor triad with added sixth + <> <> \break <> <> @@ -49,7 +50,7 @@ chs = \notes \transpose c' c' <> <>\break <> - <> + <> % add9 <> } diff --git a/input/test/Cc-chords.ly b/input/test/Cc-chords.ly deleted file mode 100644 index 4d760aac69..0000000000 --- a/input/test/Cc-chords.ly +++ /dev/null @@ -1,48 +0,0 @@ -\version "1.7.10" -\header { - texidoc="Jazz chord names, but with lower case names for minor chords - -BROKEN. FIXME. -" -} - - -%%% -%% UGH UH GUG UHGUHGHGH GHG -% -- this is fucking up global name space. -% -% imagine doing -% -% lilypond Cc-chords.ly ..other-files-testing-chords... -% -% then the other files will get messed up. -%% - -%{ - -FIXME: - -%#(assoc-set! chord::names-alist-jazz -% '((0 . 0) (2 . -1)) '("")) - -%#(assoc-set! chord::names-alist-jazz -% '((0 . 0) (2 . -1) (4 . 0) (6 . -1)) '("7")) - -#(define (pitch->chord-name-text-banter pitch additions) - (let ((name (pitch->text-banter pitch))) - (if (member '(2 . -1) (map pitch->note-name additions)) - (cons (string-append - (string-downcase (substring (car name) 0 1)) - (substring (car name) 1)) - (cdr name)) - name))) -%} - - -\score { - < - #(set-chord-name-style 'jazz) - \context ChordNames \chords { c1 c:m c:m7 } - > -} -%% new-chords-done %% diff --git a/input/test/chord-changes.ly b/input/test/chord-changes.ly deleted file mode 100644 index 131561c2e0..0000000000 --- a/input/test/chord-changes.ly +++ /dev/null @@ -1,29 +0,0 @@ -\version "1.7.10" - -\header{ -texidoc="property chordChanges: only display chord names when -there's a change in the chords scheme, but always display the -chord name after a line break. -" -} - -scheme = \chords { - % ugh ugh: this breaks the output of notes in the regular staff -% \property ChordNamesVoice.chordChanges = ##t - c1:m \break c:m c:m c:m d -} - -\score { - \notes < - \context ChordNames \scheme - \context Staff \transpose c c' \scheme - > - \paper{ - linewidth = 40 * \staffspace - \translator { - \ChordNamesContext - chordChanges = ##t - } - } -} -%% new-chords-done %% diff --git a/input/test/chord-inversion.ly b/input/test/chord-inversion.ly deleted file mode 100644 index 7a1c1a67aa..0000000000 --- a/input/test/chord-inversion.ly +++ /dev/null @@ -1,25 +0,0 @@ -\version "1.7.10" -\header{ -enteredby = "jcn" -copyright = "public domain" -TestedFeatures = "chord inversions" -} - -inversions = \notes\transpose c c'\chords{ - % inversions - c1 c:sus c:6 c/e c/g - c/d % this triggers a warning: no 'd' in chord of c - - % added bass - c/+e c/+c c/+b -} - -\score{ - < - \context ChordNames \inversions - \context Staff \inversions - > -} - - -%% new-chords-done %% diff --git a/input/test/chord-table.ly b/input/test/chord-table.ly deleted file mode 100644 index e91c0cf169..0000000000 --- a/input/test/chord-table.ly +++ /dev/null @@ -1,48 +0,0 @@ -\version "1.7.10" -\header{ -filename = "chord-table.ly" -copyright = "public domain" -enteredby = "jcn" -} - -tab = \notes\transpose c c''\chords{ - c1 c:m c:4 c:m4 c:5+ c:5- c:dim c:5-.5+ c:6\break %c:m6\break -} - -\score{ - \context StaffGroup < - \context Staff=c \notes\transpose c' c\tab - \context ChordNames=c \notes\transpose c' c\tab - \context Staff=cis \notes\transpose c' cis\tab - \context ChordNames=cis \notes\transpose c' cis\tab - \context Staff=des \notes\transpose c' des\tab - \context ChordNames=des \notes\transpose c' des\tab - \context Staff=d \notes\transpose c' d\tab - \context ChordNames=d \notes\transpose c' d\tab - \context Staff=es \notes\transpose c' es\tab - \context ChordNames=es \notes\transpose c' es\tab - \context Staff=e \notes\transpose c' e\tab - \context ChordNames=e \notes\transpose c' e\tab -%{ FIXME: remove some, gs barfs - \context Staff=fis \notes\transpose c' fis\tab - \context ChordNames=fis \notes\transpose c' fis\tab - \context Staff=g \notes\transpose c' g\tab - \context ChordNames=g \notes\transpose c' g\tab - \context Staff=as \notes\transpose c' as\tab - \context ChordNames=as \notes\transpose c' as\tab - \context Staff=a \notes\transpose c' a\tab - \context ChordNames=a \notes\transpose c' a\tab - \context Staff=bes \notes\transpose c' bes,\tab - \context ChordNames=bes \notes\transpose c' bes,\tab - \context Staff=b \notes\transpose c' b,\tab - \context ChordNames=b \notes\transpose c' b,\tab -%} - > - \paper{ - textheight = \vsize - 4.0 * \staffheight - } - -} - - -%% new-chords-done %% diff --git a/input/test/chord-taxonomy.ly b/input/test/chord-taxonomy.ly deleted file mode 100644 index 8f840581b7..0000000000 --- a/input/test/chord-taxonomy.ly +++ /dev/null @@ -1,26 +0,0 @@ -\version "1.7.10" -\header { - title="Chord Taxonomy of LilyPond -- jazz" -} -scheme = \chords { - c1 - c:4 - c:9 - bes:9^7 - c:11^7 - c:9+ - % TODO - c:m5-.7 - c:m5-.7- - c:7+ - c:m7+ - } - -\score { - < - #(set-chord-name-style 'jazz) - \context ChordNames \scheme - \context Staff \notes \transpose c c' \scheme - > -} -%% new-chords-done %% diff --git a/scm/chord-entry.scm b/scm/chord-entry.scm index c4ea088b48..1101b6d7be 100644 --- a/scm/chord-entry.scm +++ b/scm/chord-entry.scm @@ -81,35 +81,51 @@ Entry point for the parser. (cdr mods))) (else (interpret-removals chord mods)) )) + (define (pitch-octavated-below p root) + "return P, but octavated, so it is below ROOT" + (ly:make-pitch + (+ + (ly:pitch-octave root) + (if (>= (ly:pitch-notename root) + (ly:pitch-notename p)) + 0 -1)) + (ly:pitch-notename p) + (ly:pitch-alteration p))) (define (process-inversion complete-chord) "Take out inversion from COMPLETE-CHORD, and put it at the bottom. Return (INVERSION . REST-OF-CHORD). Side effect: put original pitch in INVERSION. +If INVERSION is not in COMPLETE-CHORD, it will be set as a BASS, overriding +the bass specified. + " (let* ( (root (car complete-chord)) (inv? (lambda (y) - (= (ly:pitch-notename y) - (ly:pitch-notename inversion)))) + (and (= (ly:pitch-notename y) + (ly:pitch-notename inversion)) + (= (ly:pitch-alteration y) + (ly:pitch-alteration inversion)) + ))) + (rest-of-chord (filter-out-list inv? complete-chord)) (inversion-candidates (filter-list inv? complete-chord)) - (down-inversion (ly:make-pitch - (+ - (ly:pitch-octave root) - (if (>= (ly:pitch-notename root) - (ly:pitch-notename inversion)) - 0 -1)) - (ly:pitch-notename inversion) - (ly:pitch-alteration inversion))) + (down-inversion (pitch-octavated-below inversion root)) ) (if (pair? inversion-candidates) - (set! inversion (car inversion-candidates))) - - (cons down-inversion rest-of-chord) + (set! inversion (car inversion-candidates)) + (begin + (set! bass inversion) + (set! inversion #f)) + ) + (if inversion + (cons down-inversion rest-of-chord) + rest-of-chord + ) )) ;; root is always one octave too low. @@ -125,7 +141,7 @@ Side effect: put original pitch in INVERSION. (write-me "base: " base-chord) (write-me "bass: " bass))) - ;; skip the leading : , we need some of the stuff following it. + ;; skip the leading : , we need some of the stuff following it. (if (pair? flat-mods) (if (eq? (car flat-mods) 'chord-colon) (set! flat-mods (cdr flat-mods)) @@ -182,11 +198,12 @@ Side effect: put original pitch in INVERSION. ) (if inversion - (begin - (set! complete-chord (process-inversion complete-chord)) - (make-chord (cdr complete-chord) bass duration (car complete-chord) - inversion - )) + (set! complete-chord (process-inversion complete-chord))) + (if bass + (set! bass (pitch-octavated-below bass root))) + (if inversion + (make-chord (cdr complete-chord) bass duration (car complete-chord) + inversion) (make-chord complete-chord bass duration #f #f)) )) -- 2.39.2