File: ds.h

package info (click to toggle)
freespace2 24.2.0%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 43,716 kB
  • sloc: cpp: 595,001; ansic: 21,741; python: 1,174; sh: 457; makefile: 248; xml: 181
file content (236 lines) | stat: -rw-r--r-- 6,168 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/*
 * Copyright (C) Volition, Inc. 1999.  All rights reserved.
 *
 * All source code herein is the property of Volition, Inc. You may not sell 
 * or otherwise commercially exploit the source or things you created based on the 
 * source.
 *
*/



#ifndef __DS_H__
#define __DS_H__

#include "globalincs/pstypes.h"
#include "sound/IAudioFile.h"
#include "utils/id.h"

// Constants that DirectSound should assign, but doesn't
#define MIN_PITCH		100
#define MAX_PITCH		100000


// User specified sound quality
#define DS_SQ_LOW		0
#define DS_SQ_MEDIUM	1
#define DS_SQ_HIGH		2

extern int Ds_sound_quality;
extern int Ds_float_supported;

// limits placed on how many concurrent sounds of the same type can play simultaneously
#define DS_MUST_PLAY	0
#define DS_LIMIT_ONE	1
#define DS_LIMIT_TWO	2
#define DS_LIMIT_THREE	3

struct EnhancedSoundData;

#define DS_3D		(1<<0)

#define DS_RESERVED_CHANNELS 32

typedef struct sound_info {
	uint size;
	int sample_rate;
	int avg_bytes_per_sec;
	int bits;
	int n_channels;
	int duration;	// time in ms for duration of sound
} sound_info;

extern int ds_initialized;

struct ds_sound_handle_tag {
};
using ds_sound_handle = ::util::ID<ds_sound_handle_tag, int, -1>;

int ds_init();
void ds_close();
int ds_load_buffer(int *sid, int flags, sound::IAudioFile* file);
void ds_unload_buffer(int sid);
ds_sound_handle ds_play(int sid, int snd_id, int priority, const EnhancedSoundData* enhanced_sound_data, float volume,
                        float pan, int looping, bool is_voice_msg = false);
int ds_get_channel(ds_sound_handle sig);
int ds_get_channel_raw(ds_sound_handle sig);
int ds_is_channel_playing(int channel);
bool ds_is_channel_paused(int channel_id);
void ds_stop_channel(int channel);
void ds_pause_channel(int channel_id);
void ds_resume_channel(int channel_id);
void ds_stop_channel_all();
void ds_set_volume( int channel, float vol );
void ds_set_pan( int channel, float pan );
/**
 * @brief Get the pitch of a channel
 *
 * @details A pitch value of 1.0 means that the original sound is not changed.
 */
float ds_get_pitch(int channel);
/**
 * @brief Set the pitch of a channel
 *
 * @details A pitch value of 1.0 means that the original sound is not changed.
 */
void ds_set_pitch(int channel, float pitch);
void ds_set_position(int channel, unsigned int offset);
unsigned int ds_get_play_position(int channel);
int ds_get_data(int sid, char *data);
int ds_get_size(int sid, int *size);

int ds_create_buffer(int frequency, int bits_per_sample, int nchannels, int nseconds);
int ds_lock_data(int sid, unsigned char *data, int size);
void ds_stop_easy(int sid);
int ds_get_channel_size(int channel);

int ds_get_sound_id(int channel);

// Returns the number of channels that are actually playing
int ds_get_number_channels();

ds_sound_handle ds3d_play(int sid, int snd_id, const vec3d* pos, const vec3d* vel, float min, float max, bool looping,
                          float max_volume, float estimated_vol, const EnhancedSoundData* enhanced_sound_data,
                          int priority = DS_MUST_PLAY, bool is_ambient = false);

void ds_do_frame();

// --------------------
//
// Creative eax.h
//
// --------------------

// use this structure for get/set all properties...

// used for const array of default values
typedef struct EFXREVERBPROPERTIES_list
{
	const char *name;
	float flDensity;
	float flDiffusion;
	float flGain;
	float flGainHF;
	float flGainLF;
	float flDecayTime;
	float flDecayHFRatio;
	float flDecayLFRatio;
	float flReflectionsGain;
	float flReflectionsDelay;
	float flReflectionsPan[3];
	float flLateReverbGain;
	float flLateReverbDelay;
	float flLateReverbPan[3];
	float flEchoTime;
	float flEchoDepth;
	float flModulationTime;
	float flModulationDepth;
	float flAirAbsorptionGainHF;
	float flHFReference;
	float flLFReference;
	float flRoomRolloffFactor;
	int	iDecayHFLimit;
} EFXREVERBPROPERTIES_list;

typedef struct EFXREVERBPROPERTIES
{
	SCP_string name;
	float flDensity;
	float flDiffusion;
	float flGain;
	float flGainHF;
	float flGainLF;
	float flDecayTime;
	float flDecayHFRatio;
	float flDecayLFRatio;
	float flReflectionsGain;
	float flReflectionsDelay;
	float flReflectionsPan[3];
	float flLateReverbGain;
	float flLateReverbDelay;
	float flLateReverbPan[3];
	float flEchoTime;
	float flEchoDepth;
	float flModulationTime;
	float flModulationDepth;
	float flAirAbsorptionGainHF;
	float flHFReference;
	float flLFReference;
	float flRoomRolloffFactor;
	int	iDecayHFLimit;
	EFXREVERBPROPERTIES()
	{
	}
	EFXREVERBPROPERTIES(const EFXREVERBPROPERTIES_list &list);
} EFXREVERBPROPERTIES;

extern SCP_vector<EFXREVERBPROPERTIES> EFX_presets;

typedef struct
{
	size_t environment;	// 0 to EAX_ENVIRONMENT_COUNT-1
	float fVolume;				// 0 to 1
	float fDecayTime_sec;		// seconds, 0.1 to 100
	float fDamping;				// 0 to 1
} EAX_REVERBPROPERTIES;

enum
{
	EAX_ENVIRONMENT_GENERIC,
	EAX_ENVIRONMENT_PADDEDCELL,
	EAX_ENVIRONMENT_ROOM,
	EAX_ENVIRONMENT_BATHROOM,
	EAX_ENVIRONMENT_LIVINGROOM,
	EAX_ENVIRONMENT_STONEROOM,
	EAX_ENVIRONMENT_AUDITORIUM,
	EAX_ENVIRONMENT_CONCERTHALL,
	EAX_ENVIRONMENT_CAVE,
	EAX_ENVIRONMENT_ARENA,
	EAX_ENVIRONMENT_HANGAR,
	EAX_ENVIRONMENT_CARPETEDHALLWAY,
	EAX_ENVIRONMENT_HALLWAY,
	EAX_ENVIRONMENT_STONECORRIDOR,
	EAX_ENVIRONMENT_ALLEY,
	EAX_ENVIRONMENT_FOREST,
	EAX_ENVIRONMENT_CITY,
	EAX_ENVIRONMENT_MOUNTAINS,
	EAX_ENVIRONMENT_QUARRY,
	EAX_ENVIRONMENT_PLAIN,
	EAX_ENVIRONMENT_PARKINGLOT,
	EAX_ENVIRONMENT_SEWERPIPE,
	EAX_ENVIRONMENT_UNDERWATER,
	EAX_ENVIRONMENT_DRUGGED,
	EAX_ENVIRONMENT_DIZZY,
	EAX_ENVIRONMENT_PSYCHOTIC,
	EAX_ENVIRONMENT_COUNT		// total number of environments
};

#define EAX_MAX_ENVIRONMENT (EAX_ENVIRONMENT_COUNT - 1)


// prototypes

int ds_eax_init();
void ds_eax_close();

int ds_eax_get_preset_id(const char *name);
int ds_eax_get_prop(EFXREVERBPROPERTIES **props, const char *name, const char *template_name = NULL);

int ds_eax_set_volume(float volume);
int ds_eax_set_decay_time(float seconds);
int ds_eax_set_damping(float damp);
int ds_eax_set_all(unsigned long id, float volume, float damping, float decay);
int ds_eax_get_all(EAX_REVERBPROPERTIES *er, int id = -1);
int ds_eax_is_inited();

#endif /* __DS_H__ */