]> git.cworth.org Git - scherzo/commitdiff
Add analysis support for octaves
authorCarl Worth <cworth@cworth.org>
Wed, 18 Sep 2013 03:36:43 +0000 (20:36 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 18 Sep 2013 03:36:43 +0000 (20:36 -0700)
It just looked stupid for scherzo to call a perfect octave, "unknown
or not a chord".

scherzo.c

index a13196e5b802563f7f8906e7cd42157e5c7ed7c0..7f6d5e9a5862ff63a157abcac5b44271f7ca9549 100644 (file)
--- a/scherzo.c
+++ b/scherzo.c
@@ -461,6 +461,10 @@ scherzo_analyze_chord (scherzo_t *scherzo)
 
     num_notes = note_group->num_notes;
 
+    struct { int pitches[1]; const char *name; } octaves[] = {
+       { {0}, "Octave"}
+    };
+
     struct { int pitches[2]; const char *name; } intervals[] = {
        { {0, 1}, "Minor 2nd"},
        { {0, 2}, "Major 2nd"},
@@ -521,10 +525,15 @@ scherzo_analyze_chord (scherzo_t *scherzo)
 
     for (i = 0; i < num_notes; i++) {
        notes[i].relative_pitch = notes[i].midi_pitch - bass_pitch;
-       while (notes[i].relative_pitch > 12)
+       while (notes[i].relative_pitch >= 12)
            notes[i].relative_pitch -= 12;
     }
 
+    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;