{
scherzo_t *scherzo = user_data;
int octave;
+ score_pitch_name_t pitch_name;
score_pitch_t pitch;
if (scherzo->challenge.note)
return FALSE;
case GDK_KEY_c:
case GDK_KEY_C:
- pitch = SCORE_PITCH_C;
+ pitch_name = SCORE_PITCH_NAME_C;
break;
case GDK_KEY_d:
case GDK_KEY_D:
- pitch = SCORE_PITCH_D;
+ pitch_name = SCORE_PITCH_NAME_D;
break;
case GDK_KEY_e:
case GDK_KEY_E:
- pitch = SCORE_PITCH_E;
+ pitch_name = SCORE_PITCH_NAME_E;
break;
case GDK_KEY_f:
case GDK_KEY_F:
- pitch = SCORE_PITCH_F;
+ pitch_name = SCORE_PITCH_NAME_F;
break;
case GDK_KEY_g:
case GDK_KEY_G:
- pitch = SCORE_PITCH_G;
+ pitch_name = SCORE_PITCH_NAME_G;
break;
case GDK_KEY_a:
case GDK_KEY_A:
- pitch = SCORE_PITCH_A;
+ pitch_name = SCORE_PITCH_NAME_A;
break;
case GDK_KEY_b:
case GDK_KEY_B:
- pitch = SCORE_PITCH_B;
+ pitch_name = SCORE_PITCH_NAME_B;
break;
case GDK_KEY_0:
case GDK_KEY_1:
break;
}
+ pitch = SCORE_PITCH (pitch_name, SCORE_PITCH_ACCIDENTAL_NATURAL);
+
if ((key->keyval >= GDK_KEY_A && key->keyval <= GDK_KEY_G) ||
(key->keyval >= GDK_KEY_a && key->keyval <= GDK_KEY_g))
{
{
scherzo_t *scherzo = user_data;
int octave;
+ score_pitch_name_t pitch_name;
score_pitch_t pitch;
if (scherzo->challenge.note)
switch (key->keyval) {
case GDK_KEY_c:
case GDK_KEY_C:
- pitch = SCORE_PITCH_C;
+ pitch_name = SCORE_PITCH_NAME_C;
break;
case GDK_KEY_d:
case GDK_KEY_D:
- pitch = SCORE_PITCH_D;
+ pitch_name = SCORE_PITCH_NAME_D;
break;
case GDK_KEY_e:
case GDK_KEY_E:
- pitch = SCORE_PITCH_E;
+ pitch_name = SCORE_PITCH_NAME_E;
break;
case GDK_KEY_f:
case GDK_KEY_F:
- pitch = SCORE_PITCH_F;
+ pitch_name = SCORE_PITCH_NAME_F;
break;
case GDK_KEY_g:
case GDK_KEY_G:
- pitch = SCORE_PITCH_G;
+ pitch_name = SCORE_PITCH_NAME_G;
break;
case GDK_KEY_a:
case GDK_KEY_A:
- pitch = SCORE_PITCH_A;
+ pitch_name = SCORE_PITCH_NAME_A;
break;
case GDK_KEY_b:
case GDK_KEY_B:
- pitch = SCORE_PITCH_B;
+ pitch_name = SCORE_PITCH_NAME_B;
break;
case GDK_KEY_space:
scherzo_release_pedal (scherzo);
break;
}
+ pitch = SCORE_PITCH (pitch_name, SCORE_PITCH_ACCIDENTAL_NATURAL);
+
if ((key->keyval >= GDK_KEY_A && key->keyval <= GDK_KEY_G) ||
(key->keyval >= GDK_KEY_a && key->keyval <= GDK_KEY_g))
{
switch (*s) {
case 'C':
- pitch = SCORE_PITCH_VALUE(C, NATURAL);
+ pitch = SCORE_PITCH_C;
break;
case 'D':
- pitch = SCORE_PITCH_VALUE(D, NATURAL);
+ pitch = SCORE_PITCH_D;
break;
case 'E':
- pitch = SCORE_PITCH_VALUE(E, NATURAL);
+ pitch = SCORE_PITCH_E;
break;
case 'F':
- pitch = SCORE_PITCH_VALUE(F, NATURAL);
+ pitch = SCORE_PITCH_F;
break;
case 'G':
- pitch = SCORE_PITCH_VALUE(G, NATURAL);
+ pitch = SCORE_PITCH_G;
break;
case 'A':
- pitch = SCORE_PITCH_VALUE(A, NATURAL);
+ pitch = SCORE_PITCH_A;
break;
case 'B':
- pitch = SCORE_PITCH_VALUE(B, NATURAL);
+ pitch = SCORE_PITCH_B;
break;
default:
fprintf (stderr, "Malformed pitch name: %s (expected 'A' - 'G')\n", s);
#define SCORE_PITCH_NAME(pitch) (((pitch) & SCORE_PITCH_NAME_MASK) >> SCORE_PITCH_NAME_SHIFT)
-#define SCORE_PITCH_VALUE(name, accidental) ((SCORE_PITCH_NAME_##name << SCORE_PITCH_NAME_SHIFT) + (SCORE_PITCH_ACCIDENTAL_##accidental))
+#define SCORE_PITCH(name, accidental) (((name) << SCORE_PITCH_NAME_SHIFT) | (accidental))
+
+#define SCORE_PITCH_LITERAL(literal_name, literal_accidental) SCORE_PITCH(SCORE_PITCH_NAME_##literal_name, SCORE_PITCH_ACCIDENTAL_##literal_accidental)
typedef enum score_pitch
{
- SCORE_PITCH_Cff = SCORE_PITCH_VALUE (C, DOUBLE_FLAT),
- SCORE_PITCH_Cf = SCORE_PITCH_VALUE (C, FLAT),
- SCORE_PITCH_C = SCORE_PITCH_VALUE (C, NATURAL),
- SCORE_PITCH_Cs = SCORE_PITCH_VALUE (C, SHARP),
- SCORE_PITCH_Css = SCORE_PITCH_VALUE (C, DOUBLE_SHARP),
-
- SCORE_PITCH_Dff = SCORE_PITCH_VALUE (D, DOUBLE_FLAT),
- SCORE_PITCH_Df = SCORE_PITCH_VALUE (D, FLAT),
- SCORE_PITCH_D = SCORE_PITCH_VALUE (D, NATURAL),
- SCORE_PITCH_Ds = SCORE_PITCH_VALUE (D, SHARP),
- SCORE_PITCH_Dss = SCORE_PITCH_VALUE (D, DOUBLE_SHARP),
-
- SCORE_PITCH_Eff = SCORE_PITCH_VALUE (E, DOUBLE_FLAT),
- SCORE_PITCH_Ef = SCORE_PITCH_VALUE (E, FLAT),
- SCORE_PITCH_E = SCORE_PITCH_VALUE (E, NATURAL),
- SCORE_PITCH_Es = SCORE_PITCH_VALUE (E, SHARP),
- SCORE_PITCH_Ess = SCORE_PITCH_VALUE (E, DOUBLE_SHARP),
-
- SCORE_PITCH_Fff = SCORE_PITCH_VALUE (F, DOUBLE_FLAT),
- SCORE_PITCH_Ff = SCORE_PITCH_VALUE (F, FLAT),
- SCORE_PITCH_F = SCORE_PITCH_VALUE (F, NATURAL),
- SCORE_PITCH_Fs = SCORE_PITCH_VALUE (F, SHARP),
- SCORE_PITCH_Fss = SCORE_PITCH_VALUE (F, DOUBLE_SHARP),
-
- SCORE_PITCH_Gff = SCORE_PITCH_VALUE (G, DOUBLE_FLAT),
- SCORE_PITCH_Gf = SCORE_PITCH_VALUE (G, FLAT),
- SCORE_PITCH_G = SCORE_PITCH_VALUE (G, NATURAL),
- SCORE_PITCH_Gs = SCORE_PITCH_VALUE (G, SHARP),
- SCORE_PITCH_Gss = SCORE_PITCH_VALUE (G, DOUBLE_SHARP),
-
- SCORE_PITCH_Aff = SCORE_PITCH_VALUE (A, DOUBLE_FLAT),
- SCORE_PITCH_Af = SCORE_PITCH_VALUE (A, FLAT),
- SCORE_PITCH_A = SCORE_PITCH_VALUE (A, NATURAL),
- SCORE_PITCH_As = SCORE_PITCH_VALUE (A, SHARP),
- SCORE_PITCH_Ass = SCORE_PITCH_VALUE (A, DOUBLE_SHARP),
-
- SCORE_PITCH_Bff = SCORE_PITCH_VALUE (B, DOUBLE_FLAT),
- SCORE_PITCH_Bf = SCORE_PITCH_VALUE (B, FLAT),
- SCORE_PITCH_B = SCORE_PITCH_VALUE (B, NATURAL),
- SCORE_PITCH_Bs = SCORE_PITCH_VALUE (B, SHARP),
- SCORE_PITCH_Bss = SCORE_PITCH_VALUE (B, DOUBLE_SHARP)
+ SCORE_PITCH_Cff = SCORE_PITCH_LITERAL (C, DOUBLE_FLAT),
+ SCORE_PITCH_Cf = SCORE_PITCH_LITERAL (C, FLAT),
+ SCORE_PITCH_C = SCORE_PITCH_LITERAL (C, NATURAL),
+ SCORE_PITCH_Cs = SCORE_PITCH_LITERAL (C, SHARP),
+ SCORE_PITCH_Css = SCORE_PITCH_LITERAL (C, DOUBLE_SHARP),
+
+ SCORE_PITCH_Dff = SCORE_PITCH_LITERAL (D, DOUBLE_FLAT),
+ SCORE_PITCH_Df = SCORE_PITCH_LITERAL (D, FLAT),
+ SCORE_PITCH_D = SCORE_PITCH_LITERAL (D, NATURAL),
+ SCORE_PITCH_Ds = SCORE_PITCH_LITERAL (D, SHARP),
+ SCORE_PITCH_Dss = SCORE_PITCH_LITERAL (D, DOUBLE_SHARP),
+
+ SCORE_PITCH_Eff = SCORE_PITCH_LITERAL (E, DOUBLE_FLAT),
+ SCORE_PITCH_Ef = SCORE_PITCH_LITERAL (E, FLAT),
+ SCORE_PITCH_E = SCORE_PITCH_LITERAL (E, NATURAL),
+ SCORE_PITCH_Es = SCORE_PITCH_LITERAL (E, SHARP),
+ SCORE_PITCH_Ess = SCORE_PITCH_LITERAL (E, DOUBLE_SHARP),
+
+ SCORE_PITCH_Fff = SCORE_PITCH_LITERAL (F, DOUBLE_FLAT),
+ SCORE_PITCH_Ff = SCORE_PITCH_LITERAL (F, FLAT),
+ SCORE_PITCH_F = SCORE_PITCH_LITERAL (F, NATURAL),
+ SCORE_PITCH_Fs = SCORE_PITCH_LITERAL (F, SHARP),
+ SCORE_PITCH_Fss = SCORE_PITCH_LITERAL (F, DOUBLE_SHARP),
+
+ SCORE_PITCH_Gff = SCORE_PITCH_LITERAL (G, DOUBLE_FLAT),
+ SCORE_PITCH_Gf = SCORE_PITCH_LITERAL (G, FLAT),
+ SCORE_PITCH_G = SCORE_PITCH_LITERAL (G, NATURAL),
+ SCORE_PITCH_Gs = SCORE_PITCH_LITERAL (G, SHARP),
+ SCORE_PITCH_Gss = SCORE_PITCH_LITERAL (G, DOUBLE_SHARP),
+
+ SCORE_PITCH_Aff = SCORE_PITCH_LITERAL (A, DOUBLE_FLAT),
+ SCORE_PITCH_Af = SCORE_PITCH_LITERAL (A, FLAT),
+ SCORE_PITCH_A = SCORE_PITCH_LITERAL (A, NATURAL),
+ SCORE_PITCH_As = SCORE_PITCH_LITERAL (A, SHARP),
+ SCORE_PITCH_Ass = SCORE_PITCH_LITERAL (A, DOUBLE_SHARP),
+
+ SCORE_PITCH_Bff = SCORE_PITCH_LITERAL (B, DOUBLE_FLAT),
+ SCORE_PITCH_Bf = SCORE_PITCH_LITERAL (B, FLAT),
+ SCORE_PITCH_B = SCORE_PITCH_LITERAL (B, NATURAL),
+ SCORE_PITCH_Bs = SCORE_PITCH_LITERAL (B, SHARP),
+ SCORE_PITCH_Bss = SCORE_PITCH_LITERAL (B, DOUBLE_SHARP)
} score_pitch_t;
typedef enum score_duration