From b7b592c437804f23dbe90e10b65b7cacf4770725 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 3 Oct 2013 10:52:59 -0700 Subject: [PATCH] Fix high octave numbers (8+) to not be interpreted as 0. A user recently noticed that the highest key on the piano (A8) was showing up as A0 in scherzo, (the lowest note on the piano). The bug was that scherzo was using only 3 bits for the octave number, which obviously only covers the range [0:7]. ISO octave numbers, (and the octave numbers needed for a piano), are the range [0:8]. So adding one bit to the octave storage does the trick here. --- pitch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pitch.h b/pitch.h index d376a22..683d727 100644 --- a/pitch.h +++ b/pitch.h @@ -32,7 +32,7 @@ typedef uint32_t pitch_t; #define PITCH_NAME_MASK (0x07 << PITCH_NAME_SHIFT) #define PITCH_OCTAVE_SHIFT (6) -#define PITCH_OCTAVE_MASK (0x07 << PITCH_OCTAVE_SHIFT) +#define PITCH_OCTAVE_MASK (0x0F << PITCH_OCTAVE_SHIFT) #define PITCH_ACCIDENTAL(pitch) \ (((pitch) & PITCH_ACCIDENTAL_MASK) >> PITCH_ACCIDENTAL_SHIFT) -- 2.43.0