Doing this instead of the audio type means we can save file size,
(these midi files are much smaller than resulting .wav files), and
also skip once processing step in preparing the files.
Using the -Os option to timidity means that if we have two overlapping
invocations of timidity the second one won't fail due to contention
for /dev/dsp.
typedef enum {
CHALLENGE_TYPE_TEXT,
CHALLENGE_TYPE_IMAGE,
typedef enum {
CHALLENGE_TYPE_TEXT,
CHALLENGE_TYPE_IMAGE,
+ CHALLENGE_TYPE_AUDIO,
+ CHALLENGE_TYPE_MIDI
} challenge_type_t;
typedef struct _category {
} challenge_type_t;
typedef struct _category {
case CHALLENGE_TYPE_AUDIO:
fprintf (file, "audio");
break;
case CHALLENGE_TYPE_AUDIO:
fprintf (file, "audio");
break;
+ case CHALLENGE_TYPE_MIDI:
+ fprintf (file, "midi");
+ break;
}
fprintf (file, "\n\n");
}
fprintf (file, "\n\n");
category->challenge_type = CHALLENGE_TYPE_IMAGE;
} else if (strcmp (value, "audio") == 0) {
category->challenge_type = CHALLENGE_TYPE_AUDIO;
category->challenge_type = CHALLENGE_TYPE_IMAGE;
} else if (strcmp (value, "audio") == 0) {
category->challenge_type = CHALLENGE_TYPE_AUDIO;
+ } else if (strcmp (value, "midi") == 0) {
+ category->challenge_type = CHALLENGE_TYPE_MIDI;
} else {
fprintf (stderr, "Unknown value for \"challenge\" option \"%s\" at %s:%d\n",
value, path, line_count);
} else {
fprintf (stderr, "Unknown value for \"challenge\" option \"%s\" at %s:%d\n",
value, path, line_count);
case CHALLENGE_TYPE_AUDIO:
program = "play";
break;
case CHALLENGE_TYPE_AUDIO:
program = "play";
break;
+ case CHALLENGE_TYPE_MIDI:
+ program = "timidity -Os";
+ break;
}
xasprintf (&command, "%s %s/%s >/dev/null 2>&1 &",
}
xasprintf (&command, "%s %s/%s >/dev/null 2>&1 &",
free (response);
/* Replay audio challenges for reinforcement. */
free (response);
/* Replay audio challenges for reinforcement. */
- if (category->challenge_type == CHALLENGE_TYPE_AUDIO) {
+ if (category->challenge_type == CHALLENGE_TYPE_AUDIO ||
+ category->challenge_type == CHALLENGE_TYPE_MIDI)
+ {
mnemon_show_challenge (mnemon, category->challenge_type,
item->challenge);
mnemon_show_challenge (mnemon, category->challenge_type,
item->challenge);
+ printf ("%s\n", item->challenge);
+ sleep (2);
}
} while (mnemon->to_introduce ||
mnemon->unlearned ||
}
} while (mnemon->to_introduce ||
mnemon->unlearned ||