]> icculus.org git repositories - divverent/darkplaces.git/blob - sound.h
Collision against patches: do some major optimizations.
[divverent/darkplaces.git] / sound.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
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.
8
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.
12
13 See the GNU General Public License for more details.
14
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.
18
19 */
20
21 #ifndef SOUND_H
22 #define SOUND_H
23
24 #include "matrixlib.h"
25
26
27 // ====================================================================
28 // Constants
29 // ====================================================================
30
31 #define DEFAULT_SOUND_PACKET_VOLUME 255
32 #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
33
34 // Channel flags
35 #define CHANNELFLAG_NONE                0
36 #define CHANNELFLAG_FORCELOOP   (1 << 0) // force looping even if the sound is not looped
37 #define CHANNELFLAG_LOCALSOUND  (1 << 1) // INTERNAL USE. Not settable by S_SetChannelFlag
38 #define CHANNELFLAG_PAUSED              (1 << 2)
39 #define CHANNELFLAG_FULLVOLUME  (1 << 3) // isn't affected by the general volume
40
41
42 // ====================================================================
43 // Types and variables
44 // ====================================================================
45
46 typedef struct sfx_s sfx_t;
47
48 extern cvar_t bgmvolume;
49 extern cvar_t volume;
50 extern cvar_t snd_initialized;
51 extern cvar_t snd_staticvolume;
52 extern cvar_t snd_mutewhenidle;
53
54
55 // ====================================================================
56 // Functions
57 // ====================================================================
58
59 void S_Init (void);
60 void S_Terminate (void);
61
62 void S_Startup (void);
63 void S_Shutdown (void);
64 void S_UnloadAllSounds_f (void);
65
66 void S_Update(const matrix4x4_t *listenermatrix);
67 void S_ExtraUpdate (void);
68
69 sfx_t *S_PrecacheSound (const char *sample, qboolean complain, qboolean serversound);
70 void S_ClearUsed (void);
71 void S_PurgeUnused (void);
72 qboolean S_IsSoundPrecached (const sfx_t *sfx);
73
74 // S_StartSound returns the channel index, or -1 if an error occurred
75 int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
76 qboolean S_LocalSound (const char *s);
77
78 void S_StaticSound (sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
79 void S_StopSound (int entnum, int entchannel);
80 void S_StopAllSounds (void);
81 void S_PauseGameSounds (qboolean toggle);
82
83 void S_StopChannel (unsigned int channel_ind, qboolean lockmutex);
84 qboolean S_SetChannelFlag (unsigned int ch_ind, unsigned int flag, qboolean value);
85 void S_SetChannelVolume (unsigned int ch_ind, float fvol);
86 float S_GetChannelPosition (unsigned int ch_ind);
87
88 void S_BlockSound (void);
89 void S_UnblockSound (void);
90
91 int S_GetSoundRate (void);
92 int S_GetSoundChannels (void);
93
94 #endif