2 #include <SDL/SDL_mixer.h>
13 static Mix_Music *music[NUM_TUNES];
14 static int music_volume[NUM_TUNES] = {128,128,128};
15 static Mix_Chunk *wav[NUM_SOUNDS];
21 char *add_path(char *);
32 "music/4est_fulla3s.mod"
37 // Return 1 if the sound is ready to roll, and 0 if not.
41 // Initialise output with SDL_mixer
42 if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, AUDIO_S16, MIX_DEFAULT_CHANNELS, 4096) < 0) {
43 fprintf(stderr, "Couldn't open SDL_mixer audio: %s\n", SDL_GetError());
47 // Preload all the tunes into memory
48 for (i=0; i<NUM_TUNES; i++) {
49 if (!(music[i] = Mix_LoadMUS(add_path(tune_file[i])))) {
50 printf ("Failed to load %s\n",add_path(tune_file[i]));
54 // Preload all the wav files into memory
55 for (i=0; i<NUM_SOUNDS; i++) {
56 wav[i] = Mix_LoadWAV(add_path(wav_file[i]));
64 if(!opt_sound) return;
65 Mix_PlayChannel(-1, wav[i], 0);
72 play_tune(int i) {/*{{{*/
73 if(!opt_music) return;
77 Mix_FadeOutMusic(1500);
79 Mix_FadeInMusic(music[i],-1,2000);
80 Mix_VolumeMusic(music_volume[i]);
87 * The init_sound() routine is called first.
88 * The play_sound() routine is called with the index number of the sound we wish to play.
89 * The play_tune() routine is called with the index number of the tune we wish to play.