]> git.cworth.org Git - scherzo/blobdiff - scherzo.c
Don't bother looking at signatures that we know can't match
[scherzo] / scherzo.c
index ae95d647ff5f393769858b08455f495721afdc30..a1a279786b21339eec1d4dc3e597325f32e19e13 100644 (file)
--- a/scherzo.c
+++ b/scherzo.c
@@ -484,14 +484,14 @@ scherzo_analyze_chord (scherzo_t *scherzo)
 
     struct { int pitches[4]; const char *name; } sevenths[] = {
        { {0, 4, 8, 11}, "Augmented/major 7" },
+       { {0, 4, 8, 10}, "Augmented 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" },
+       { {0, 3, 6, 10}, "Half-diminished 7" },
+       { {0, 3, 6, 9},  "Diminished 7" }
     };
 
     if (scherzo->chord) {
@@ -556,24 +556,31 @@ scherzo_analyze_chord (scherzo_t *scherzo)
            }
     }
 
-    for (i = 0; i < ARRAY_SIZE (octaves); i++) {
-       if (_chord_signature_matches (notes, num_notes, octaves[i].pitches, 1))
-           chord_name = octaves[i].name;
-    }
-
-    for (i = 0; i < ARRAY_SIZE (intervals); i++) {
-       if (_chord_signature_matches (notes, num_notes, intervals[i].pitches, 2))
-           chord_name = intervals[i].name;
-    }
-
-    for (i = 0; i < ARRAY_SIZE (triads); i++) {
-       if (_chord_signature_matches (notes, num_notes, triads[i].pitches, 3))
-           chord_name = triads[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;
+    switch (num_notes) {
+    case 1:
+       for (i = 0; i < ARRAY_SIZE (octaves); i++) {
+           if (_chord_signature_matches (notes, num_notes, octaves[i].pitches, 1))
+               chord_name = octaves[i].name;
+       }
+       break;
+    case 2:
+       for (i = 0; i < ARRAY_SIZE (intervals); i++) {
+           if (_chord_signature_matches (notes, num_notes, intervals[i].pitches, 2))
+               chord_name = intervals[i].name;
+       }
+       break;
+    case 3:
+       for (i = 0; i < ARRAY_SIZE (triads); i++) {
+           if (_chord_signature_matches (notes, num_notes, triads[i].pitches, 3))
+               chord_name = triads[i].name;
+       }
+       break;
+    case 4:
+       for (i = 0; i < ARRAY_SIZE(sevenths); i++) {
+           if (_chord_signature_matches (notes, num_notes, sevenths[i].pitches, 4))
+               chord_name = sevenths[i].name;
+       }
+       break;
     }
 
     if (chord_name)