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.
20 // sound.h -- client sound i/o functions
25 #define DEFAULT_SOUND_PACKET_VOLUME 255
26 #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
28 // !!! if this is changed, it much be changed in asm_i386.h too !!!
33 } portable_samplepair_t;
41 // !!! if this is changed, it much be changed in asm_i386.h too !!!
49 byte data[1]; // variable sized
58 int samples; // mono samples in buffer
59 int submission_chunk; // don't mix less than this #
60 int samplepos; // in mono samples
63 unsigned char *buffer;
66 // !!! if this is changed, it much be changed in asm_i386.h too !!!
69 sfx_t *sfx; // sfx number
70 int leftvol; // 0-255 volume
71 int rightvol; // 0-255 volume
72 int end; // end time in global paintsamples
73 int pos; // sample position in sfx
74 int looping; // where to loop, -1 = no looping
75 int entnum; // to allow overriding a specific sound
77 vec3_t origin; // origin of sound effect
78 vec_t dist_mult; // distance multiplier (attenuation/clipK)
79 int master_vol; // 0-255 master volume
89 int dataofs; // chunk starts this many bytes from file start
93 void S_Startup (void);
94 void S_Shutdown (void);
95 void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
96 void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
97 void S_StopSound (int entnum, int entchannel);
98 void S_StopAllSounds(qboolean clear);
99 void S_ClearBuffer (void);
100 void S_Update (vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up);
101 void S_ExtraUpdate (void);
103 sfx_t *S_PrecacheSound (char *sample);
104 void S_TouchSound (char *sample);
105 void S_ClearPrecache (void);
106 void S_BeginPrecaching (void);
107 void S_EndPrecaching (void);
108 void S_PaintChannels(int endtime);
109 void S_InitPaintChannels (void);
111 // picks a channel based on priorities, empty slots, number of channels
112 channel_t *SND_PickChannel(int entnum, int entchannel);
114 // spatializes a channel
115 void SND_Spatialize(channel_t *ch);
117 // initializes cycling through a DMA buffer and returns information on it
118 qboolean SNDDMA_Init(void);
120 // gets the current DMA position
121 int SNDDMA_GetDMAPos(void);
123 // shutdown the DMA xfer.
124 void SNDDMA_Shutdown(void);
126 // ====================================================================
127 // User-setable variables
128 // ====================================================================
130 // LordHavoc: increased from 128 to 516 (4 for NUM_AMBIENTS)
131 #define MAX_CHANNELS 516
132 // LordHavoc: increased maximum sound channels from 8 to 128
133 #define MAX_DYNAMIC_CHANNELS 128
136 extern channel_t channels[MAX_CHANNELS];
137 // 0 to MAX_DYNAMIC_CHANNELS-1 = normal entity sounds
138 // MAX_DYNAMIC_CHANNELS to MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS -1 = water, etc
139 // MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS to total_channels = static sounds
141 extern int total_channels;
144 // Fake dma is a synchronous faking of the DMA progress used for
145 // isolating performance in the renderer. The fakedma_updates is
146 // number of times S_Update() is called per second.
149 extern qboolean fakedma;
150 extern int fakedma_updates;
151 extern int paintedtime;
152 extern vec3_t listener_origin;
153 extern vec3_t listener_forward;
154 extern vec3_t listener_right;
155 extern vec3_t listener_up;
156 extern volatile dma_t *shm;
157 extern volatile dma_t sn;
158 extern vec_t sound_nominal_clip_dist;
160 extern cvar_t loadas8bit;
161 extern cvar_t bgmvolume;
162 extern cvar_t volume;
164 extern qboolean snd_initialized;
166 extern int snd_blocked;
168 void S_LocalSound (char *s);
169 sfxcache_t *S_LoadSound (sfx_t *s);
171 wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength);
173 void SND_InitScaletable (void);
174 void SNDDMA_Submit(void);
176 void S_AmbientOff (void);
177 void S_AmbientOn (void);