vkQuake2 doxygen  1.0 dev
snd_loc.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 1997-2001 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 // snd_loc.h -- private sound functions
21 
22 // !!! if this is changed, the asm code must change !!!
23 typedef struct
24 {
25  int left;
26  int right;
28 
29 typedef struct
30 {
31  int length;
32  int loopstart;
33  int speed; // not needed, because converted on load?
34  int width;
35  int stereo;
36  byte data[1]; // variable sized
37 } sfxcache_t;
38 
39 typedef struct sfx_s
40 {
41  char name[MAX_QPATH];
44  char *truename;
45 } sfx_t;
46 
47 // a playsound_t will be generated by each call to S_StartSound,
48 // when the mixer reaches playsound->begin, the playsound will
49 // be assigned to a channel
50 typedef struct playsound_s
51 {
52  struct playsound_s *prev, *next;
54  float volume;
55  float attenuation;
56  int entnum;
58  qboolean fixed_origin; // use origin field instead of entnum's origin
60  unsigned begin; // begin on this sample
61 } playsound_t;
62 
63 typedef struct
64 {
65  int channels;
66  int samples; // mono samples in buffer
67  int submission_chunk; // don't mix less than this #
68  int samplepos; // in mono samples
70  int speed;
71  byte *buffer;
72 } dma_t;
73 
74 // !!! if this is changed, the asm code must change !!!
75 typedef struct
76 {
77  sfx_t *sfx; // sfx number
78  int leftvol; // 0-255 volume
79  int rightvol; // 0-255 volume
80  int end; // end time in global paintsamples
81  int pos; // sample position in sfx
82  int looping; // where to loop, -1 = no looping OBSOLETE?
83  int entnum; // to allow overriding a specific sound
84  int entchannel; //
85  vec3_t origin; // only use if fixed_origin is set
86  vec_t dist_mult; // distance multiplier (attenuation/clipK)
87  int master_vol; // 0-255 master volume
88  qboolean fixed_origin; // use origin instead of fetching entnum's origin
89  qboolean autosound; // from an entity->sound, cleared each frame
90 } channel_t;
91 
92 typedef struct
93 {
94  int rate;
95  int width;
96  int channels;
97  int loopstart;
98  int samples;
99  int dataofs; // chunk starts this many bytes from file start
100 } wavinfo_t;
101 
102 
103 /*
104 ====================================================================
105 
106  SYSTEM SPECIFIC FUNCTIONS
107 
108 ====================================================================
109 */
110 
111 // initializes cycling through a DMA buffer and returns information on it
112 int SNDDMA_Init(void);
113 
114 // gets the current DMA position
115 int SNDDMA_GetDMAPos(void);
116 
117 // shutdown the DMA xfer.
118 void SNDDMA_Shutdown(void);
119 
120 void SNDDMA_BeginPainting (void);
121 
122 void SNDDMA_Submit(void);
123 
124 //====================================================================
125 
126 #define MAX_CHANNELS 32
128 
129 extern int paintedtime;
130 extern int s_rawend;
131 extern vec3_t listener_origin;
132 extern vec3_t listener_forward;
133 extern vec3_t listener_right;
134 extern vec3_t listener_up;
135 extern dma_t dma;
137 
138 #define MAX_RAW_SAMPLES 8192
140 
141 extern cvar_t *s_volume;
142 extern cvar_t *s_nosound;
143 extern cvar_t *s_loadas8bit;
144 extern cvar_t *s_khz;
145 extern cvar_t *s_show;
146 extern cvar_t *s_mixahead;
147 extern cvar_t *s_testsound;
148 extern cvar_t *s_primary;
149 
150 wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength);
151 
152 void S_InitScaletable (void);
153 
155 
156 void S_IssuePlaysound (playsound_t *ps);
157 
158 void S_PaintChannels(int endtime);
159 
160 // picks a channel based on priorities, empty slots, number of channels
162 
163 // spatializes a channel
164 void S_Spatialize(channel_t *ch);
MAX_CHANNELS
#define MAX_CHANNELS
Definition: snd_loc.h:126
s_rawend
int s_rawend
Definition: snd_dma.c:83
GetWavinfo
wavinfo_t GetWavinfo(char *name, byte *wav, int wavlength)
Definition: snd_mem.c:267
MAX_QPATH
#define MAX_QPATH
Definition: q_shared.h:80
s_loadas8bit
cvar_t * s_loadas8bit
Definition: snd_dma.c:76
channel_t::pos
int pos
Definition: snd_loc.h:81
wavinfo_t::width
int width
Definition: snd_loc.h:95
sfxcache_t::length
int length
Definition: snd_loc.h:31
channel_t::sfx
sfx_t * sfx
Definition: snd_loc.h:77
s_nosound
cvar_t * s_nosound
channel_t::entnum
int entnum
Definition: snd_loc.h:83
channel_t::fixed_origin
qboolean fixed_origin
Definition: snd_loc.h:88
S_PaintChannels
void S_PaintChannels(int endtime)
Definition: snd_mix.c:224
channel_t::looping
int looping
Definition: snd_loc.h:82
sfx_s::truename
char * truename
Definition: snd_loc.h:44
listener_up
vec3_t listener_up
Definition: snd_dma.c:52
s_testsound
cvar_t * s_testsound
Definition: snd_dma.c:75
playsound_s
Definition: snd_loc.h:50
channel_t::autosound
qboolean autosound
Definition: snd_loc.h:89
wavinfo_t::channels
int channels
Definition: snd_loc.h:96
channel_t::rightvol
int rightvol
Definition: snd_loc.h:79
wavinfo_t::samples
int samples
Definition: snd_loc.h:98
qboolean
qboolean
Definition: q_shared.h:63
sfx_s
Definition: snd_loc.h:39
dma_t::submission_chunk
int submission_chunk
Definition: snd_loc.h:67
sfxcache_t::stereo
int stereo
Definition: snd_loc.h:35
s_volume
cvar_t * s_volume
Definition: snd_dma.c:74
channel_t::leftvol
int leftvol
Definition: snd_loc.h:78
s_primary
cvar_t * s_primary
Definition: snd_dma.c:80
dma_t::samples
int samples
Definition: snd_loc.h:66
cvar_s
Definition: q_shared.h:324
playsound_s::attenuation
float attenuation
Definition: snd_loc.h:55
portable_samplepair_t::left
int left
Definition: snd_loc.h:25
sfxcache_t::speed
int speed
Definition: snd_loc.h:33
S_Spatialize
void S_Spatialize(channel_t *ch)
Definition: snd_dma.c:477
playsound_s::begin
unsigned begin
Definition: snd_loc.h:60
sfx_t
struct sfx_s sfx_t
playsound_s::sfx
sfx_t * sfx
Definition: snd_loc.h:53
MAX_RAW_SAMPLES
#define MAX_RAW_SAMPLES
Definition: snd_loc.h:138
SNDDMA_Shutdown
void SNDDMA_Shutdown(void)
Definition: snd_win.c:829
playsound_s::prev
struct playsound_s * prev
Definition: snd_loc.h:52
sfx_s::cache
sfxcache_t * cache
Definition: snd_loc.h:43
S_LoadSound
sfxcache_t * S_LoadSound(sfx_t *s)
Definition: snd_mem.c:99
S_PickChannel
channel_t * S_PickChannel(int entnum, int entchannel)
Definition: snd_dma.c:375
S_IssuePlaysound
void S_IssuePlaysound(playsound_t *ps)
Definition: snd_dma.c:550
dma_t::buffer
byte * buffer
Definition: snd_loc.h:71
dma_t::channels
int channels
Definition: snd_loc.h:65
listener_right
vec3_t listener_right
Definition: snd_dma.c:51
playsound_s::next
struct playsound_s * next
Definition: snd_loc.h:52
playsound_s::volume
float volume
Definition: snd_loc.h:54
s_pendingplays
playsound_t s_pendingplays
Definition: snd_dma.c:70
playsound_s::entchannel
int entchannel
Definition: snd_loc.h:57
dma_t::speed
int speed
Definition: snd_loc.h:70
channel_t
Definition: snd_loc.h:75
wavinfo_t::rate
int rate
Definition: snd_loc.h:94
name
cvar_t * name
Definition: cl_main.c:79
channel_t::entchannel
int entchannel
Definition: snd_loc.h:84
s
static fixed16_t s
Definition: r_scan.c:30
channels
channel_t channels[MAX_CHANNELS]
Definition: snd_dma.c:42
playsound_t
struct playsound_s playsound_t
vec_t
float vec_t
Definition: q_shared.h:133
s_mixahead
cvar_t * s_mixahead
Definition: snd_dma.c:79
playsound_s::origin
vec3_t origin
Definition: snd_loc.h:59
s_show
cvar_t * s_show
Definition: snd_dma.c:78
SNDDMA_Submit
void SNDDMA_Submit(void)
Definition: snd_win.c:761
dma_t::samplepos
int samplepos
Definition: snd_loc.h:68
s_khz
cvar_t * s_khz
Definition: snd_dma.c:77
listener_forward
vec3_t listener_forward
Definition: snd_dma.c:50
SNDDMA_Init
int SNDDMA_Init(void)
Definition: snd_win.c:593
channel_t::master_vol
int master_vol
Definition: snd_loc.h:87
S_InitScaletable
void S_InitScaletable(void)
Definition: snd_mix.c:350
playsound_s::entnum
int entnum
Definition: snd_loc.h:56
SNDDMA_BeginPainting
void SNDDMA_BeginPainting(void)
Definition: snd_win.c:707
portable_samplepair_t::right
int right
Definition: snd_loc.h:26
portable_samplepair_t
Definition: snd_loc.h:23
s_rawsamples
portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES]
Definition: snd_dma.c:84
wavinfo_t::loopstart
int loopstart
Definition: snd_loc.h:97
dma
dma_t dma
Definition: snd_dma.c:47
sfxcache_t
Definition: snd_loc.h:29
channel_t::origin
vec3_t origin
Definition: snd_loc.h:85
playsound_s::fixed_origin
qboolean fixed_origin
Definition: snd_loc.h:58
sfxcache_t::width
int width
Definition: snd_loc.h:34
dma_t
Definition: snd_loc.h:63
listener_origin
vec3_t listener_origin
Definition: snd_dma.c:49
dma_t::samplebits
int samplebits
Definition: snd_loc.h:69
channel_t::dist_mult
vec_t dist_mult
Definition: snd_loc.h:86
wavinfo_t::dataofs
int dataofs
Definition: snd_loc.h:99
paintedtime
int paintedtime
Definition: snd_dma.c:57
SNDDMA_GetDMAPos
int SNDDMA_GetDMAPos(void)
Definition: snd_win.c:674
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:134
channel_t::end
int end
Definition: snd_loc.h:80
sfxcache_t::loopstart
int loopstart
Definition: snd_loc.h:32
wavinfo_t
Definition: snd_loc.h:92
sfx_s::name
char name[MAX_QPATH]
Definition: snd_loc.h:41
sfx_s::registration_sequence
int registration_sequence
Definition: snd_loc.h:42