13 static Mix_Music *music[NUM_TUNES];
14 static int music_volume[NUM_TUNES] = {88,88,88};
15 static Mix_Chunk *wav[NUM_SOUNDS];
21 char *add_data_path(char *);
32 // Return 1 if the sound is ready to roll, and 0 if not.
38 // Initialise output with SDL_mixer
39 if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, AUDIO_S16, MIX_DEFAULT_CHANNELS, 4096) < 0) {
40 fprintf(stderr, "Couldn't open SDL_mixer audio: %s\n", SDL_GetError());
44 // Preload all the tunes into memory
45 for (i=0; i<NUM_TUNES; i++) {
46 s = add_data_path(tune_file[i]);
48 music[i] = Mix_LoadMUS(s);
49 if(!music[i]) printf("Failed to load %s.\n", s);
54 // Preload all the wav files into memory
55 for (i=0; i<NUM_SOUNDS; i++) {
56 s = add_data_path(wav_file[i]);
58 wav[i] = Mix_LoadWAV(s);
68 if(!opt_sound) return;
69 Mix_PlayChannel(-1, wav[i], 0);
84 Mix_FadeOutMusic(2500);
86 if(i == TUNE_GAMEPLAY) {
87 Mix_FadeInMusic(music[i],-1,2000);
88 Mix_VolumeMusic(music_volume[i]);
102 if(playing == TUNE_GAMEPLAY && !tune_paused) {
113 if(playing == TUNE_GAMEPLAY && tune_paused) {
121 * The init_sound() routine is called first.
122 * The play_sound() routine is called with the index number of the sound we wish to play.
123 * The play_tune() routine is called with the index number of the tune we wish to play.