]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - sound.h
oops, didn't want this debug spam to be committed
[xonotic/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 mastervolume;
49 extern cvar_t bgmvolume;
50 extern cvar_t volume;
51 extern cvar_t snd_initialized;
52 extern cvar_t snd_staticvolume;
53 extern cvar_t snd_mutewhenidle;
54
55
56 // ====================================================================
57 // Functions
58 // ====================================================================
59
60 void S_Init (void);
61 void S_Terminate (void);
62
63 void S_Startup (void);
64 void S_Shutdown (void);
65 void S_UnloadAllSounds_f (void);
66
67 void S_Update(const matrix4x4_t *listenermatrix);
68 void S_ExtraUpdate (void);
69
70 sfx_t *S_PrecacheSound (const char *sample, qboolean complain, qboolean levelsound);
71 float S_SoundLength(const char *name);
72 void S_ClearUsed (void);
73 void S_PurgeUnused (void);
74 qboolean S_IsSoundPrecached (const sfx_t *sfx);
75 sfx_t *S_FindName(const char *name);
76
77 // for sound() builtins
78 #define CHANFLAG_RELIABLE 1
79
80 // these define the "engine" channel namespace
81 #define CHAN_MIN_AUTO       -128
82 #define CHAN_MAX_AUTO          0
83 #define CHAN_MIN_SINGLE        1
84 #define CHAN_MAX_SINGLE      127
85 #define IS_CHAN_AUTO(n)        ((n) >= CHAN_MIN_AUTO && (n) <= CHAN_MAX_AUTO)
86 #define IS_CHAN_SINGLE(n)      ((n) >= CHAN_MIN_SINGLE && (n) <= CHAN_MAX_SINGLE)
87 #define IS_CHAN(n)             (IS_CHAN_AUTO(n) || IS_CHAN_SINGLE(n))
88
89 // engine channel == network channel
90 #define CHAN_ENGINE2NET(c)     (c)
91 #define CHAN_NET2ENGINE(c)     (c)
92
93 // engine view of channel encodes the auto flag into the channel number (see CHAN_ constants below)
94 // user view uses the flags bitmask for it
95 #define CHAN_USER2ENGINE(c)    (c)
96 #define CHAN_ENGINE2USER(c)    (c)
97 #define CHAN_ENGINE2CVAR(c)    (abs(c))
98
99 // S_StartSound returns the channel index, or -1 if an error occurred
100 int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
101 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);
102 qboolean S_LocalSound (const char *s);
103
104 void S_StaticSound (sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
105 void S_StopSound (int entnum, int entchannel);
106 void S_StopAllSounds (void);
107 void S_PauseGameSounds (qboolean toggle);
108
109 void S_StopChannel (unsigned int channel_ind, qboolean lockmutex, qboolean freesfx);
110 qboolean S_SetChannelFlag (unsigned int ch_ind, unsigned int flag, qboolean value);
111 void S_SetChannelVolume (unsigned int ch_ind, float fvol);
112 void S_SetChannelSpeed (unsigned int ch_ind, float fspeed);
113 float S_GetChannelPosition (unsigned int ch_ind);
114 float S_GetEntChannelPosition(int entnum, int entchannel);
115
116 void S_BlockSound (void);
117 void S_UnblockSound (void);
118
119 int S_GetSoundRate (void);
120 int S_GetSoundChannels (void);
121
122 #endif