- struct { modified_degree_t degrees[3]; const char *name; } trichords[] = {
- /* Triads */
- { {{1, 0}, {3, +1}, {5, 0}}, "sus" },
- { {{1, 0}, {3, 0}, {5, +1}}, SUP "+" PUS },
- { {{1, 0}, {3, 0}, {5, 0}}, "" },
- { {{1, 0}, {3, -1}, {5, 0}}, "m" },
- { {{1, 0}, {3, -1}, {5, -1}}, "°" },
- { {{1, 0}, {2, 0}, {5, 0}}, "msus2" },
- /* Seventh chords with no 3rd */
- { {{1, 0}, {5, +1}, {7, 0}}, SUP "+M7" PUS },
- { {{1, 0}, {5, +1}, {7, -1}}, SUP "+7" PUS },
- { {{1, 0}, {5, 0}, {7, 0}}, "M7" },
- { {{1, 0}, {5, 0}, {7, -1}}, "7" },
- { {{1, 0}, {5, -1}, {7, -1}}, "7♭5" },
- /* Seventh chords with no 5th */
- { {{1, 0}, {4, 0}, {7, 0}}, "M7sus" },
- { {{1, 0}, {4, 0}, {7, -1}}, "7sus" },
- { {{1, 0}, {3, 0}, {7, 0}}, "M7" },
- { {{1, 0}, {3, 0}, {7, -1}}, "7" },
- { {{1, 0}, {3, -1}, {7, 0}}, "m" SUP "M7" PUS },
- { {{1, 0}, {3, -1}, {7, -1}}, "m7" },
- { {{1, 0}, {2, 0}, {7, 0}}, "m" SUP "M7" PUS "sus2" },
- { {{1, 0}, {2, 0}, {7, -1}}, "m7sus2" },
- };
-
- struct { modified_degree_t degrees[4]; const char *name; } tetrachords[] = {
- /* Sixth chords */
- { {{1, 0}, {4, 0}, {5, 0}, {6, 0}}, "6sus" },
- { {{1, 0}, {3, 0}, {5, 0}, {6, 0}}, "6" }, /* Ambiguous with m7 */
- { {{1, 0}, {3, -1}, {5, 0}, {6, 0}}, "m6" },
- { {{1, 0}, {2, 0}, {5, 0}, {6, 0}}, "m6sus2" },
- /* Seventh chords */
- { {{1, 0}, {4, 0}, {5, +1}, {7, 0}}, SUP "+M7" PUS "sus" },
- { {{1, 0}, {4, 0}, {5, +1}, {7, -1}}, SUP "+7" PUS "sus" },
- { {{1, 0}, {4, 0}, {5, 0}, {7, 0}}, "M7sus" },
- { {{1, 0}, {4, 0}, {5, 0}, {7, -1}}, "7sus" },
- { {{1, 0}, {4, 0}, {5, -1}, {7, -1}}, "7♭5sus" },
- { {{1, 0}, {3, 0}, {5, +1}, {7, 0}}, SUP "+M7" PUS },
- { {{1, 0}, {3, 0}, {5, +1}, {7, -1}}, SUP "+7" PUS },
- { {{1, 0}, {3, 0}, {5, 0}, {7, 0}}, "M7" },
- { {{1, 0}, {3, 0}, {5, 0}, {7, -1}}, "7" },
- { {{1, 0}, {3, 0}, {5, -1}, {7, -1}}, "7♭5" },
- { {{1, 0}, {3, -1}, {5, 0}, {7, 0}}, "m" SUP "M7" PUS },
- { {{1, 0}, {3, -1}, {5, 0}, {7, -1}}, "m7" },
- { {{1, 0}, {3, -1}, {5, -1}, {7, 0}}, "°" SUP "M7" PUS },
- { {{1, 0}, {3, -1}, {5, -1}, {7, -1}}, "𝆩" SUP "7" PUS },
- { {{1, 0}, {3, -1}, {5, -1}, {7, -2}}, "°" SUP "7" PUS },
- { {{1, 0}, {2, 0}, {5, 0}, {7, 0}}, "m" SUP "M7" PUS "sus2" },
- { {{1, 0}, {2, 0}, {5, 0}, {7, -1}}, "m7sus2" },
- { {{1, 0}, {2, 0}, {5, -1}, {7, 0}}, "°" SUP "M7" PUS "sus2" },
- { {{1, 0}, {2, 0}, {5, -1}, {7, -1}}, "𝆩" SUP "7" PUS "sus2" },
- { {{1, 0}, {2, 0}, {5, -1}, {7, -2}}, "°" SUP "7" PUS "sus2" }, /* Ambiguous with 7 */
- /* Ninth chords voiced with no 5th */
- { {{1, 0}, {9, 0}, {4, 0}, {7, 0}}, "M9sus" },
- { {{1, 0}, {9, 0}, {4, 0}, {7, -1}}, "9sus" },
- { {{1, 0}, {9, 0}, {3, 0}, {7, 0}}, "M9" },
- { {{1, 0}, {9, 0}, {3, 0}, {7, -1}}, "9" },
- { {{1, 0}, {9, 0}, {3, -1}, {7, 0}}, "m" SUP "M9" PUS },
- { {{1, 0}, {9, 0}, {3, -1}, {7, -1}}, "m9" },
- { {{1, 0}, {9, -1}, {3, -1}, {7, -1}}, "m♭9" },
- { {{1, 0}, {9, 0}, {3, -1}, {6, 0}}, "m6/9" },
- { {{1, 0}, {9, -1}, {3, -1}, {6, 0}}, "m6/♭9" },
- };
-
- /* The sorting here is funny to keep the array in degree order
- * after reducing each degree to an actual scale degree, (9 -> 2,
- * 11 -> 4, 13 -> 6) */
- struct { modified_degree_t degrees[5]; const char *name; } pentachords[] = {
- /* Sixth plus 9 */
- { {{1, 0}, {9, 0}, {3, 0}, {5, 0}, {6, 0}}, "6/9" },
- { {{1, 0}, {9, 0}, {3, -1}, {5, 0}, {6, 0}}, "m6/9" },
- { {{1, 0}, {9, -1}, {3, -1}, {5, 0}, {6, 0}}, "m6/♭9" },
- /* Seventh plus altered 9 */
- { {{1, 0}, {9, +1}, {3, 0}, {5, 0}, {7, -1}}, "7♯9" },
- { {{1, 0}, {9, -1}, {3, 0}, {5, 0}, {7, -1}}, "7♭9" },
- { {{1, 0}, {9, +1}, {3, 0}, {5, -1}, {7, -1}}, "7♭5♯9" },
- { {{1, 0}, {9, -1}, {3, 0}, {5, -1}, {7, -1}}, "7♭5♭9" },
- /* Ninth chords */
- { {{1, 0}, {9, 0}, {4, 0}, {5, +1}, {7, 0}}, SUP "+M9" PUS "sus" },
- { {{1, 0}, {9, 0}, {4, 0}, {5, +1}, {7, -1}}, SUP "+9" PUS "sus" },
- { {{1, 0}, {9, 0}, {4, 0}, {5, 0}, {7, 0}}, "M9sus" },
- { {{1, 0}, {9, 0}, {4, 0}, {5, 0}, {7, -1}}, "9sus" },
-
- { {{1, 0}, {9, 0}, {3, 0}, {5, +1}, {7, 0}}, SUP "+M9" PUS },
- { {{1, 0}, {9, 0}, {3, 0}, {5, +1}, {7, -1}}, SUP "+9" PUS },
-
- { {{1, 0}, {9, 0}, {3, 0}, {5, 0}, {7, 0}}, "M9" },
- { {{1, 0}, {9, 0}, {3, 0}, {5, 0}, {7, -1}}, "9" },
- { {{1, 0}, {9, 0}, {3, -1}, {5, 0}, {7, 0}}, "m" SUP "M9" PUS },
- { {{1, 0}, {9, 0}, {3, -1}, {5, 0}, {7, -1}}, "m9" },
- { {{1, 0}, {9, -1}, {3, -1}, {5, 0}, {7, -1}}, "m♭9" },
- { {{1, 0}, {9, 0}, {3, 0}, {5, -1}, {7, 0}}, "M9" SUP "♭5" PUS },
- { {{1, 0}, {9, 0}, {3, 0}, {5, -1}, {7, -1}}, "9" SUP "♭5" PUS },
- { {{1, 0}, {9, 0}, {3, -1}, {5, -1}, {7, 0}}, "m" SUP "M9♭5" PUS },
- { {{1, 0}, {9, 0}, {3, -1}, {5, -1}, {7, -1}}, "𝆩" SUP "9" PUS },
- { {{1, 0}, {9, -1}, {3, -1}, {5, -1}, {7, -1}}, "𝆩" SUP "♭9" PUS },
- { {{1, 0}, {9, 0}, {3, -1}, {5, -1}, {7, -2}}, "°" SUP "9" PUS },
- { {{1, 0}, {9, -1}, {3, -1}, {5, -1}, {7, -2}}, "°" SUP "♭9" PUS },
- };
-
- struct { modified_degree_t degrees[6]; const char *name; } hexachords[] = {
- { {{1, 0}, {9, 0}, {3, 0}, {11, 0}, {5, +1}, {7, 0}}, SUP "+M11" PUS },
- { {{1, 0}, {9, 0}, {3, 0}, {11, 0}, {5, +1}, {7, -1}}, SUP "+11" PUS },
- { {{1, 0}, {9, 0}, {3, 0}, {11, 0}, {5, 0}, {7, 0}}, "M11" },
- { {{1, 0}, {9, 0}, {3, 0}, {11, 0}, {5, 0}, {7, -1}}, "11" },
- { {{1, 0}, {9, 0}, {3, -1}, {11, 0}, {5, 0}, {7, 0}}, "m" SUP "M11" PUS },
- { {{1, 0}, {9, 0}, {3, -1}, {11, 0}, {5, 0}, {7, -1}}, "m11" },
- { {{1, 0}, {9, -1}, {3, -1}, {11, 0}, {5, -1}, {7, -1}}, "𝆩" SUP "11" PUS },
- { {{1, 0}, {9, -1}, {3, -1}, {11, -1}, {5, -1}, {7, -2}}, "°" SUP "11" PUS }
- };
-
- if (scherzo->chord) {
- score_remove_chord (scherzo->chord);
- scherzo->chord = NULL;
+chord_signature_t signatures[] = {
+ /* Octave */
+ { 1, {{1, 0}}, "P8" },
+
+ /* Intervals */
+ { 2, {{1, 0}, {2, -1}}, "m2" },
+ { 2, {{1, 0}, {2, 0}}, "M2" },
+ { 2, {{1, 0}, {3, -1}}, "m3" },
+ { 2, {{1, 0}, {3, 0}}, "M3" },
+ { 2, {{1, 0}, {4, 0}}, "P4" },
+ { 2, {{1, 0}, {5, -1}}, "Tri-tone" },
+ { 2, {{1, 0}, {5, 0}}, "P5" },
+ { 2, {{1, 0}, {6, -1}}, "m6" },
+ { 2, {{1, 0}, {6, 0}}, "M6" },
+ { 2, {{1, 0}, {7, -1}}, "m7" },
+ { 2, {{1, 0}, {7, 0}}, "M7" },
+
+ /* Triads */
+ { 3, {{1, 0}, {4, 0}, {5, 0}}, "sus" },
+ { 3, {{1, 0}, {3, 0}, {5, +1}}, SUP "+" PUS },
+ { 3, {{1, 0}, {3, 0}, {5, 0}}, "" },
+ { 3, {{1, 0}, {3, -1}, {5, 0}}, "m" },
+ { 3, {{1, 0}, {3, -1}, {5, -1}}, "°" },
+ { 3, {{1, 0}, {2, 0}, {5, 0}}, "msus2" },
+
+ /* Seventh chords with no 3rd */
+ { 3, {{1, 0}, {5, +1}, {7, 0}}, SUP "+M7" PUS },
+ { 3, {{1, 0}, {5, +1}, {7, -1}}, SUP "+7" PUS },
+ { 3, {{1, 0}, {5, 0}, {7, 0}}, "M7" },
+ { 3, {{1, 0}, {5, 0}, {7, -1}}, "7" },
+ { 3, {{1, 0}, {5, -1}, {7, -1}}, "7♭5" },
+
+ /* Seventh chords with no 5th */
+ { 3, {{1, 0}, {4, 0}, {7, 0}}, "M7sus" },
+ { 3, {{1, 0}, {4, 0}, {7, -1}}, "7sus" },
+ { 3, {{1, 0}, {3, 0}, {7, 0}}, "M7" },
+ { 3, {{1, 0}, {3, 0}, {7, -1}}, "7" },
+ { 3, {{1, 0}, {3, -1}, {7, 0}}, "m" SUP "M7" PUS },
+ { 3, {{1, 0}, {3, -1}, {7, -1}}, "m7" },
+ { 3, {{1, 0}, {2, 0}, {7, 0}}, "m" SUP "M7" PUS "sus2" },
+ { 3, {{1, 0}, {2, 0}, {7, -1}}, "m7sus2" },
+
+ /* Sixth chords */
+ { 4, {{1, 0}, {4, 0}, {5, 0}, {6, 0}}, "6sus" },
+ { 4, {{1, 0}, {3, 0}, {5, 0}, {6, 0}}, "6" }, /* Ambiguous with m7 */
+ { 4, {{1, 0}, {3, -1}, {5, 0}, {6, 0}}, "m6" },
+ { 4, {{1, 0}, {2, 0}, {5, 0}, {6, 0}}, "m6sus2" },
+
+ /* Seventh chords */
+ { 4, {{1, 0}, {4, 0}, {5, +1}, {7, 0}}, SUP "+M7" PUS "sus" },
+ { 4, {{1, 0}, {4, 0}, {5, +1}, {7, -1}}, SUP "+7" PUS "sus" },
+ { 4, {{1, 0}, {4, 0}, {5, 0}, {7, 0}}, "M7sus" },
+ { 4, {{1, 0}, {4, 0}, {5, 0}, {7, -1}}, "7sus" },
+ { 4, {{1, 0}, {4, 0}, {5, -1}, {7, -1}}, "7♭5sus" },
+ { 4, {{1, 0}, {3, 0}, {5, +1}, {7, 0}}, SUP "+M7" PUS },
+ { 4, {{1, 0}, {3, 0}, {5, +1}, {7, -1}}, SUP "+7" PUS },
+ { 4, {{1, 0}, {3, 0}, {5, 0}, {7, 0}}, "M7" },
+ { 4, {{1, 0}, {3, 0}, {5, 0}, {7, -1}}, "7" },
+ { 4, {{1, 0}, {3, 0}, {5, -1}, {7, -1}}, "7♭5" },
+ { 4, {{1, 0}, {3, -1}, {5, 0}, {7, 0}}, "m" SUP "M7" PUS },
+ { 4, {{1, 0}, {3, -1}, {5, 0}, {7, -1}}, "m7" },
+ { 4, {{1, 0}, {3, -1}, {5, -1}, {7, 0}}, "°" SUP "M7" PUS },
+ { 4, {{1, 0}, {3, -1}, {5, -1}, {7, -1}}, "𝆩" SUP "7" PUS },
+ { 4, {{1, 0}, {3, -1}, {5, -1}, {7, -2}}, "°" SUP "7" PUS },
+ { 4, {{1, 0}, {2, 0}, {5, 0}, {7, 0}}, "m" SUP "M7" PUS "sus2" },
+ { 4, {{1, 0}, {2, 0}, {5, 0}, {7, -1}}, "m7sus2" },
+ { 4, {{1, 0}, {2, 0}, {5, -1}, {7, 0}}, "°" SUP "M7" PUS "sus2" },
+ { 4, {{1, 0}, {2, 0}, {5, -1}, {7, -1}}, "𝆩" SUP "7" PUS "sus2" },
+ { 4, {{1, 0}, {2, 0}, {5, -1}, {7, -2}}, "°" SUP "7" PUS "sus2" }, /* Ambiguous with 7 */
+
+ /* The sorting for chords with degree higher than 9 is funny
+ * to keep the array in degree order after reducing each
+ * degree to an actual scale degree, (9 -> 2, 11 -> 4, 13 ->
+ * 6) */
+
+ /* Ninth chords voiced with no 5th */
+ { 4, {{1, 0}, {9, 0}, {4, 0}, {7, 0}}, "M9sus" },
+ { 4, {{1, 0}, {9, 0}, {4, 0}, {7, -1}}, "9sus" },
+ { 4, {{1, 0}, {9, 0}, {3, 0}, {7, 0}}, "M9" },
+ { 4, {{1, 0}, {9, 0}, {3, 0}, {7, -1}}, "9" },
+ { 4, {{1, 0}, {9, 0}, {3, -1}, {7, 0}}, "m" SUP "M9" PUS },
+ { 4, {{1, 0}, {9, 0}, {3, -1}, {7, -1}}, "m9" },
+ { 4, {{1, 0}, {9, -1}, {3, -1}, {7, -1}}, "m♭9" },
+ { 4, {{1, 0}, {9, 0}, {3, -1}, {6, 0}}, "m6/9" },
+ { 4, {{1, 0}, {9, -1}, {3, -1}, {6, 0}}, "m6/♭9" },
+
+ /* Sixth plus 9 */
+ { 5, {{1, 0}, {9, 0}, {3, 0}, {5, 0}, {6, 0}}, "6/9" },
+ { 5, {{1, 0}, {9, 0}, {3, -1}, {5, 0}, {6, 0}}, "m6/9" },
+ { 5, {{1, 0}, {9, -1}, {3, -1}, {5, 0}, {6, 0}}, "m6/♭9" },
+
+ /* Seventh plus altered 9 */
+ { 5, {{1, 0}, {9, +1}, {3, 0}, {5, 0}, {7, -1}}, "7♯9" },
+ { 5, {{1, 0}, {9, -1}, {3, 0}, {5, 0}, {7, -1}}, "7♭9" },
+ { 5, {{1, 0}, {9, +1}, {3, 0}, {5, -1}, {7, -1}}, "7♭5♯9" },
+ { 5, {{1, 0}, {9, -1}, {3, 0}, {5, -1}, {7, -1}}, "7♭5♭9" },
+
+ /* Ninth chords */
+ { 5, {{1, 0}, {9, 0}, {4, 0}, {5, +1}, {7, 0}}, SUP "+M9" PUS "sus" },
+ { 5, {{1, 0}, {9, 0}, {4, 0}, {5, +1}, {7, -1}}, SUP "+9" PUS "sus" },
+ { 5, {{1, 0}, {9, 0}, {4, 0}, {5, 0}, {7, 0}}, "M9sus" },
+ { 5, {{1, 0}, {9, 0}, {4, 0}, {5, 0}, {7, -1}}, "9sus" },
+ { 5, {{1, 0}, {9, 0}, {3, 0}, {5, +1}, {7, 0}}, SUP "+M9" PUS },
+ { 5, {{1, 0}, {9, 0}, {3, 0}, {5, +1}, {7, -1}}, SUP "+9" PUS },
+ { 5, {{1, 0}, {9, 0}, {3, 0}, {5, 0}, {7, 0}}, "M9" },
+ { 5, {{1, 0}, {9, 0}, {3, 0}, {5, 0}, {7, -1}}, "9" },
+ { 5, {{1, 0}, {9, 0}, {3, -1}, {5, 0}, {7, 0}}, "m" SUP "M9" PUS },
+ { 5, {{1, 0}, {9, 0}, {3, -1}, {5, 0}, {7, -1}}, "m9" },
+ { 5, {{1, 0}, {9, -1}, {3, -1}, {5, 0}, {7, -1}}, "m♭9" },
+ { 5, {{1, 0}, {9, 0}, {3, 0}, {5, -1}, {7, 0}}, "M9" SUP "♭5" PUS },
+ { 5, {{1, 0}, {9, 0}, {3, 0}, {5, -1}, {7, -1}}, "9" SUP "♭5" PUS },
+ { 5, {{1, 0}, {9, 0}, {3, -1}, {5, -1}, {7, 0}}, "m" SUP "M9♭5" PUS },
+ { 5, {{1, 0}, {9, 0}, {3, -1}, {5, -1}, {7, -1}}, "𝆩" SUP "9" PUS },
+ { 5, {{1, 0}, {9, -1}, {3, -1}, {5, -1}, {7, -1}}, "𝆩" SUP "♭9" PUS },
+ { 5, {{1, 0}, {9, 0}, {3, -1}, {5, -1}, {7, -2}}, "°" SUP "9" PUS },
+ { 5, {{1, 0}, {9, -1}, {3, -1}, {5, -1}, {7, -2}}, "°" SUP "♭9" PUS },
+
+ /* Eleventh chords */
+ { 6, {{1, 0}, {9, 0}, {3, 0}, {11, 0}, {5, +1}, {7, 0}}, SUP "+M11" PUS },
+ { 6, {{1, 0}, {9, 0}, {3, 0}, {11, 0}, {5, +1}, {7, -1}}, SUP "+11" PUS },
+ { 6, {{1, 0}, {9, 0}, {3, 0}, {11, 0}, {5, 0}, {7, 0}}, "M11" },
+ { 6, {{1, 0}, {9, 0}, {3, 0}, {11, 0}, {5, 0}, {7, -1}}, "11" },
+ { 6, {{1, 0}, {9, 0}, {3, -1}, {11, 0}, {5, 0}, {7, 0}}, "m" SUP "M11" PUS },
+ { 6, {{1, 0}, {9, 0}, {3, -1}, {11, 0}, {5, 0}, {7, -1}}, "m11" },
+ { 6, {{1, 0}, {9, -1}, {3, -1}, {11, 0}, {5, -1}, {7, -1}}, "𝆩" SUP "11" PUS },
+ { 6, {{1, 0}, {9, -1}, {3, -1}, {11, -1}, {5, -1}, {7, -2}}, "°" SUP "11" PUS }
+};
+
+static void
+scherzo_adjust_pitch_to_match_modified_degree (pitch_t *pitch,
+ pitch_t root,
+ modified_degree_t *degree)
+{
+ pitch_name_t name = PITCH_NAME (*pitch);
+ pitch_accidental_t accidental = PITCH_ACCIDENTAL (*pitch);
+ int octave = PITCH_OCTAVE (*pitch);
+ int degree_zero_based = (degree->degree - 1) % 7;
+ int degree_delta;
+
+ int note_degree_zero_based = name - PITCH_NAME (root);
+ if (note_degree_zero_based < 0)
+ note_degree_zero_based += 7;
+
+ if (note_degree_zero_based == degree_zero_based)
+ return;
+
+ degree_delta = note_degree_zero_based - degree_zero_based;
+ if (degree_delta > 3)
+ degree_delta = - (7 - degree_delta);
+ if (degree_delta < -3)
+ degree_delta = - (-7 - degree_delta);
+
+ if (abs (degree_delta) != 1) {
+ fprintf (stderr, "Internal error: Cannot adjust a note more than one degree (%d vs. %d).\n", note_degree_zero_based + 1, degree->degree);
+ exit (1);
+ }
+
+ if (degree_delta == -1) {
+ if (name == PITCH_NAME_B) {
+ name = PITCH_NAME_C;
+ octave++;
+ } else {
+ name++;
+ }
+ switch (name) {
+ case PITCH_NAME_D:
+ case PITCH_NAME_E:
+ case PITCH_NAME_G:
+ case PITCH_NAME_A:
+ case PITCH_NAME_B:
+ accidental -= 2;
+ break;
+ case PITCH_NAME_C:
+ case PITCH_NAME_F:
+ accidental -= 1;
+ break;
+ }
+ }
+
+ if (degree_delta == +1) {
+ if (name == PITCH_NAME_C) {
+ name = PITCH_NAME_B;
+ octave--;
+ } else {
+ name--;
+ }
+ switch (name) {
+ case PITCH_NAME_C:
+ case PITCH_NAME_D:
+ case PITCH_NAME_F:
+ case PITCH_NAME_G:
+ case PITCH_NAME_A:
+ accidental += 2;
+ break;
+ case PITCH_NAME_E:
+ case PITCH_NAME_B:
+ accidental += 1;
+ }
+ }
+
+ if (accidental < 0 || accidental > PITCH_ACCIDENTAL_DOUBLE_SHARP) {
+ fprintf (stderr, "Internal error: Trying to adjust an accidental out of range (degree_delta == %d (%d - %d), new accidental == %d).\n", degree_delta, note_degree_zero_based, degree_zero_based, accidental);
+ exit (1);
+ }
+
+ *pitch = PITCH (name, accidental, octave);
+}
+
+static void
+_spell_chord_by_signature (pitch_group_t *chord,
+ chord_signature_t *signature,
+ pitch_t root)
+{
+ int i, degree, note_half_steps, degree_half_steps;
+ int root_midi;
+
+ /* Sanitize root to eliminate things like double-flats,
+ * double-sharps, Cb, E#, etc. */
+ root_midi = _pitch_to_midi (root);
+ root = _midi_to_pitch (root_midi);
+
+ for (i = 0; i < chord->num_pitches; i++) {
+ note_half_steps = _pitch_from_root_in_half_steps (chord->pitches[i],
+ root);
+ for (degree = 0; degree < signature->num_degrees; degree++) {
+ degree_half_steps = _modified_degree_to_half_steps (&signature->degrees[degree]);
+ if (note_half_steps == degree_half_steps) {
+ scherzo_adjust_pitch_to_match_modified_degree (&chord->pitches[i],
+ root,
+ &signature->degrees[degree]);
+ break;
+ }
+ }
+ if (note_half_steps != degree_half_steps) {
+ fprintf (stderr, "Internal error: Chord and degree mis-match\n");
+ exit (1);
+ }