Now loads both normal and fast versions of songs; plays according to time left.
[supertux.git] / src / sound.h
1 /*
2   sound.h
3   
4   Super Tux - Audio Functions
5   
6   by Bill Kendrick
7   bill@newbreedsoftware.com
8   http://www.newbreedsoftware.com/supertux/
9  
10   April 22, 2000 - December 28, 2003
11
12   Current maintainer:
13         Duong-Khang NGUYEN <neoneurone@users.sf.net>
14 */
15
16 #ifndef SUPERTUX_SOUND_H
17 #define SUPERTUX_SOUND_H
18
19 #include "defines.h"     /* get YES/NO defines */
20
21 /*all the sounds we have*/
22 #define NUM_SOUNDS 16
23
24 /*global variable*/
25 int use_sound;
26 int use_music;
27 int audio_device;        /* != 0: available and initialized */
28
29 /* enum of different internal music types */
30 enum Music_Type {
31   NO_MUSIC,
32   LEVEL_MUSIC,
33   HURRYUP_MUSIC,
34   HERRING_MUSIC
35 } current_music;
36
37
38 #ifndef NOSOUND
39
40 #include <SDL_mixer.h>
41
42 /* variables for stocking the sound and music */
43 Mix_Chunk * sounds[NUM_SOUNDS];
44 Mix_Music * level_song, * level_song_fast, * herring_song;
45
46 /* functions handling the sound and music */
47 int open_audio(int frequency, Uint16 format, int channels, int chunksize);
48
49 Mix_Chunk * load_sound(char * file);
50 void play_sound(Mix_Chunk * snd);
51 Mix_Music * load_song(char * file);
52
53 int playing_music(void);
54 int halt_music(void);
55 int play_music(Mix_Music*music, int loops);
56 void free_music(Mix_Music*music);
57 void free_chunk(Mix_Chunk*chunk);
58
59 #else
60
61 //fake variables
62 void* sounds[NUM_SOUNDS];
63 void* level_song, *herring_song;
64
65 // fake sound handlers
66 int open_audio (int frequency, int format, int channels, int chunksize);
67
68 void* load_sound(void* file);
69 void play_sound(void * snd);
70 void* load_song(void* file);
71
72 int playing_music();
73 void halt_music();
74 int play_music(void *music, int loops);
75 void free_music(void *music);
76 ;
77 void free_chunk(void *chunk);
78
79 #endif
80
81 #endif /*SUPERTUX_SOUND_H*/