4 Super Tux - Audio Functions
7 bill@newbreedsoftware.com
8 http://www.newbreedsoftware.com/supertux/
10 April 22, 2000 - July 15, 2002
19 #include <SDL_image.h>
23 #include <sys/types.h>
34 /* --- OPEN THE AUDIO DEVICE --- */
36 int open_audio (int frequency, Uint16 format, int channels, int chunksize)
38 return Mix_OpenAudio( frequency, format, channels, chunksize );
42 /* --- LOAD A SOUND --- */
44 Mix_Chunk * load_sound(char * file)
48 snd = Mix_LoadWAV(file);
50 /* printf message and abort if there is an initialized audio device */
51 if ((snd == NULL) && (audio_device == YES))
52 st_abort("Can't load", file);
58 /* --- LOAD A SONG --- */
60 Mix_Music * load_song(char * file)
64 sng = Mix_LoadMUS(file);
66 /* printf message and abort if there is an initialized audio device */
67 if ((sng == NULL) && (audio_device == YES))
68 st_abort("Can't load", file);
73 /* --- PLAY A SOUND --- */
75 void play_sound(Mix_Chunk * snd)
77 /* this won't call the function if the user has disabled sound
78 * either via menu or via command-line option
80 if ((use_sound == YES) && (audio_device == YES))
82 Mix_PlayChannel(-1, snd, 0);
87 void free_chunk(Mix_Chunk *chunk)
91 DEBUG_MSG( __PRETTY_FUNCTION__ );
92 Mix_FreeChunk( chunk );
97 int playing_music(void)
101 return Mix_PlayingMusic();
105 /* we are in --disable-sound we can't be playing music */
113 if ((use_sound == YES) && (audio_device == YES))
115 return Mix_HaltMusic();
124 int play_music(Mix_Music *music, int loops)
126 if ((use_sound == YES) && (audio_device == YES))
128 DEBUG_MSG(__PRETTY_FUNCTION__);
129 return Mix_PlayMusic(music, loops);
133 /* return error since you're trying to play music in --disable-sound mode */
139 void free_music(Mix_Music *music)
143 DEBUG_MSG(__PRETTY_FUNCTION__);
144 Mix_FreeMusic( music );
151 int open_audio (int frequency, int format, int channels, int chunksize)
156 void* load_sound(void* file)
160 void play_sound(void * snd)
162 void* load_song(void* file)
173 int play_music(void *music, int loops)
177 void free_music(void *music)
179 void free_chunk(void *chunk)