|
|
1.1 root 1: // snd_loc.h -- private sound functions
2:
3: // !!! if this is changed, the asm code must change !!!
4: typedef struct
5: {
6: int left;
7: int right;
8: } portable_samplepair_t;
9:
10: typedef struct
11: {
12: int length;
13: int loopstart;
14: int speed; // not needed, because converted on load?
15: int width;
16: int stereo;
17: byte data[1]; // variable sized
18: } sfxcache_t;
19:
20: typedef struct sfx_s
21: {
22: char name[MAX_QPATH];
23: int registration_sequence;
24: sfxcache_t *cache;
1.1.1.2 ! root 25: char *truename;
1.1 root 26: } sfx_t;
27:
28: // a playsound_t will be generated by each call to S_StartSound,
29: // when the mixer reaches playsound->begin, the playsound will
30: // be assigned to a channel
31: typedef struct playsound_s
32: {
33: struct playsound_s *prev, *next;
34: sfx_t *sfx;
35: float volume;
36: float attenuation;
37: int entnum;
38: int entchannel;
39: qboolean fixed_origin; // use origin field instead of entnum's origin
40: vec3_t origin;
41: unsigned begin; // begin on this sample
42: } playsound_t;
43:
44: typedef struct
45: {
46: int channels;
47: int samples; // mono samples in buffer
48: int submission_chunk; // don't mix less than this #
49: int samplepos; // in mono samples
50: int samplebits;
51: int speed;
52: byte *buffer;
53: } dma_t;
54:
55: // !!! if this is changed, the asm code must change !!!
56: typedef struct
57: {
58: sfx_t *sfx; // sfx number
59: int leftvol; // 0-255 volume
60: int rightvol; // 0-255 volume
61: int end; // end time in global paintsamples
62: int pos; // sample position in sfx
63: int looping; // where to loop, -1 = no looping OBSOLETE?
64: int entnum; // to allow overriding a specific sound
65: int entchannel; //
66: vec3_t origin; // only use if fixed_origin is set
67: vec_t dist_mult; // distance multiplier (attenuation/clipK)
68: int master_vol; // 0-255 master volume
69: qboolean fixed_origin; // use origin instead of fetching entnum's origin
70: qboolean autosound; // from an entity->sound, cleared each frame
71: } channel_t;
72:
73: typedef struct
74: {
75: int rate;
76: int width;
77: int channels;
78: int loopstart;
79: int samples;
80: int dataofs; // chunk starts this many bytes from file start
81: } wavinfo_t;
82:
83:
84: /*
85: ====================================================================
86:
87: SYSTEM SPECIFIC FUNCTIONS
88:
89: ====================================================================
90: */
91:
92: // initializes cycling through a DMA buffer and returns information on it
93: qboolean SNDDMA_Init(void);
94:
95: // gets the current DMA position
96: int SNDDMA_GetDMAPos(void);
97:
98: // shutdown the DMA xfer.
99: void SNDDMA_Shutdown(void);
100:
101: void SNDDMA_BeginPainting (void);
102:
103: void SNDDMA_Submit(void);
104:
105: //====================================================================
106:
107: #define MAX_CHANNELS 32
108: extern channel_t channels[MAX_CHANNELS];
109:
110: extern int paintedtime;
111: extern int s_rawend;
112: extern vec3_t listener_origin;
113: extern vec3_t listener_forward;
114: extern vec3_t listener_right;
115: extern vec3_t listener_up;
116: extern dma_t dma;
117: extern playsound_t s_pendingplays;
118:
119: #define MAX_RAW_SAMPLES 8192
120: extern portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
121:
122: extern cvar_t *s_volume;
123: extern cvar_t *s_nosound;
124: extern cvar_t *s_loadas8bit;
125: extern cvar_t *s_khz;
126: extern cvar_t *s_show;
127: extern cvar_t *s_mixahead;
128: extern cvar_t *s_testsound;
129: extern cvar_t *s_primary;
130:
131: wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength);
132:
133: void S_InitScaletable (void);
134:
135: sfxcache_t *S_LoadSound (sfx_t *s);
136:
137: void S_IssuePlaysound (playsound_t *ps);
138:
139: void S_PaintChannels(int endtime);
140:
141: // picks a channel based on priorities, empty slots, number of channels
142: channel_t *S_PickChannel(int entnum, int entchannel);
143:
144: // spatializes a channel
145: void S_Spatialize(channel_t *ch);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.