From 9f1dfa2331bdac81aa261442b44b753c115c0102 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 17 Sep 2013 14:34:55 -0700 Subject: [PATCH] Add recognition of 7th chords There's still no recognition of chords in anything but root position, (and the accidentals are still not yet drawn on the staff). --- scherzo.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scherzo.c b/scherzo.c index 9b0e2d9..7296280 100644 --- a/scherzo.c +++ b/scherzo.c @@ -417,6 +417,18 @@ scherzo_analyze_chord (scherzo_t *scherzo) { {0, 3, 6}, "Diminished triad" } }; + struct { int pitches[4]; const char *name; } sevenths[] = { + { {0, 4, 8, 11}, "Augmented/major 7" }, + { {0, 4, 7, 11}, "Major 7" }, + { {0, 4, 7, 10}, "Dominant 7" }, + { {0, 3, 7, 11}, "Minor/major 7" }, + { {0, 3, 7, 10}, "Minor 7" }, + { {0, 3, 6, 10}, "Half-diminished 7" }, + { {0, 3, 6, 9}, "Diminished 7" }, + { {0, 4, 8, 10}, "Augmented 7" }, + { {0, 3, 6, 11}, "Diminished/major 7" }, + }; + if (scherzo->chord) { score_remove_chord (scherzo->chord); scherzo->chord = NULL; @@ -451,12 +463,10 @@ scherzo_analyze_chord (scherzo_t *scherzo) chord_name = triads[i].name; } -/* - for (i = 0; i < num_sevenths; i++) { - if (_chord_signature_matches (notes, num_notes, seventh[i].pitches, 4)) - chord_name = seventh[i].name; + for (i = 0; i < ARRAY_SIZE(sevenths); i++) { + if (_chord_signature_matches (notes, num_notes, sevenths[i].pitches, 4)) + chord_name = sevenths[i].name; } -*/ if (chord_name) scherzo->chord = score_add_chord (scherzo->treble, chord_name); -- 2.43.0