13 static Mix_Music *music[NUM_TUNES];
14 static int music_volume[NUM_TUNES] = {255};
15 static Mix_Chunk *wav[NUM_SOUNDS];
21 char *add_data_path(char *);
30 // Return 1 if the sound is ready to roll, and 0 if not.
36 // Initialise output with SDL_mixer
37 if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, AUDIO_S16, MIX_DEFAULT_CHANNELS, 4096) < 0) {
38 fprintf(stderr, "Couldn't open SDL_mixer audio: %s\n", SDL_GetError());
42 // Preload all the tunes into memory
43 for (i=0; i<NUM_TUNES; i++) {
44 s = add_data_path(tune_file[i]);
46 music[i] = Mix_LoadMUS(s);
47 if(!music[i]) printf("Failed to load %s.\n", s);
52 // Preload all the wav files into memory
53 for (i=0; i<NUM_SOUNDS; i++) {
54 s = add_data_path(wav_file[i]);
56 wav[i] = Mix_LoadWAV(s);
66 if(!opt_sound) return;
67 Mix_PlayChannel(-1, wav[i], 0);
70 int playing = NUM_TUNES + 1;
81 if (playing < NUM_TUNES) {
82 Mix_FadeOutMusic(2500);
84 // There are songs yet to be written...
86 Mix_FadeInMusic(music[i], -1, 2000);
87 Mix_VolumeMusic(music_volume[i]);
101 if(playing < NUM_TUNES && !tune_paused) {
112 if(playing < NUM_TUNES && tune_paused) {
120 * The init_sound() routine is called first.
121 * The play_sound() routine is called with the index number of the sound we wish to play.
122 * The play_tune() routine is called with the index number of the tune we wish to play.