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