update
[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 - March 15, 2004
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 /* used to reserve some channels for panning effects */
22 #define SOUND_RESERVED_CHANNELS 2
23
24 /*global variable*/
25 extern int use_sound;           /* handle sound on/off menu and command-line option */
26 extern int use_music;           /* handle music on/off menu and command-line option */
27 extern 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 };
36
37
38 /* panning effects: terrible :-) ! */
39 enum Sound_Speaker {
40   SOUND_LEFT_SPEAKER = 0,
41   SOUND_RIGHT_SPEAKER = 1,
42   SOUND_CENTER_SPEAKER = -1
43 };
44
45 /* Sound files: */
46 enum {
47   SND_JUMP,
48   SND_BIGJUMP,
49   SND_SKID,
50   SND_DISTRO,
51   SND_HERRING,
52   SND_BRICK,
53   SND_HURT,
54   SND_SQUISH,
55   SND_FALL,
56   SND_RICOCHET,
57   SND_BUMP_UPGRADE,
58   SND_UPGRADE,
59   SND_EXCELLENT,
60   SND_COFFEE,
61   SND_SHOOT,
62   SND_LIFEUP,
63   SND_STOMP,
64   SND_KICK,
65   NUM_SOUNDS
66 };
67
68 extern char* soundfilenames[NUM_SOUNDS];
69
70 #ifndef NOSOUND
71
72 #include <SDL_mixer.h>
73
74 /* variables for stocking the sound and music */
75 extern Mix_Chunk * sounds[NUM_SOUNDS];
76 extern Mix_Music * level_song, * level_song_fast, * herring_song;
77
78 /* functions handling the sound and music */
79 int open_audio(int frequency, Uint16 format, int channels, int chunksize);
80 void close_audio( void );
81
82 Mix_Chunk * load_sound(char * file);
83 void play_sound(Mix_Chunk * snd, enum Sound_Speaker whichSpeaker);
84 Mix_Music * load_song(char * file);
85
86 int playing_music(void);
87 int halt_music(void);
88 int play_music(Mix_Music*music, int loops);
89 void free_music(Mix_Music*music);
90 void free_chunk(Mix_Chunk*chunk);
91
92 int get_current_music();
93 void set_current_music(int music);
94 void play_current_music();
95
96 #else
97
98 /* fake variables */
99 extern void* sounds[NUM_SOUNDS];
100 extern void * level_song, * level_song_fast, * herring_song;
101
102 /* fake sound handlers */
103 int open_audio (int frequency, int format, int channels, int chunksize);
104 void close_audio( void );
105
106 void* load_sound(void* file);
107 void play_sound(void * snd, enum Sound_Speaker whichSpeaker);
108 void* load_song(void* file);
109
110 int playing_music();
111 void halt_music();
112 int play_music(void *music, int loops);
113 void free_music(void *music);
114 void free_chunk(void *chunk);
115
116 int get_current_music();
117 void set_current_music(int music);
118 void play_current_music(void);
119
120 #endif
121
122 #endif /*SUPERTUX_SOUND_H*/