_midi_to_score_pitch_and_octave (midi_note, &pitch, &octave);
- note = score_staff_add_note (staff, pitch, octave, SCORE_DURATION_WHOLE);
+ note = score_add_note (staff, pitch, octave, SCORE_DURATION_WHOLE);
scherzo->num_notes_pressed++;
scherzo->notes_pressed = talloc_realloc (scherzo->ctx,
static void
scherzo_remove_note_midi (scherzo_t *scherzo, unsigned char midi_note)
{
- score_staff_t *staff;
score_pitch_t pitch;
int octave;
score_note_t *note;
int i;
- staff = scherzo->challenge.staff;
-
_midi_to_score_pitch_and_octave (midi_note, &pitch, &octave);
for (i = 0; i < scherzo->num_notes_pressed; i++) {
note = scherzo->notes_pressed[i];
if (note->pitch == pitch && note->octave == octave) {
- score_staff_remove_note (staff, note);
+ score_remove_note (note);
if (i < scherzo->num_notes_pressed - 1) {
memmove (scherzo->notes_pressed + i,
scherzo->notes_pressed + i + 1,
char *s;
if (challenge->note) {
- score_staff_remove_note (challenge->staff, challenge->note);
+ score_remove_note (challenge->note);
challenge->note = NULL;
}
octave = *s - '0';
- challenge->note = score_staff_add_note (challenge->staff, pitch, octave,
- SCORE_DURATION_WHOLE);
+ challenge->note = score_add_note (challenge->staff, pitch, octave,
+ SCORE_DURATION_WHOLE);
challenge->satisfied = 0;
challenge->mistaken = 0;
}
}
score_note_t *
-score_staff_add_note (score_staff_t *staff,
- score_pitch_t pitch,
- int octave,
- score_duration_t duration)
+score_add_note (score_staff_t *staff,
+ score_pitch_t pitch,
+ int octave,
+ score_duration_t duration)
{
score_note_t *note;
if (note == NULL)
return NULL;
+ note->staff = staff;
note->pitch = pitch;
note->octave = octave;
note->duration = duration;
}
void
-score_staff_remove_note (score_staff_t *staff, score_note_t *note)
+score_remove_note (score_note_t *note)
{
+ score_staff_t *staff = note->staff;
int i;
for (i = 0; i < staff->num_notes; i++)
typedef struct score_note
{
+ score_staff_t *staff;
score_pitch_t pitch;
int octave;
score_duration_t duration;
* QUARTER=4, EIGHTH=8, etc.)
*/
score_note_t *
-score_staff_add_note (score_staff_t *staff,
- score_pitch_t pitch,
- int octave,
- score_duration_t);
+score_add_note (score_staff_t *staff,
+ score_pitch_t pitch,
+ int octave,
+ score_duration_t);
/* Remove the given note from the given staff. */
void
-score_staff_remove_note (score_staff_t *staff, score_note_t *note);
+score_remove_note (score_note_t *note);
/* Return the first note on the given staff with the given pitch,
* octave, and durations. Returns NULL if no match is found. */