1 #ifndef INC_SOUND_H
2 #define INC_SOUND_H
3 
4 #include "coords.h"
5 #include <vector>
6 
7 struct Mix_Chunk;
8 
9 class SoundEvent
10 {
11     private:
12 	RelPolarCoord pos;
13 	Mix_Chunk* chunk;
14 	int volume;
15 	bool noSight;
16 
17 	bool hadFirstUpdate;
18 	float startVolMult;
19 
20     public:
21 	int channel;
22 	bool finished;
23 
isFinished(const SoundEvent & ev)24 	static bool isFinished(const SoundEvent& ev) { return ev.finished; }
25 
26 	void update(RelPolarCoord aimPos);
27 
28 	SoundEvent(RelPolarCoord pos, Mix_Chunk* chunk,
29 		int volume=128, int stretch=1000, bool noSight=false);
30 };
31 
32 class SoundEvents : public std::vector<SoundEvent>
33 {
34     private:
35 	bool audioInitialised;
36 	bool initialiseAudio();
37     public:
38 	void update(RelPolarCoord aimPos);
39 	void newEvent(RelPolarCoord pos, Mix_Chunk* chunk,
40 		int volume=128, int stretch=1000, bool noSight=false);
41 	void channelDone(int channel);
SoundEvents()42 	SoundEvents() : audioInitialised(false) {}
43 };
44 
45 extern SoundEvents soundEvents;
46 
47 extern Mix_Chunk* invDieChunk;
48 extern Mix_Chunk* invHitChunk;
49 extern Mix_Chunk* sparkChunk;
50 extern Mix_Chunk* shotChunk;
51 extern Mix_Chunk* shieldChunk;
52 extern Mix_Chunk* primedChunk;
53 extern Mix_Chunk* nodeHumChunk;
54 extern Mix_Chunk* mutChunk;
55 
56 #endif /* INC_SOUND_H */
57