]> git.cworth.org Git - scherzo/commitdiff
Don't bother looking at signatures that we know can't match
authorCarl Worth <cworth@cworth.org>
Thu, 19 Sep 2013 14:40:58 +0000 (07:40 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 19 Sep 2013 14:40:58 +0000 (07:40 -0700)
Only look at signatures which have a length the same as the number of
notes in the current chord being analyzed.

scherzo.c

index d7f78fdf6f372ba4b94d5020deeaba4547bea5e7..a1a279786b21339eec1d4dc3e597325f32e19e13 100644 (file)
--- a/scherzo.c
+++ b/scherzo.c
@@ -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)