2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "matrixlib.h"
27 // ====================================================================
29 // ====================================================================
31 #define DEFAULT_SOUND_PACKET_VOLUME 255
32 #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
35 // These channel flags can be used for sound() builtins, with SOUNDFLAG_* names
36 #define CHANNELFLAG_NONE 0
37 #define CHANNELFLAG_RELIABLE (1 << 0) // send as reliable message (only used on server)
38 #define CHANNELFLAG_FORCELOOP (1 << 1) // force looping even if the sound is not looped
39 #define CHANNELFLAG_LOCALSOUND (1 << 2) // INTERNAL USE. Not settable by S_SetChannelFlag
40 #define CHANNELFLAG_PAUSED (1 << 3) // pause status
41 #define CHANNELFLAG_FULLVOLUME (1 << 4) // isn't affected by the general volume
43 // ====================================================================
44 // Types and variables
45 // ====================================================================
47 typedef struct sfx_s sfx_t;
49 extern cvar_t mastervolume;
50 extern cvar_t bgmvolume;
52 extern cvar_t snd_initialized;
53 extern cvar_t snd_staticvolume;
54 extern cvar_t snd_mutewhenidle;
57 // ====================================================================
59 // ====================================================================
62 void S_Terminate (void);
64 void S_Startup (void);
65 void S_Shutdown (void);
66 void S_UnloadAllSounds_f(cmd_state_t *cmd);
68 void S_Update(const matrix4x4_t *listenermatrix);
69 void S_ExtraUpdate (void);
71 sfx_t *S_PrecacheSound (const char *sample, qboolean complain, qboolean levelsound);
72 float S_SoundLength(const char *name);
73 void S_ClearUsed (void);
74 void S_PurgeUnused (void);
75 qboolean S_IsSoundPrecached (const sfx_t *sfx);
76 sfx_t *S_FindName(const char *name);
78 // these define the "engine" channel namespace
79 #define CHAN_MIN_AUTO -128
80 #define CHAN_MAX_AUTO 0
81 #define CHAN_MIN_SINGLE 1
82 #define CHAN_MAX_SINGLE 127
83 #define IS_CHAN_AUTO(n) ((n) >= CHAN_MIN_AUTO && (n) <= CHAN_MAX_AUTO)
84 #define IS_CHAN_SINGLE(n) ((n) >= CHAN_MIN_SINGLE && (n) <= CHAN_MAX_SINGLE)
85 #define IS_CHAN(n) (IS_CHAN_AUTO(n) || IS_CHAN_SINGLE(n))
87 // engine channel == network channel
88 #define CHAN_ENGINE2NET(c) (c)
89 #define CHAN_NET2ENGINE(c) (c)
91 // engine view of channel encodes the auto flag into the channel number (see CHAN_ constants below)
92 // user view uses the flags bitmask for it
93 #define CHAN_USER2ENGINE(c) (c)
94 #define CHAN_ENGINE2USER(c) (c)
95 #define CHAN_ENGINE2CVAR(c) (abs(c))
97 // S_StartSound returns the channel index, or -1 if an error occurred
98 int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
99 int S_StartSound_StartPosition_Flags (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition, int flags, float fspeed);
100 qboolean S_LocalSound (const char *s);
102 void S_StaticSound (sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
103 void S_StopSound (int entnum, int entchannel);
104 void S_StopAllSounds (void);
105 void S_StopAllSounds_f(cmd_state_t *cmd);
106 void S_PauseGameSounds (qboolean toggle);
108 void S_StopChannel (unsigned int channel_ind, qboolean lockmutex, qboolean freesfx);
109 qboolean S_SetChannelFlag (unsigned int ch_ind, unsigned int flag, qboolean value);
110 void S_SetChannelVolume (unsigned int ch_ind, float fvol);
111 void S_SetChannelSpeed (unsigned int ch_ind, float fspeed);
112 float S_GetChannelPosition (unsigned int ch_ind);
113 float S_GetEntChannelPosition(int entnum, int entchannel);
115 void S_BlockSound (void);
116 void S_UnblockSound (void);
118 int S_GetSoundRate (void);
119 int S_GetSoundChannels (void);
120 int S_GetSoundWidth (void);