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)
39 return Mix_OpenAudio( frequency, format, channels, chunksize );
42 // let the user think that the audio device was correctly opened
43 // and keep the compiler happy :-D
49 /* --- LOAD A SOUND --- */
51 Mix_Chunk * load_sound(char * file)
55 snd = Mix_LoadWAV(file);
58 st_abort("Can't load", file);
64 /* --- LOAD A SONG --- */
66 Mix_Music * load_song(char * file)
70 sng = Mix_LoadMUS(file);
73 st_abort("Can't load", file);
79 /* --- PLAY A SOUND --- */
81 void play_sound(Mix_Chunk * snd)
83 /* this won't call the function if the user has disabled sound */
85 Mix_PlayChannel(-1, snd, 0);
90 void free_chunk(Mix_Chunk *chunk)
93 DEBUG_MSG( __PRETTY_FUNCTION__ );
94 Mix_FreeChunk( chunk );
99 int playing_music(void)
102 return Mix_PlayingMusic();
105 /* we are in --disable-sound we can't be playing music */
114 return Mix_HaltMusic();
122 int play_music(Mix_Music *music, int loops)
125 DEBUG_MSG(__PRETTY_FUNCTION__);
126 return Mix_PlayMusic(music, loops);
129 /* return error since you're trying to play music in --disable-sound mode */
135 void free_music(Mix_Music *music)
137 if ( music != NULL ) {
138 DEBUG_MSG(__PRETTY_FUNCTION__);
139 Mix_FreeMusic( music );
146 int open_audio (int frequency, int format, int channels, int chunksize)
151 void* load_sound(void* file) { return NULL; }
152 void play_sound(void * snd) {}
153 void* load_song(void* file) { return NULL; }
155 int playing_music() { return 0; }
157 int play_music(void *music, int loops) { return 0;}
158 void free_music(void *music) {}
159 void free_chunk(void *chunk) {}