X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=scherzo.c;fp=scherzo.c;h=109de6d06b2ccce29e193686f0cd0f9f35059561;hb=e5ec7a294da3e46c83d858f711405febbad2651b;hp=b8dd611a0a7e9ae9cff49b08b1a1090e4518acfc;hpb=367e517451123c7c79ead28eca6d2489bfed6467;p=scherzo diff --git a/scherzo.c b/scherzo.c index b8dd611..109de6d 100644 --- a/scherzo.c +++ b/scherzo.c @@ -32,10 +32,11 @@ typedef struct challenge { + int active; bin_t *bin; int item_index; score_staff_t *staff; - score_note_t *note; + pitch_t pitch; int satisfied; int mistaken; @@ -152,8 +153,8 @@ on_key_press_event (GtkWidget *widget, pitch_name_t pitch_name = PITCH_NATURAL (C, 0); pitch_t pitch; - if (scherzo->challenge.note) - octave = PITCH_OCTAVE (scherzo->challenge.note->pitch); + if (scherzo->challenge.active) + octave = PITCH_OCTAVE (scherzo->challenge.pitch); else octave = scherzo->keyboard_octave; @@ -257,8 +258,8 @@ on_key_release_event (unused (GtkWidget *widget), pitch_name_t pitch_name = PITCH_NAME_C; pitch_t pitch; - if (scherzo->challenge.note) - octave = PITCH_OCTAVE (scherzo->challenge.note->pitch); + if (scherzo->challenge.active) + octave = PITCH_OCTAVE (scherzo->challenge.pitch); else octave = scherzo->keyboard_octave; @@ -1154,15 +1155,9 @@ _select_challenge (scherzo_t *scherzo) item_t *item; challenge_t *challenge = &scherzo->challenge; pitch_name_t pitch_name; - pitch_t pitch; int octave; char *s; - if (challenge->note) { - score_remove_note (challenge->note); - challenge->note = NULL; - } - mnemon_select_item (&scherzo->mnemon, &challenge->bin, &challenge->item_index, @@ -1220,10 +1215,9 @@ _select_challenge (scherzo_t *scherzo) octave = *s - '0'; - pitch = PITCH (pitch_name, PITCH_ACCIDENTAL_NATURAL, octave); + challenge->pitch = PITCH (pitch_name, PITCH_ACCIDENTAL_NATURAL, octave); - challenge->note = score_staff_add_note (challenge->staff, pitch, - SCORE_DURATION_WHOLE); + challenge->active = 1; challenge->satisfied = 0; challenge->mistaken = 0; } @@ -1234,10 +1228,10 @@ _judge_pitch (scherzo_t *scherzo, pitch_t pitch) { challenge_t *challenge = &scherzo->challenge; - if (! challenge->note) + if (! challenge->active) return; - if (pitch == challenge->note->pitch) + if (pitch == challenge->pitch) challenge->satisfied = 1; else challenge->mistaken = 1; @@ -1250,7 +1244,7 @@ _score_challenge (scherzo_t *scherzo) { challenge_t *challenge = &scherzo->challenge; - if (! challenge->note) + if (! challenge->active) return; if (! challenge->satisfied) @@ -1369,7 +1363,7 @@ main (int argc, char *argv[]) /* XXX: Should create a default file if one cannot be loaded. */ mnemon_load_category (&scherzo.mnemon, "scherzo-notes"); - scherzo.challenge.note = NULL; + scherzo.challenge.active = 0; /* _select_challenge (&scherzo); */