]> git.cworth.org Git - scherzo/blobdiff - scherzo.c
Add analysis support for octaves
[scherzo] / scherzo.c
index 676f5b459001412ad4ce7c4605dbc07e007cba8c..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,6 +525,13 @@ 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)
+           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++) {