X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=scherzo.c;h=7f6d5e9a5862ff63a157abcac5b44271f7ca9549;hb=e1b42d290d7e53d454b6e71e36acc4f10652f186;hp=676f5b459001412ad4ce7c4605dbc07e007cba8c;hpb=f9ffdfde546d16f24ab5d30ed9caef2c687b4755;p=scherzo diff --git a/scherzo.c b/scherzo.c index 676f5b4..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,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++) {