1 // Emacs style mode select   -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // $Id: s_sound.h 1403 2018-07-06 09:49:21Z wesleyjohnson $
5 //
6 // Copyright (C) 1993-1996 by id Software, Inc.
7 // Portions Copyright (C) 1998-2000 by DooM Legacy Team.
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 //
20 // $Log: s_sound.h,v $
21 // Revision 1.9  2002/09/12 20:10:51  hurdler
22 // Added some cvars
23 //
24 // Revision 1.8  2001/04/17 22:26:07  calumr
25 // Initial Mac add
26 //
27 // Revision 1.7  2001/02/24 13:35:21  bpereira
28 //
29 // Revision 1.6  2000/11/02 17:50:10  stroggonmeth
30 // Big 3Dfloors & FraggleScript commit!!
31 //
32 // Revision 1.5  2000/05/13 19:52:10  metzgermeister
33 // cd vol jiggle
34 //
35 // Revision 1.4  2000/04/21 08:23:47  emanne
36 // To have SDL working.
37 // qmus2mid.h: force include of qmus2mid_sdl.h when needed.
38 // s_sound.h: with it.
39 //
40 // Revision 1.3  2000/03/12 23:21:10  linuxcub
41 // Added consvars which hold the filenames and arguments which will be used
42 // when running the soundserver and musicserver (under Linux). I hope I
43 // didn't break anything ... Erling Jacobsen, linuxcub@email.dk
44 //
45 // Revision 1.2  2000/02/27 00:42:11  hurdler
46 // Revision 1.1.1.1  2000/02/22 20:32:32  hurdler
47 // Initial import into CVS (v1.29 pr3)
48 //
49 //
50 // DESCRIPTION:
51 //      The not so system specific sound interface.
52 //
53 //-----------------------------------------------------------------------------
54 
55 
56 #ifndef S_SOUND_H
57 #define S_SOUND_H
58 
59 #include "doomdef.h"
60   // SNDSERV, MUSSERV, CDMUS, MACOS_DI
61 #include "sounds.h"
62   // sfxinfo_t
63 #include "command.h"
64   // consvar_t
65 #include "m_fixed.h"
66 #include "p_mobj.h"
67   // mobj_t
68 #include "sounds.h"
69   // sfxinfo_t
70 #include "r_defs.h"
71   // sector_t
72 
73 #ifdef SURROUND_SOUND
74 #define SURROUND_SEP            1024
75 #endif
76 
77 // killough 4/25/98: mask used to indicate sound origin is player item pickup
78 #define PICKUP_SOUND (0x8000)
79 
80 extern consvar_t stereoreverse;
81 
82 extern consvar_t cv_soundvolume;
83 extern consvar_t cv_musicvolume;
84 extern consvar_t cv_numChannels;
85 extern consvar_t cv_rndsoundpitch;
86 
87 #ifdef SNDSERV
88 extern consvar_t cv_sndserver_cmd;
89 extern consvar_t cv_sndserver_arg;
90 #endif
91 #ifdef MUSSERV
92 extern consvar_t cv_musserver_cmd;
93 extern consvar_t cv_musserver_arg;
94 extern consvar_t cv_musserver_opt;
95 #endif
96 
97 extern CV_PossibleValue_t soundvolume_cons_t[];
98 #ifdef CDMUS
99 //part of i_cdmus.c
100 extern consvar_t cd_volume;
101 extern consvar_t cdUpdate;
102 #endif
103 
104 #ifdef MACOS_DI        //mp3 playlist stuff
105 // specific to macos directory
106 typedef enum
107 {
108     music_normal,
109     playlist_random,
110     playlist_normal
111 } playmode_t;
112 
113 extern consvar_t  play_mode;
114 #endif
115 
116 // Register sound vars and commands at game startup.
117 void S_Register_SoundStuff (void);
118 
119 
120 //
121 // Initializes sound stuff, including volume
122 // Sets channels, SFX and music volume,
123 //  allocates channel buffer, sets S_sfx lookup.
124 //
125 void S_Init (int sfxVolume, int musicVolume);
126 
127 
128 //
129 // Per level startup code.
130 // Kills playing sounds at start of level,
131 //  determines music if any, changes music.
132 //
133 void S_Stop_LevelSound(void);
134 void S_Start_LevelSound(void);
135 
136 // [WDJ] Common routine for handling sfx names
137 void S_GetSfxLump( sfxinfo_t * sfx );
138 // [WDJ] Common routine to Free data for a sfx
139 void S_FreeSfx( sfxinfo_t * sfx );
140 
141 // Used by hardware sound.
142 // Easier to pass by default instead of making it conditional.
143 typedef enum
144 {
145     CT_NORMAL = 0,
146     CT_ATTACK,
147     CT_SCREAM,
148     CT_AMBIENT
149 } channel_type_t;
150 
151 
152 // General sounds, no location.
153 void S_StartSound( sfxid_t sfx_id );
154 
155 // Unusual sfx sounds are called through this interface.
156 void S_StartXYZSound(const xyz_t * origin, sfxid_t sfx_id);
157 void S_StartXYZSoundName(const xyz_t *origin, const mobj_t * mo,
158                          const char *soundname);
159 
160 // Most sector sfx sounds are called through this interface.
161 void S_StartSecSound(const sector_t *sec, sfxid_t sfx_id);
162 void S_StopSecSound(const sector_t *sec);
163 
164 // Most Mobj sfx sounds are called through this interface.
165 void S_StartObjSound(const mobj_t *mo, sfxid_t sfx_id);
166 void S_StopObjSound(const mobj_t *mo);
167 // Special cases of 3D sources
168 void S_StartAttackSound(const mobj_t *mo, sfxid_t sfx_id);
169 void S_StartScreamSound(const mobj_t *mo, sfxid_t sfx_id);
170 
171 // Ambient sounds, with no location.
172 void S_StartAmbientSound(sfxid_t sfx_id, int volume);
173 
174 
175 // Start music using <music_id> from sounds.h
176 void S_StartMusic(int music_id);
177 
178 // Start music using <music_id> from sounds.h.
179 //   looping : non-zero if continuous looping of music
180 void S_ChangeMusic (int music_num, byte looping);
181 void S_ChangeMusicName( const char * name, byte looping);
182 
183 // Stops the music fer sure.
184 void S_StopMusic(void);
185 
186 // Stop and resume music, during game PAUSE.
187 void S_PauseSound(void);
188 void S_ResumeSound(void);
189 
190 
191 //
192 // Updates music & sounds
193 //
194 void S_UpdateSounds(void);
195 
196 //  volume : volume control,  0..31
197 void S_SetMusicVolume(int volume);
198 //  volume : volume control,  0..31
199 void S_SetSfxVolume(int volume);
200 
201 //   origin : the object to check,  if NULL do not check it
202 //   sfxid : the sfx to check,  if sfx_None do not check it
203 // returns true if either is found.
204 boolean  S_SoundPlaying(xyz_t *origin, sfxid_t sfxid);
205 
206 #endif
207