]> git.cworth.org Git - scherzo/commitdiff
Respell a note if it triggers a key change.
authorCarl Worth <cworth@cworth.org>
Thu, 3 Oct 2013 17:47:11 +0000 (10:47 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 3 Oct 2013 17:50:55 +0000 (10:50 -0700)
It looks a bit odd to play a G-major scale, see the G-major key
signature pop up, but see a G-flat on the staff at the end of the
scale instead of the expected F-sharp.

Fix this by respelling the note when the key signature changes.

scherzo.c

index 0ef44ea1b362bba96e6b3edc63160cfdd6e97af0..7288d5fdbe7efb98b7b4c87879b6549cbbf8f23d 100644 (file)
--- a/scherzo.c
+++ b/scherzo.c
@@ -999,9 +999,13 @@ scherzo_press_note (scherzo_t *scherzo, pitch_t pitch)
             (NUM_RECENT_PITCHES - 1) * sizeof (pitch_t));
     recent_pitches[NUM_RECENT_PITCHES - 1] = pitch;
 
-    if (pitches_are_diatonic_scale (recent_pitches, NUM_RECENT_PITCHES))
+    if (pitches_are_diatonic_scale (recent_pitches, NUM_RECENT_PITCHES)) {
        scherzo_set_key (scherzo, recent_pitches[0]);
 
+       /* Respell pitch according to new key. */
+       pitch = scherzo_key_spell_pitch (&scherzo->key, pitch);
+    }
+
     /* Do nothing if this note is already pressed. */
     for (i = 0; i < scherzo->notes_pressed.num_pitches; i++)
        if (scherzo->notes_pressed.pitches[i] == pitch)