3 #include <SDL/SDL_mixer.h>
18 TSoundLibrary g_snd_lib
;
20 int RegenerateSounds(){
21 printf("RegenerateSounds not implemented\n");
25 void InvalidateSounds(){
26 printf("InvalidateSounds not implemented\n");
29 void PlaySound(int id
){
31 if(id
<0 || id
>=g_snd_lib
.no_sounds
) return;
32 channel
= Mix_PlayChannel(id
, g_snd_lib
.sounds
[id
].sound
, 0);
34 fprintf(stderr
, "Unable to play WAV file: %s\n", Mix_GetError());
36 printf("Play sound %d\n",id
);
39 int LoadSound(char *path
){
41 if((i
=(++g_snd_lib
.no_sounds
))>g_snd_lib
.allocated
){
42 g_snd_lib
.allocated
*=2;
43 g_snd_lib
.allocated
+=1;
44 g_snd_lib
.sounds
= realloc(g_snd_lib
.sounds
, sizeof(TSound
)* g_snd_lib
.allocated
);
47 g_snd_lib
.sounds
[i
].filename
= calloc(strlen(path
)+1,sizeof(char));
48 strcpy(g_snd_lib
.sounds
[i
].filename
, path
);
49 g_snd_lib
.sounds
[i
].sound
= Mix_LoadWAV(path
);
50 if(g_snd_lib
.sounds
[i
].sound
== NULL
) {
51 fprintf(stderr
, "Unable to load WAV file: %s\n", Mix_GetError());
57 void DestroySound(int id
){
58 printf("DestroySound not implemented\n");
62 int audio_rate
= 22050;
63 Uint16 audio_format
= AUDIO_S16SYS
;
64 int audio_channels
= 2;
65 int audio_buffers
= 4096;
67 if(Mix_OpenAudio(audio_rate
, audio_format
, audio_channels
, audio_buffers
) != 0) {
68 fprintf(stderr
, "Unable to initialize audio: %s\n", Mix_GetError());
72 memset(&g_snd_lib
, 0, sizeof(TSoundLibrary
));
78 void SoundDestroyAll(){
79 printf("SoundDestroyAll not implemented\n");