-scherzo_adjust_note_to_match_modified_degree (score_note_t *note,
- score_pitch_t root,
- modified_degree_t *degree)
-{
- score_pitch_name_t name = SCORE_PITCH_NAME (note->pitch);
- score_pitch_accidental_t accidental = SCORE_PITCH_ACCIDENTAL (note->pitch);
- int degree_zero_based = (degree->degree - 1) % 7;
- int degree_delta;
-
- int note_degree_zero_based = name - SCORE_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 == SCORE_PITCH_NAME_B) {
- name = SCORE_PITCH_NAME_C;
- note->octave++;
- } else {
- name++;
- }
- switch (name) {
- case SCORE_PITCH_NAME_D:
- case SCORE_PITCH_NAME_E:
- case SCORE_PITCH_NAME_G:
- case SCORE_PITCH_NAME_A:
- case SCORE_PITCH_NAME_B:
- accidental -= 2;
- break;
- case SCORE_PITCH_NAME_C:
- case SCORE_PITCH_NAME_F:
- accidental -= 1;
- break;
- }
- }
-
- if (degree_delta == +1) {
- if (name == SCORE_PITCH_NAME_C) {
- name = SCORE_PITCH_NAME_B;
- note->octave--;
- } else {
- name--;
- }
- switch (name) {
- case SCORE_PITCH_NAME_C:
- case SCORE_PITCH_NAME_D:
- case SCORE_PITCH_NAME_F:
- case SCORE_PITCH_NAME_G:
- case SCORE_PITCH_NAME_A:
- accidental += 2;
- break;
- case SCORE_PITCH_NAME_E:
- case SCORE_PITCH_NAME_B:
- accidental += 1;
- }
- }
-
- if (accidental < 0 || accidental > SCORE_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);
- }
-
- note->pitch = SCORE_PITCH (name, accidental);
-}
-
-static void
-_spell_chord_by_signature (note_group_t *chord,
- int num_notes,