cairo_paint (cr);
/* Add some padding on the sides and top */
- cairo_translate (cr, pad, 2 * scherzo->staff_height);
+ cairo_translate (cr, pad, scherzo->staff_height);
score_set_staff_height (score, scherzo->staff_height);
score_set_width (score, widget_width - 2 * pad);
note->octave == challenge->note->octave)
{
challenge->satisfied = 1;
+ score_set_note_color_rgb (note, 18/256., 130/256., 28/256.); /* green */
}
else
{
challenge->mistaken = 1;
+ score_set_note_color_rgb (note, 184/256., 4/256., 22/256.); /* red */
}
}
ssize_t remaining;
snd_seq_event_t event;
score_note_t *note;
+ int need_redraw = FALSE;
remaining = read (scherzo->midi_fd, buf, MIDI_BUF_SIZE);
next, remaining, &event);
remaining -= consumed;
+ next += consumed;
switch (event.type) {
case SND_SEQ_EVENT_NONE:
case SND_SEQ_EVENT_NOTEON:
note = scherzo_add_note_midi (scherzo, event.data.note.note);
_judge_note (scherzo, note);
- gtk_widget_queue_draw (scherzo->window);
+ need_redraw = TRUE;
break;
case SND_SEQ_EVENT_NOTEOFF:
scherzo_remove_note_midi (scherzo, event.data.note.note);
_score_challenge (scherzo);
- gtk_widget_queue_draw (scherzo->window);
+ need_redraw = TRUE;
break;
case SND_SEQ_EVENT_CLOCK:
/* Ignore for now as my piano sends a constant stream of these. */
break;
}
}
-
+
+ if (need_redraw)
+ gtk_widget_queue_draw (scherzo->window);
+
/* Return TRUE to continue to get called in the future. */
return TRUE;
}
scherzo.ctx = talloc_new (NULL);
scherzo.score = score_create (scherzo.ctx);
- scherzo.staff_height = 48;
+ scherzo.staff_height = 100;
score_set_staff_height (scherzo.score, scherzo.staff_height);
score_add_brace (scherzo.score, 2);
scherzo.window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size (GTK_WINDOW (scherzo.window), 600, 400);
+ gtk_window_set_default_size (GTK_WINDOW (scherzo.window), 1000, 600);
g_signal_connect (scherzo.window, "delete-event",
G_CALLBACK (on_delete_event_quit), NULL);