Open source remastering of the Freespace 2 engine
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
12 #ifndef __DS_H__
13 #define __DS_H__
15 #include "globalincs/pstypes.h"
16 #include "sound/ogg/ogg.h"
17 #include "cfile/cfile.h"
19 #ifdef _WIN32
20 #define VC_EXTRALEAN
21 #include <windows.h>
22 #include <mmsystem.h>
23 #endif
26 // Constants that DirectSound should assign, but doesn't
27 #define MIN_PITCH 100
28 #define MAX_PITCH 100000
31 // User specified sound quality
32 #define DS_SQ_LOW 0
33 #define DS_SQ_MEDIUM 1
34 #define DS_SQ_HIGH 2
36 extern int Ds_sound_quality;
37 extern int Ds_float_supported;
39 // limits placed on how many concurrent sounds of the same type can play simultaneously
40 #define DS_MUST_PLAY 0
41 #define DS_LIMIT_ONE 1
42 #define DS_LIMIT_TWO 2
43 #define DS_LIMIT_THREE 3
45 struct EnhancedSoundData;
47 #define DS_3D (1<<0)
49 typedef struct sound_info {
50  int format; // WAVE_FORMAT_* defines from mmreg.h
51  OggVorbis_File ogg_info;
56  int bits;
58  int duration; // time in ms for duration of sound
60 } sound_info;
62 extern int ds_initialized;
64 int ds_init();
65 void ds_close();
66 int ds_parse_sound(CFILE *fp, ubyte **dest, uint *dest_size, WAVEFORMATEX **header, bool ogg = false, OggVorbis_File *ovf = NULL);
67 int ds_parse_sound_info(char *real_filename, sound_info *s_info);
68 int ds_load_buffer(int *sid, int *final_size, void *header, sound_info *si, int flags);
69 void ds_unload_buffer(int sid);
70 int 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);
71 int ds_get_channel(int sig);
73 void ds_stop_channel(int channel);
74 void ds_stop_channel_all();
75 void ds_set_volume( int channel, float vol );
76 void ds_set_pan( int channel, float pan );
77 int ds_get_pitch(int channel);
78 void ds_set_pitch(int channel, int pitch);
79 void ds_chg_loop_status(int channel, int loop);
80 void ds_set_position(int channel, unsigned int offset);
81 unsigned int ds_get_play_position(int channel);
82 unsigned int ds_get_write_position(int channel);
83 int ds_get_data(int sid, char *data);
84 int ds_get_size(int sid, int *size);
86 int ds_create_buffer(int frequency, int bits_per_sample, int nchannels, int nseconds);
87 int ds_lock_data(int sid, unsigned char *data, int size);
88 int ds_play_easy(int sid, float volume);
89 void ds_stop_easy(int sid);
92 int ds_get_sound_id(int channel);
94 // Returns the number of channels that are actually playing
97 int ds3d_play(int sid, int snd_id, vec3d *pos, vec3d *vel, float min, float max, int looping, float max_volume, float estimated_vol, const EnhancedSoundData * enhanced_sound_data, int priority = DS_MUST_PLAY, bool is_ambient = false);
99 void ds_do_frame();
101 // --------------------
102 //
103 // Creative eax.h
104 //
105 // --------------------
107 // use this structure for get/set all properties...
109 // used for const array of default values
111 {
112  char *name;
113  float flDensity;
114  float flDiffusion;
115  float flGain;
116  float flGainHF;
117  float flGainLF;
118  float flDecayTime;
126  float flLateReverbPan[3];
127  float flEchoTime;
128  float flEchoDepth;
138 typedef struct EFXREVERBPROPERTIES
139 {
141  float flDensity;
142  float flDiffusion;
143  float flGain;
144  float flGainHF;
145  float flGainLF;
146  float flDecayTime;
154  float flLateReverbPan[3];
155  float flEchoTime;
156  float flEchoDepth;
165  {
166  }
172 typedef struct
173 {
174  unsigned int environment; // 0 to EAX_ENVIRONMENT_COUNT-1
175  float fVolume; // 0 to 1
176  float fDecayTime_sec; // seconds, 0.1 to 100
177  float fDamping; // 0 to 1
180 enum
181 {
208  EAX_ENVIRONMENT_COUNT // total number of environments
209 };
214 // prototypes
216 int ds_eax_init();
217 void ds_eax_close();
219 int ds_eax_get_preset_id(const char *name);
220 int ds_eax_get_prop(EFXREVERBPROPERTIES **props, const char *name, const char *template_name = NULL);
222 int ds_eax_set_volume(float volume);
223 int ds_eax_set_decay_time(float seconds);
224 int ds_eax_set_damping(float damp);
225 int ds_eax_set_environment(unsigned long envid);
226 int ds_eax_set_all(unsigned long id, float volume, float damping, float decay);
227 int ds_eax_get_all(EAX_REVERBPROPERTIES *er, int id = -1);
228 int ds_eax_is_inited();
230 #endif /* __DS_H__ */
float flDiffusion
Definition: ds.h:142
int ds_eax_init()
Definition: ds.cpp:2521
#define DS_MUST_PLAY
Definition: ds.h:40
float flDecayLFRatio
Definition: ds.h:148
float flLateReverbPan[3]
Definition: ds.h:126
float flGainLF
Definition: ds.h:145
int ds_eax_set_all(unsigned long id, float volume, float damping, float decay)
Definition: ds.cpp:2348
void ds_stop_easy(int sid)
Definition: ds.cpp:1720
float flReflectionsPan[3]
Definition: ds.h:151
int ds_load_buffer(int *sid, int *final_size, void *header, sound_info *si, int flags)
Load a secondary buffer with sound data.
Definition: ds.cpp:676
int ds_init()
Definition: ds.cpp:1060
int ds_initialized
Definition: ds.cpp:229
Definition: pstypes.h:88
float flDecayTime
Definition: ds.h:146
void ds_stop_channel_all()
Definition: ds.cpp:1914
int bits
Definition: ds.h:56
Definition: cfile.h:28
int ds_eax_get_preset_id(const char *name)
Definition: ds.cpp:2376
float flDecayHFRatio
Definition: ds.h:147
int ds_parse_sound(CFILE *fp, ubyte **dest, uint *dest_size, WAVEFORMATEX **header, bool ogg=false, OggVorbis_File *ovf=NULL)
Parse a wave file.
Definition: ds.cpp:246
int n_block_align
Definition: ds.h:55
int ds_eax_get_prop(EFXREVERBPROPERTIES **props, const char *name, const char *template_name=NULL)
Definition: ds.cpp:2393
float flLateReverbDelay
Definition: ds.h:153
int ds_get_channel_size(int channel)
Definition: ds.cpp:2177
void ds_set_volume(int channel, float vol)
Set the volume for a channel. The volume is expected to be in linear scale.
Definition: ds.cpp:1929
float flEchoDepth
Definition: ds.h:156
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
Definition: vmallocator.h:21
GLsizeiptr size
Definition: Glext.h:5496
float flModulationTime
Definition: ds.h:129
int ds3d_play(int sid, int snd_id, vec3d *pos, vec3d *vel, float min, float max, int looping, float max_volume, float estimated_vol, const EnhancedSoundData *enhanced_sound_data, int priority=DS_MUST_PLAY, bool is_ambient=false)
Definition: ds.cpp:2044
int ds_is_channel_playing(int channel)
Definition: ds.cpp:1888
float flLFReference
Definition: ds.h:161
int ds_parse_sound_info(char *real_filename, sound_info *s_info)
Definition: ds.cpp:457
Definition: ds.cpp:128
int ds_eax_set_volume(float volume)
Definition: ds.cpp:2268
int 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)
Definition: ds.cpp:1794
GLintptr offset
Definition: Glext.h:5497
int ds_eax_set_environment(unsigned long envid)
Definition: ds.cpp:2332
void ds_chg_loop_status(int channel, int loop)
Definition: ds.cpp:2017
float flLateReverbDelay
Definition: ds.h:125
int ds_eax_get_all(EAX_REVERBPROPERTIES *er, int id=-1)
Definition: ds.cpp:2468
float flDecayHFRatio
Definition: ds.h:119
unsigned int uint
Definition: pstypes.h:64
int ds_get_pitch(int channel)
Definition: ds.cpp:1965
float flAirAbsorptionGainHF
Definition: ds.h:131
int ds_eax_is_inited()
Definition: ds.cpp:2598
int sample_rate
Definition: ds.h:53
int ds_get_data(int sid, char *data)
Definition: ds.cpp:2225
int ds_lock_data(int sid, unsigned char *data, int size)
Definition: ds.cpp:1698
void ds_unload_buffer(int sid)
Definition: ds.cpp:1307
void ds_close()
Definition: ds.cpp:1344
int ds_create_buffer(int frequency, int bits_per_sample, int nchannels, int nseconds)
Definition: ds.cpp:1667
int format
Definition: ds.h:50
float flEchoTime
Definition: ds.h:155
struct sound_info sound_info
float flRoomRolloffFactor
Definition: ds.h:162
int ds_play_easy(int sid, float volume)
Definition: ds.cpp:1738
uint size
Definition: ds.h:52
int duration
Definition: ds.h:58
void ds_set_pitch(int channel, int pitch)
Definition: ds.cpp:1990
int ds_get_sound_id(int channel)
Definition: ds.cpp:2639
cfbp fp
Definition: cfile.cpp:1065
float flModulationDepth
Definition: ds.h:158
float flReflectionsPan[3]
Definition: ds.h:123
Definition: ds.h:49
int ds_eax_set_damping(float damp)
Definition: ds.cpp:2310
void ds_set_position(int channel, unsigned int offset)
Definition: ds.cpp:2115
float flDecayLFRatio
Definition: ds.h:120
float flReflectionsDelay
Definition: ds.h:150
unsigned char ubyte
Definition: pstypes.h:62
int iDecayHFLimit
Definition: ds.h:163
unsigned int environment
Definition: ds.h:174
void ds_set_pan(int channel, float pan)
Definition: ds.cpp:1946
GLbitfield flags
Definition: Glext.h:6722
void ds_eax_close()
Definition: ds.cpp:2500
GLuint const GLchar * name
Definition: Glext.h:5608
unsigned int ds_get_write_position(int channel)
Definition: ds.cpp:2169
float fDecayTime_sec
Definition: ds.h:176
int ds_get_number_channels()
Definition: ds.cpp:2202
float flHFReference
Definition: ds.h:160
ubyte * data
Definition: ds.h:59
SCP_string name
Definition: ds.h:140
float flDensity
Definition: ds.h:141
float flReflectionsGain
Definition: ds.h:121
Definition: ds.h:164
Definition: multi.h:385
int n_channels
Definition: ds.h:57
GLenum GLsizei GLenum GLenum const GLvoid * data
Definition: Gl.h:1509
OggVorbis_File ogg_info
Definition: ds.h:51
float flReflectionsGain
Definition: ds.h:149
unsigned int ds_get_play_position(int channel)
Definition: ds.cpp:2127
float flGain
Definition: ds.h:143
hull_check pos
Definition: lua.cpp:5050
float fDamping
Definition: ds.h:177
float flLateReverbPan[3]
Definition: ds.h:154
float flModulationDepth
Definition: ds.h:130
float fVolume
Definition: ds.h:175
float flAirAbsorptionGainHF
Definition: ds.h:159
int ds_get_channel(int sig)
Definition: ds.cpp:1870
float flGainHF
Definition: ds.h:144
int avg_bytes_per_sec
Definition: ds.h:54
float flLateReverbGain
Definition: ds.h:124
float flLateReverbGain
Definition: ds.h:152
int ds_get_size(int sid, int *size)
Definition: ds.cpp:2233
float flRoomRolloffFactor
Definition: ds.h:134
int Ds_sound_quality
Definition: ds.cpp:61
int ds_eax_set_decay_time(float seconds)
Definition: ds.cpp:2289
void ds_stop_channel(int channel)
Definition: ds.cpp:1904
int Ds_float_supported
Definition: ds.cpp:62
void ds_do_frame()
Definition: ds.cpp:2606
float flModulationTime
Definition: ds.h:157
float flReflectionsDelay
Definition: ds.h:122