From e1b42d290d7e53d454b6e71e36acc4f10652f186 Mon Sep 17 00:00:00 2001
From: Carl Worth <cworth@cworth.org>
Date: Tue, 17 Sep 2013 20:36:43 -0700
Subject: [PATCH] Add analysis support for octaves

It just looked stupid for scherzo to call a perfect octave, "unknown
or not a chord".
---
 scherzo.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/scherzo.c b/scherzo.c
index a13196e..7f6d5e9 100644
--- 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;
-- 
2.45.2