1 // SONIC ROBO BLAST 2
2 //-----------------------------------------------------------------------------
3 // Copyright (C) 1993-1996 by id Software, Inc.
4 // Copyright (C) 1998-2000 by DooM Legacy Team.
5 // Copyright (C) 1999-2020 by Sonic Team Junior.
6 //
7 // This program is free software distributed under the
8 // terms of the GNU General Public License, version 2.
9 // See the 'LICENSE' file for more details.
10 //-----------------------------------------------------------------------------
11 /// \file  i_sound.h
12 /// \brief System interface, sound, music
13 
14 #ifndef __I_SOUND__
15 #define __I_SOUND__
16 
17 #include "doomdef.h"
18 #include "sounds.h"
19 #include "command.h"
20 
21 // copied from SDL mixer, plus GME
22 typedef enum {
23 	MU_NONE,
24 	MU_WAV,
25 	MU_MOD,
26 	MU_MID,
27 	MU_OGG,
28 	MU_MP3,
29 	MU_FLAC,
30 	MU_GME,
31 	MU_MOD_EX, // libopenmpt
32 	MU_MID_EX // Non-native MIDI
33 } musictype_t;
34 
35 /**	\brief Sound subsystem runing and waiting
36 */
37 extern UINT8 sound_started;
38 
39 /**	\brief info of samplerate
40 */
41 extern consvar_t cv_samplerate;
42 //extern consvar_t cv_rndsoundpitch;
43 
44 /**	\brief	The I_GetSfx function
45 
46 	\param	sfx	sfx to setup
47 
48 	\return	data for sfx
49 */
50 void *I_GetSfx(sfxinfo_t *sfx);
51 
52 /**	\brief	The I_FreeSfx function
53 
54 	\param	sfx	sfx to be freed up
55 
56 	\return	void
57 */
58 void I_FreeSfx(sfxinfo_t *sfx);
59 
60 /**	\brief Init at program start...
61 */
62 void I_StartupSound(void);
63 
64 /**	\brief ... shut down and relase at program termination.
65 */
66 void I_ShutdownSound(void);
67 
68 /// ------------------------
69 ///  SFX I/O
70 /// ------------------------
71 
72 /**	\brief	Starts a sound in a particular sound channel.
73 	\param	id	sfxid
74 	\param	vol	volume for sound
75 	\param	sep	left-right balancle
76 	\param	pitch	not used
77 	\param	priority	not used
78 
79 	\return	sfx handle
80 */
81 INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel);
82 
83 /**	\brief	Stops a sound channel.
84 
85 	\param	handle	stop sfx handle
86 
87 	\return	void
88 */
89 void I_StopSound(INT32 handle);
90 
91 /**	\brief Some digital sound drivers need this.
92 */
93 void I_UpdateSound(void);
94 
95 /**	\brief	Called by S_*() functions to see if a channel is still playing.
96 
97 	\param	handle	sfx handle
98 
99 	\return	0 if no longer playing, 1 if playing.
100 */
101 boolean I_SoundIsPlaying(INT32 handle);
102 
103 /**	\brief	Updates the sfx handle
104 
105 	\param	handle	sfx handle
106 	\param	vol	volume
107 	\param	sep	separation
108 	\param	pitch	ptich
109 
110 	\return	void
111 */
112 void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch);
113 
114 /**	\brief	The I_SetSfxVolume function
115 
116 	\param	volume	volume to set at
117 
118 	\return	void
119 */
120 void I_SetSfxVolume(UINT8 volume);
121 
122 /// ------------------------
123 //  MUSIC SYSTEM
124 /// ------------------------
125 
126 /** \brief Init the music systems
127 */
128 void I_InitMusic(void);
129 
130 /** \brief Shutdown the music systems
131 */
132 void I_ShutdownMusic(void);
133 
134 /// ------------------------
135 //  MUSIC PROPERTIES
136 /// ------------------------
137 
138 musictype_t I_SongType(void);
139 boolean I_SongPlaying(void);
140 boolean I_SongPaused(void);
141 
142 /// ------------------------
143 //  MUSIC EFFECTS
144 /// ------------------------
145 
146 boolean I_SetSongSpeed(float speed);
147 
148 /// ------------------------
149 //  MUSIC SEEKING
150 /// ------------------------
151 
152 UINT32 I_GetSongLength(void);
153 
154 boolean I_SetSongLoopPoint(UINT32 looppoint);
155 UINT32 I_GetSongLoopPoint(void);
156 
157 boolean I_SetSongPosition(UINT32 position);
158 UINT32 I_GetSongPosition(void);
159 
160 /// ------------------------
161 //  MUSIC PLAYBACK
162 /// ------------------------
163 
164 /**	\brief	Registers a song handle to song data.
165 
166 	\param	data	pointer to song data
167 	\param	len	len of data
168 
169 	\return	song handle
170 
171 	\todo Remove this
172 */
173 boolean I_LoadSong(char *data, size_t len);
174 
175 /**	\brief	See ::I_LoadSong, then think backwards
176 
177 	\param	handle	song handle
178 
179 	\sa I_LoadSong
180 	\todo remove midi handle
181 */
182 void I_UnloadSong(void);
183 
184 /**	\brief	Called by anything that wishes to start music
185 
186 	\param	handle	Song handle
187 	\param	looping	looping it if true
188 
189 	\return	if true, it's playing the song
190 
191 	\todo pass music name, not handle
192 */
193 boolean I_PlaySong(boolean looping);
194 
195 /**	\brief	Stops a song over 3 seconds
196 
197 	\param	handle	Song handle
198 	\return	void
199 
200 	/todo drop handle
201 */
202 void I_StopSong(void);
203 
204 /**	\brief	PAUSE game handling.
205 
206 	\param	handle	song handle
207 
208 	\return	void
209 */
210 void I_PauseSong(void);
211 
212 /**	\brief	RESUME game handling
213 
214 	\param	handle	song handle
215 
216 	\return	void
217 */
218 void I_ResumeSong(void);
219 
220 /**	\brief	The I_SetMusicVolume function
221 
222 	\param	volume	volume to set at
223 
224 	\return	void
225 */
226 void I_SetMusicVolume(UINT8 volume);
227 
228 boolean I_SetSongTrack(INT32 track);
229 
230 /// ------------------------
231 /// MUSIC FADING
232 /// ------------------------
233 
234 void I_SetInternalMusicVolume(UINT8 volume);
235 void I_StopFadingSong(void);
236 boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void));
237 boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void));
238 boolean I_FadeOutStopSong(UINT32 ms);
239 boolean I_FadeInPlaySong(UINT32 ms, boolean looping);
240 
241 #endif
242