1 /*
2  * Copyright (c) 2000 Mark B. Allan. All rights reserved.
3  *
4  * "Chromium B.S.U." is free software; you can redistribute
5  * it and/or use it and/or modify it under the terms of the
6  * "Clarified Artistic License"
7  */
8 #ifndef Audio_h
9 #define Audio_h
10 
11 #ifdef HAVE_CONFIG_H
12 #include <chromium-bsu-config.h>
13 #endif
14 
15 #define NUM_EXPLO		2
16 #define NUM_EXPLO_POP	6
17 
18 #define MAX_MUSIC 32
19 
20 class SoundInfo;
21 class Global;
22 
23 #ifdef USE_SDL_CDROM
24 #include <SDL.h> // for CDROM
25 #endif
26 
27 /**
28  * Base class upon which all audio calls are made. If USE_SDL_CDROM is defined,
29  * this class will do CD music playback, but does not do any sound effects.
30  */
31 //====================================================================
32 class Audio
33 {
34 public:
35 	/** available sound effects types */
36 	enum SoundType	{
37 						HeroAmmo00, 	/**< unused */
38 						PowerUp,		/**< power up sound */
39 						Explosion,		/**< standard explosion */
40 						ExploPop,		/**< 'light' explosion */
41 						ExploBig,		/**< deep, long explosion */
42 						AddLife,		/**< new ship earned */
43 						LoseLife,		/**< ship lost */
44 						MusicGame,		/**< gameplay music */
45 						MusicMenu, 		/**< menu music */
46 						NumSoundTypes 	/**< total number of sounds available */
47 					};
48 
49 	Audio();
50 	virtual ~Audio();
51 
52 	virtual void	update();
53 	virtual void	playSound(SoundType type, float *pos, int age = 0);
54 	virtual void	stopMusic();
55 	virtual void	pauseGameMusic(bool);
56 	virtual void	setMusicMode(SoundType);
57 	virtual void	setMusicVolume(float);
58 	virtual void	setSoundVolume(float);
59 	virtual void	setMusicIndex(int);
60 	virtual void	nextMusicIndex();
61 
62 protected:
63 	virtual void	initSound();
64 #ifdef USE_SDL_CDROM
65 	virtual void	initCDROM();
66 #endif // USE_SDL_CDROM
67 
68 	const char	*fileNames[NumSoundTypes];	/**< base filenames for sound effects */
69 #ifdef USE_SDL_CDROM
70 	SDL_CD	*cdrom; 					/**< pointer to CDROM struct. Is void* if not using SDL */
71 #endif // USE_SDL_CDROM
72 	char	musicFile[MAX_MUSIC][256];	/**< array of filenames for playlist */
73 	int		musicMax;					/**< max number of user-defined songs (CD or playlist) */
74 	int		musicIndex; 				/**< current track ( 0 < musicIndex < musicMax ) */
75 
76 };
77 
78 /**
79  * node class used for 'audio queue'
80  */
81 //======================================
82 class SoundInfo
83 {
84 public:
85 	SoundInfo();
86 	SoundInfo(Audio::SoundType t, float p[3], int a);
87 
88 	Audio::SoundType	type;
89 	float		pos[3];
90 	int			age;
91 
92 	SoundInfo	*next;
93 	SoundInfo	*back;
94 };
95 
96 #endif // Audio_h
97