38 buf_id(0), channel_id(-1), frequency(0), bits_per_sample(0),
39 nchannels(0), nseconds(0), nbytes(0)
45 static int MAX_CHANNELS;
47 static int channel_next_sig = 1;
54 static int Ds_use_eax = 0;
56 static int Ds_eax_inited = 0;
58 static int AL_play_position = 0;
100 {
"Generic", 1.0f, 1.0f, 0.316228f, 0.891251f, 1.0f, 1.49f, 0.83f, 1.0f, 0.050003f, 0.007f, {0.0f, 0.0f, 0.0f}, 1.258925f, 0.011f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
101 {
"Padded cell", 0.171500f, 1.0f, 0.316228f, 0.001f, 1.0f, 0.17f, 0.10f, 1.0f, 0.250035f, 0.001f, {0.0f, 0.0f, 0.0f}, 1.269112f, 0.002f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
102 {
"Room", 0.428687f, 1.0f, 0.316228f, 0.592925f, 1.0f, 0.40f, 0.83f, 1.0f, 0.150314f, 0.002f, {0.0f, 0.0f, 0.0f}, 1.062919f, 0.003f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
103 {
"Bathroom", 0.171500f, 1.0f, 0.316228f, 0.251189f, 1.0f, 1.49f, 0.54f, 1.0f, 0.653131f, 0.007f, {0.0f, 0.0f, 0.0f}, 3.273407f, 0.011f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
104 {
"Living room", 0.976563f, 1.0f, 0.316228f, 0.001f, 1.0f, 0.50f, 0.10f, 1.0f, 0.205116f, 0.003f, {0.0f, 0.0f, 0.0f}, 0.280543f, 0.004f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
105 {
"Stone room", 1.0f, 1.0f, 0.316228f, 0.707946f, 1.0f, 2.31f, 0.64f, 1.0f, 0.441062f, 0.012f, {0.0f, 0.0f, 0.0f}, 1.100272f, 0.017f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
106 {
"Auditorium", 1.0f, 1.0f, 0.316228f, 0.578096f, 1.0f, 4.32f, 0.59f, 1.0f, 0.403181f, 0.02f, {0.0f, 0.0f, 0.0f}, 0.716968f, 0.03f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
107 {
"Concert hall", 1.0f, 1.0f, 0.316228f, 0.562341f, 1.0f, 3.92f, 0.70f, 1.0f, 0.242661f, 0.02f, {0.0f, 0.0f, 0.0f}, 0.997700f, 0.029f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
108 {
"Cave", 1.0f, 1.0f, 0.316228f, 1.0f, 1.0f, 2.91f, 1.30f, 1.0f, 0.500035f, 0.015f, {0.0f, 0.0f, 0.0f}, 0.706318f, 0.022f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 0 },
109 {
"Arena", 1.0f, 1.0f, 0.316228f, 0.447713f, 1.0f, 7.24f, 0.33f, 1.0f, 0.261216f, 0.02f, {0.0f, 0.0f, 0.0f}, 1.018591f, 0.03f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
110 {
"Hangar", 1.0f, 1.0f, 0.316228f, 0.316228f, 1.0f, 10.05f, 0.23f, 1.0f, 0.500035f, 0.02f, {0.0f, 0.0f, 0.0f}, 1.256030f, 0.03f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
111 {
"Carpeted hallway", 0.428687f, 1.0f, 0.316228f, 0.01f, 1.0f, 0.30f, 0.10f, 1.0f, 0.121479f, 0.002f, {0.0f, 0.0f, 0.0f}, 0.153109f, 0.03f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
112 {
"Hallway", 0.364500f, 1.0f, 0.316228f, 0.707946f, 1.0f, 1.49f, 0.59f, 1.0f, 0.245754f, 0.007f, {0.0f, 0.0f, 0.0f}, 1.661499f, 0.011f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
113 {
"Stone corridor", 1.0f, 1.0f, 0.316228f, 0.761202f, 1.0f, 2.70f, 0.79f, 1.0f, 0.247172f, 0.013f, {0.0f, 0.0f, 0.0f}, 1.575796f, 0.02f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
114 {
"Alley", 1.0f, 0.30f, 0.316228f, 0.732825f, 1.0f, 1.49f, 0.86f, 1.0f, 0.250035f, 0.007f, {0.0f, 0.0f, 0.0f}, 0.995405f, 0.011f, {0.0f, 0.0f, 0.0f}, 0.125f, 0.95f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
115 {
"Forest", 1.0f, 0.30f, 0.316228f, 0.022387f, 1.0f, 1.49f, 0.54f, 1.0f, 0.052481f, 0.162f, {0.0f, 0.0f, 0.0f}, 0.768245f, 0.088f, {0.0f, 0.0f, 0.0f}, 0.125f, 1.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
116 {
"City", 1.0f, 0.50f, 0.316228f, 0.398107f, 1.0f, 1.49f, 0.67f, 1.0f, 0.073030f, 0.007f, {0.0f, 0.0f, 0.0f}, 0.142725f, 0.011f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
117 {
"Mountains", 1.0f, 0.27f, 0.316228f, 0.056234f, 1.0f, 1.49f, 0.21f, 1.0f, 0.040738f, 0.30f, {0.0f, 0.0f, 0.0f}, 0.191867f, 0.10f, {0.0f, 0.0f, 0.0f}, 0.25f, 1.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 0 },
118 {
"Quarry", 1.0f, 1.0f, 0.316228f, 0.316228f, 1.0f, 1.49f, 0.83f, 1.0f, 0.0f, 0.061f, {0.0f, 0.0f, 0.0f}, 1.778279f, 0.025f, {0.0f, 0.0f, 0.0f}, 0.125f, 0.70f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
119 {
"Plain", 1.0f, 0.21f, 0.316228f, 0.10f, 1.0f, 1.49f, 0.50f, 1.0f, 0.058479f, 0.179f, {0.0f, 0.0f, 0.0f}, 0.108893f, 0.10f, {0.0f, 0.0f, 0.0f}, 0.25f, 1.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
120 {
"Parking lot", 1.0f, 1.0f, 0.316228f, 1.0f, 1.0f, 1.65f, 1.50f, 1.0f, 0.208209f, 0.008f, {0.0f, 0.0f, 0.0f}, 0.265155f, 0.012f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 0 },
121 {
"Sewer pipe", 0.307063f, 0.80f, 0.316228f, 0.316228f, 1.0f, 2.81f, 0.14f, 1.0f, 1.638702f, 0.014f, {0.0f, 0.0f, 0.0f}, 3.247133f, 0.021f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 0.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
122 {
"Underwater", 0.364500f, 1.0f, 0.316228f, 0.01f, 1.0f, 1.49f, 0.10f, 1.0f, 0.596348f, 0.007f, {0.0f, 0.0f, 0.0f}, 7.079458f, 0.011f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 1.18f, 0.348f, 0.994260f, 5000.0f, 250.0f, 0.0f, 1 },
123 {
"Drugged", 0.428687f, 0.50f, 0.316228f, 1.0f, 1.0f, 8.39f, 1.39f, 1.0f, 0.875992f, 0.002f, {0.0f, 0.0f, 0.0f}, 3.108136f, 0.03f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 0.25f, 1.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 0 },
124 {
"Dizzy", 0.364500f, 0.60f, 0.316228f, 0.630957f, 1.0f, 17.23f, 0.56f, 1.0f, 0.139155f, 0.02f, {0.0f, 0.0f, 0.0f}, 0.493742f, 0.03f, {0.0f, 0.0f, 0.0f}, 0.25f, 1.0f, 0.81f, 0.31f, 0.994260f, 5000.0f, 250.0f, 0.0f, 0 },
125 {
"Psychotic", 0.062500f, 0.50f, 0.316228f, 0.840427f, 1.0f, 7.56f, 0.91f, 1.0f, 0.486407f, 0.02f, {0.0f, 0.0f, 0.0f}, 2.437811f, 0.03f, {0.0f, 0.0f, 0.0f}, 0.25f, 0.0f, 4.00f, 1.0f, 0.994260f, 5000.0f, 250.0f, 0.0f, 0 }
131 typedef ALvoid (AL_APIENTRY * ALGENFILTERS) (ALsizei, ALuint*);
132 typedef ALvoid (AL_APIENTRY * ALDELETEFILTERS) (ALsizei, ALuint*);
134 typedef ALvoid (AL_APIENTRY * ALGENEFFECTS) (ALsizei, ALuint*);
135 typedef ALvoid (AL_APIENTRY * ALDELETEEFFECTS) (ALsizei, ALuint*);
140 typedef ALvoid (AL_APIENTRY * ALGENAUXILIARYEFFECTSLOTS) (ALsizei, ALuint*);
141 typedef ALvoid (AL_APIENTRY * ALDELETEAUXILIARYEFFECTSLOTS) (ALsizei, ALuint*);
142 typedef ALboolean (AL_APIENTRY * ALISAUXILIARYEFFECTSLOT) (ALuint);
176 static ALuint AL_EFX_effect_id = 0;
177 static int Ds_active_env = -1;
180 static void *al_load_function(
const char *func_name)
182 void *
func = alGetProcAddress(func_name);
189 static void al_efx_load_preset(
size_t presetid)
191 if ( !Ds_eax_inited ) {
195 if (presetid >= EFX_presets.size()) {
225 Ds_active_env = presetid;
250 unsigned int tag,
size, next_chunk;
251 bool got_fmt =
false, got_data =
false;
274 if ( ov_streams(ovf) != 1 ) {
275 nprintf((
"Sound",
"SOUND ==> OGG reading error: We don't support bitstream changes!\n" ));
281 (*header)->nChannels = (
ushort)ovf->vi->channels;
282 (*header)->nSamplesPerSec = ovf->vi->rate;
290 (*header)->wBitsPerSample = 16;
294 (*header)->wBitsPerSample = 8;
298 (*header)->nBlockAlign = (
ushort)(((*header)->wBitsPerSample / 8) * ovf->vi->channels);
299 (*header)->nAvgBytesPerSec = ovf->vi->rate * (*header)->nBlockAlign;
303 ogg_int64_t pcm_total_size = ov_pcm_total(ovf, -1);
304 if (pcm_total_size > 0) {
305 *dest_size = (
uint)(pcm_total_size * (*header)->nBlockAlign);
307 nprintf((
"Sound",
"SOUND ==> Size returned for this file is invalid. Please re-encode the file, as it will not work correctly.\n"));
327 if (
cfread( &tag,
sizeof(
uint), 1, fp ) != 1 ) {
333 if (
cfread( &size,
sizeof(
uint), 1, fp ) != 1 ) {
403 memcpy (*header, &PCM_header,
sizeof(PCM_header));
404 (*header)->cbSize = cbExtra;
424 cfread( *dest, size, 1, fp );
437 if (got_fmt && got_data) {
461 bool got_fmt =
false, got_data =
false;
463 int rc, FileSize, FileOffset;
468 if ( (real_filename == NULL) || (s_info == NULL) ) {
473 strcpy_s( filename, real_filename );
474 char *
p = strrchr(filename,
'.');
497 if ( ov_streams(&ovf) != 1 ) {
498 nprintf((
"Sound",
"SOUND ==> OGG reading error: We don't support bitstream changes!\n" ));
542 if (
cfread( &tag,
sizeof(
uint), 1, fp ) != 1 ) {
548 if (
cfread( &size,
sizeof(
uint), 1, fp ) != 1 ) {
629 if (got_fmt && got_data) {
649 for (i = 0; i < sound_buffers.size(); i++) {
650 if (sound_buffers[i].buf_id == 0) {
655 sound_buffers.push_back( new_buffer );
657 return (
int)(sound_buffers.size() - 1);
678 Assert( final_size != NULL );
689 nprintf((
"Sound",
"SOUND ==> No more sound buffers available\n"));
701 int sign, byte_order = 0, section, last_section = -1;
705 ubyte *convert_buffer = NULL;
712 ubyte *mono_buffer =
nullptr;
722 #if BYTE_ORDER == BIG_ENDIAN
743 nprintf((
"Sound",
"SOUND ==> Converting sound from ADPCM to PCM\n" ));
751 if (src_bytes_used != si->
size) {
757 data = convert_buffer;
759 nprintf((
"Sound",
"SOUND ==> Coverted sound from ADPCM to PCM successfully\n" ));
768 #if BYTE_ORDER == BIG_ENDIAN
773 swap_tmp = (
float *)(si->
data +
i);
783 }
else if (bits == 16) {
785 size = si->
size >> 1;
789 if (convert_buffer == NULL) {
793 float *in_p = (
float*)si->
data;
794 short *out_p = (
short*)convert_buffer;
798 for (
int i = 0;
i <
end;
i++) {
799 int i_val = (
int)(in_p[
i] * 32767.0
f + 0.5
f);
800 CLAMP(i_val, -32768, 32767);
802 *out_p++ = (short)i_val;
805 data = convert_buffer;
808 size = si->
size >> 2;
812 if (convert_buffer == NULL) {
816 float *in_p = (
float*)si->
data;
821 for (
int i = 0;
i <
end;
i++) {
822 int i_val = (
int)(in_p[
i] * 127.0
f + 0.5
f) + 128;
823 CLAMP(i_val, 0, 255);
824 *out_p++ = (
ubyte)i_val;
827 data = convert_buffer;
833 nprintf((
"Sound",
"SOUND ==> converting sound from OGG to PCM\n" ));
835 sign = (si->
bits == 8) ? 0 : 1;
836 #if BYTE_ORDER == BIG_ENDIAN
843 if (convert_buffer == NULL) {
847 while (src_bytes_used < si->size) {
850 if (si->
bits == 32) {
851 rc = ov_read_float(&si->
ogg_info, &pcm, 1024, §ion);
853 rc = ov_read(&si->
ogg_info, (
char *) convert_buffer + src_bytes_used, si->
size - src_bytes_used, byte_order, si->
bits / 8, sign, §ion);
857 if ((last_section != -1) && (last_section != section)) {
858 nprintf((
"Sound",
"SOUND ==> OGG reading error: We don't support bitstream changes!\n" ));
861 convert_buffer = NULL;
865 if (rc == OV_EBADLINK) {
868 convert_buffer = NULL;
871 }
else if (rc == 0) {
874 if (si->
bits == 32) {
875 float *out_p = (
float*)(convert_buffer + src_bytes_used);
877 for (
int i = 0;
i < rc;
i++) {
879 *out_p++ = pcm[j][
i];
885 src_bytes_used += rc;
887 last_section = section;
893 size = (
int)src_bytes_used;
895 data = convert_buffer;
900 nprintf((
"Sound",
"SOUND ==> Coverted sound from OGG successfully\n" ));
909 if ( (flags &
DS_3D) && (n_channels > 1) ) {
912 if (mono_buffer == NULL) {
913 if (convert_buffer) {
921 float *in_p = (
float*)data;
922 float *out_p = (
float*)mono_buffer;
926 for (
int i = 0;
i <
end;
i += 2) {
927 float i_val = (in_p[
i] + in_p[
i+1]) * 0.5
f;
931 }
else if (bits == 16) {
932 short *in_p = (
short*)data;
933 short *out_p = (
short*)mono_buffer;
934 int end = size /
sizeof(short);
936 for (
int i = 0;
i <
end;
i += 2) {
937 int i_val = (in_p[
i] + in_p[
i+1]) >> 1;
938 CLAMP(i_val, -32768, 32767);
939 *out_p++ = (short)i_val;
946 for (
int i = 0;
i <
size;
i += 2) {
947 int i_val = (in_p[
i] + in_p[
i+1]) >> 1;
948 CLAMP(i_val, 0, 255);
949 *out_p++ = (
ubyte)i_val;
958 if (convert_buffer) {
960 convert_buffer = NULL;
962 nprintf((
"Sound",
"SOUND ==> Converted 3D sound from stereo to mono\n"));
969 if (format == AL_INVALID_VALUE) {
970 if (convert_buffer) {
982 OpenAL_ErrorCheck( alBufferData(pi, format, data, size, frequency), {
if (convert_buffer)
vm_free(convert_buffer);
return -1; } );
984 sound_buffers[*sid].buf_id = pi;
985 sound_buffers[*sid].channel_id = -1;
986 sound_buffers[*sid].frequency = frequency;
987 sound_buffers[*sid].bits_per_sample =
bits;
988 sound_buffers[*sid].nchannels = n_channels;
989 sound_buffers[*sid].nseconds = size / bps;
990 sound_buffers[*sid].nbytes =
size;
999 if ( convert_buffer ) {
1002 if ( mono_buffer !=
nullptr ) {
1016 Channels =
new channel[MAX_CHANNELS];
1017 }
catch (std::bad_alloc) {
1027 sound_buffers.clear();
1040 const ALchar * renderer = alGetString(AL_RENDERER);
1041 if (renderer == NULL)
1043 mprintf((
"ds_check_for_openal_soft: renderer is null!"));
1046 else if (!
stricmp((
const char *)renderer,
"OpenAL Soft"))
1062 ALfloat list_orien[] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f };
1063 ALCint attrList[] = { ALC_FREQUENCY, 22050, 0 };
1064 unsigned int sample_rate = 22050;
1066 mprintf((
"Initializing OpenAL...\n"));
1073 sample_rate = 48000;
1077 sample_rate = 44100;
1081 sample_rate = 22050;
1086 attrList[1] = sample_rate;
1091 mprintf((
"\n ERROR: Unable to find suitable playback device!\n\n"));
1095 ds_sound_device = alcOpenDevice( (
const ALCchar*) playback_device.c_str() );
1105 mprintf((
" Failed to create context for playback_device (%s) with attrList = { 0x%x, %d, %d } returning error (%s)\n",
1114 mprintf((
" OpenAL Vendor : %s\n", alGetString(AL_VENDOR)));
1115 mprintf((
" OpenAL Renderer : %s\n", alGetString(AL_RENDERER)));
1116 mprintf((
" OpenAL Version : %s\n", alGetString(AL_VERSION)));
1124 alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
1127 if ( alIsExtensionPresent( (
const ALchar*)
"AL_LOKI_play_position" ) == AL_TRUE ) {
1128 mprintf((
" Found extension \"AL_LOKI_play_position\".\n"));
1129 AL_play_position = 1;
1132 if ( alIsExtensionPresent( (
const ALchar*)
"AL_EXT_float32" ) == AL_TRUE ) {
1133 mprintf((
" Found extension \"AL_EXT_float32\".\n"));
1139 if ( alcIsExtensionPresent(
ds_sound_device, (
const ALchar*)
"ALC_EXT_EFX") == AL_TRUE ) {
1140 mprintf((
" Found extension \"ALC_EXT_EFX\".\n"));
1144 if (Ds_use_eax == 1) {
1155 EFX_presets.push_back( EFX_Reverb_Defaults[
i] );
1163 mprintf((
"You are not using OpenAL Soft. Disabling enhanced sound.\n"));
1168 mprintf((
"Enhanced sound is enabled.\n"));
1173 mprintf((
"Enhanced sound is manually disabled.\n"));
1193 mprintf((
" Sample rate: %d (%d)\n", freq, sample_rate));
1197 ALCint major = 0, minor = 0, max_sends = 0;
1203 mprintf((
" EFX version: %d.%d\n", (
int)major, (
int)minor));
1204 mprintf((
" Max auxiliary sends: %d\n", max_sends));
1206 mprintf((
" EFX enabled: NO\n"));
1209 mprintf((
" Playback device: %s\n", playback_device.c_str()));
1210 mprintf((
" Capture device: %s\n", (capture_device.empty()) ?
"<not available>" : capture_device.c_str()));
1212 mprintf((
"... OpenAL successfully initialized!\n"));
1221 alcMakeContextCurrent(NULL);
1233 mprintf((
"... OpenAL failed to initialize!\n"));
1243 if ( (i < 0) || (i >= MAX_CHANNELS) ) {
1247 if ( (Channels[i].source_id != 0) && alIsSource(Channels[i].source_id) ) {
1251 if (Ds_eax_inited) {
1257 if (Channels[i].sid >= 0) {
1258 sound_buffers[Channels[
i].
sid].channel_id = -1;
1262 Channels[
i].
sid = -1;
1263 Channels[
i].
sig = -1;
1270 if ( (i < 0) || (i >= MAX_CHANNELS) ) {
1274 if ( (Channels[i].source_id != 0) && alIsSource(Channels[i].source_id) ) {
1278 if (Ds_eax_inited) {
1282 if (Channels[i].sid >= 0) {
1283 sound_buffers[Channels[
i].
sid].channel_id = -1;
1286 Channels[
i].
sid = -1;
1287 Channels[
i].
sig = -1;
1299 for (i = 0; i < MAX_CHANNELS; i++) {
1309 if ( (sid < 0) || ((
size_t)sid >= sound_buffers.size()) ) {
1313 if (sound_buffers[sid].channel_id >= 0) {
1315 sound_buffers[sid].channel_id = -1;
1318 ALuint buf_id = sound_buffers[sid].buf_id;
1320 if ( (buf_id != 0) && alIsBuffer(buf_id) ) {
1324 sound_buffers[sid].buf_id = 0;
1334 for (i = 0; i < sound_buffers.size(); i++) {
1338 sound_buffers.clear();
1354 alcMakeContextCurrent(NULL);
1382 int i, first_free_channel,
limit = 100;
1384 int lowest_vol_index = -1, lowest_instance_vol_index = -1;
1385 float lowest_vol = 1.0f, lowest_instance_vol = 1.0f;
1390 first_free_channel = -1;
1417 for ( i = 0; i < MAX_CHANNELS; i++ ) {
1422 if (first_free_channel == -1) {
1423 first_free_channel =
i;
1429 if (chp->
sid == -1) {
1430 if (first_free_channel == -1) {
1431 first_free_channel =
i;
1438 if ( (status == AL_INITIAL) || (status == AL_STOPPED) ) {
1441 if (first_free_channel == -1) {
1442 first_free_channel =
i;
1446 if ( chp->
snd_id == snd_id ) {
1449 lowest_instance_vol = chp->
vol;
1450 lowest_instance_vol_index =
i;
1455 lowest_vol_index =
i;
1456 lowest_vol = chp->
vol;
1462 if ( (instance_count >= limit) && (lowest_instance_vol_index >= 0) ) {
1464 if (lowest_instance_vol <= new_volume) {
1466 first_free_channel = lowest_instance_vol_index;
1480 first_free_channel = -1;
1482 }
else if (first_free_channel == -1) {
1485 if ( (lowest_vol_index != -1) && (priority ==
DS_MUST_PLAY) ) {
1488 if ( Channels[lowest_vol_index].vol <= new_volume ) {
1490 first_free_channel = lowest_vol_index;
1495 if ( (first_free_channel >= 0) && (Channels[first_free_channel].source_id == 0) ) {
1496 OpenAL_ErrorCheck( alGenSources(1, &Channels[first_free_channel].source_id),
return -1 );
1498 return first_free_channel;
1516 int i, first_free_channel;
1520 int least_important_index = -1, least_important_instance_index = -1;
1521 float least_important_vol = 1.1f, least_important_instance_vol = 1.1f;
1522 int least_important_priority = -1, least_important_instance_priority = -1;
1527 first_free_channel = -1;
1530 for ( i = 0; i < MAX_CHANNELS; i++ ) {
1535 if (first_free_channel == -1) {
1536 first_free_channel =
i;
1542 if (chp->
sid == -1) {
1543 if (first_free_channel == -1) {
1544 first_free_channel =
i;
1551 if ( (status == AL_INITIAL) || (status == AL_STOPPED) ) {
1554 if (first_free_channel == -1) {
1555 first_free_channel =
i;
1559 if ( chp->
snd_id == snd_id ) {
1565 if (chp->
priority > least_important_instance_priority) {
1566 least_important_instance_vol = chp->
vol;
1567 least_important_instance_priority = chp->
priority;
1568 least_important_instance_index =
i;
1569 }
else if ((chp->
priority == least_important_instance_priority)
1570 && (chp->
vol < least_important_instance_vol)) {
1571 least_important_instance_vol = chp->
vol;
1572 least_important_instance_priority = chp->
priority;
1573 least_important_instance_index =
i;
1578 }
else if ( (chp->
priority > least_important_priority) ) {
1579 least_important_index =
i;
1580 least_important_vol = chp->
vol;
1581 least_important_priority = chp->
priority;
1582 }
else if ( (chp->
priority == least_important_priority) && (chp->
vol < least_important_vol) ) {
1583 least_important_index =
i;
1584 least_important_vol = chp->
vol;
1585 least_important_priority = chp->
priority;
1592 if ( ((
unsigned int)instance_count >= enhanced_limit) && (least_important_instance_index >= 0) ) {
1593 if (least_important_instance_vol <= new_volume) {
1595 first_free_channel =least_important_instance_index;
1598 first_free_channel = -1;
1600 }
else if (first_free_channel == -1) {
1603 if ( (least_important_index != -1)) {
1608 if ( Channels[least_important_index].vol <= new_volume ) {
1610 first_free_channel = least_important_index;
1616 if ( (first_free_channel >= 0) && (Channels[first_free_channel].source_id == 0) ) {
1617 OpenAL_ErrorCheck( alGenSources(1, &Channels[first_free_channel].source_id),
return -1 );
1619 return first_free_channel;
1643 int first_free_channel = -1;
1644 unsigned int enhanced_limit = 0;
1647 enhanced_priority = enhanced_sound_data.
priority;
1648 enhanced_limit = enhanced_sound_data.
limit;
1661 return first_free_channel;
1672 if (!ds_initialized) {
1678 nprintf((
"Sound",
"SOUND ==> No more OpenAL buffers available\n"));
1684 sound_buffers[sid].buf_id =
i;
1685 sound_buffers[sid].channel_id = -1;
1686 sound_buffers[sid].frequency = frequency;
1687 sound_buffers[sid].bits_per_sample = bits_per_sample;
1688 sound_buffers[sid].nchannels = nchannels;
1689 sound_buffers[sid].nseconds = nseconds;
1690 sound_buffers[sid].nbytes = nseconds * (bits_per_sample / 8) * nchannels * frequency;
1700 if ( (sid < 0) || ((
size_t)sid >= sound_buffers.size()) ) {
1706 if (format == AL_INVALID_VALUE) {
1710 sound_buffers[sid].nbytes =
size;
1712 OpenAL_ErrorCheck( alBufferData(sound_buffers[sid].buf_id, format, data, size, sound_buffers[sid].frequency),
return -1 );
1724 int cid = sound_buffers[sid].channel_id;
1727 ALuint source_id = Channels[cid].
source_id;
1740 if (!ds_initialized) {
1755 ALuint source_id = Channels[ch_idx].
source_id;
1759 if (Channels[ch_idx].sid != sid) {
1760 ALuint buffer_id = sound_buffers[sid].buf_id;
1764 Channels[ch_idx].
sid = sid;
1794 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)
1799 if (!ds_initialized) {
1803 ch_idx =
ds_get_free_channel(volume, snd_id, priority, enhanced_priority, *enhanced_sound_data);
1809 if (Channels[ch_idx].source_id == 0) {
1814 OpenAL_ErrorPrint( alSource3f(Channels[ch_idx].source_id, AL_POSITION, pan, 0.0
f, 1.0
f) );
1827 OpenAL_ErrorCheck( alGetSourcei(Channels[ch_idx].source_id, AL_SOURCE_STATE, &status),
return -1 );
1829 if (status == AL_PLAYING) {
1834 OpenAL_ErrorCheck( alSourcei(Channels[ch_idx].source_id, AL_BUFFER, sound_buffers[sid].buf_id),
return -1 );
1836 OpenAL_ErrorPrint( alSourcei(Channels[ch_idx].source_id, AL_SOURCE_RELATIVE, AL_TRUE) );
1838 OpenAL_ErrorPrint( alSourcei(Channels[ch_idx].source_id, AL_LOOPING, (looping) ? AL_TRUE : AL_FALSE) );
1840 if (Ds_eax_inited) {
1846 sound_buffers[sid].channel_id = ch_idx;
1848 Channels[ch_idx].
sid = sid;
1849 Channels[ch_idx].
snd_id = snd_id;
1850 Channels[ch_idx].
sig = channel_next_sig++;
1853 Channels[ch_idx].
vol = volume;
1854 Channels[ch_idx].
looping = looping;
1855 Channels[ch_idx].
priority = enhanced_priority;
1858 if (channel_next_sig < 0) {
1859 channel_next_sig = 1;
1862 return Channels[ch_idx].
sig;
1874 for ( i = 0; i < MAX_CHANNELS; i++ ) {
1875 if ( Channels[i].source_id && (Channels[i].sig == sig) ) {
1890 if ( Channels[channel_id].source_id != 0 ) {
1893 OpenAL_ErrorPrint( alGetSourcei(Channels[channel_id].source_id, AL_SOURCE_STATE, &status) );
1895 return (status == AL_PLAYING);
1906 if ( Channels[channel_id].source_id != 0 ) {
1918 for ( i=0; i<MAX_CHANNELS; i++ ) {
1919 if ( Channels[i].source_id != 0 ) {
1931 if ( (channel_id < 0) || (channel_id >= MAX_CHANNELS) ) {
1935 ALuint source_id = Channels[channel_id].
source_id;
1937 if (source_id != 0) {
1938 CAP(vol, 0.0
f, 1.0
f);
1948 if ( (channel_id < 0) || (channel_id >= MAX_CHANNELS) ) {
1954 OpenAL_ErrorCheck( alGetSourcei(Channels[channel_id].source_id, AL_SOURCE_STATE, &state),
return );
1956 if (state == AL_PLAYING) {
1958 OpenAL_ErrorPrint( alSource3f(Channels[channel_id].source_id, AL_POSITION, pan, 0.0
f, 1.0
f) );
1971 if ( (channel_id < 0) || (channel_id >= MAX_CHANNELS) ) {
1975 OpenAL_ErrorCheck( alGetSourcei(Channels[channel_id].source_id, AL_SOURCE_STATE, &status),
return -1 );
1977 if (status == AL_PLAYING) {
1978 OpenAL_ErrorPrint( alGetSourcef(Channels[channel_id].source_id, AL_PITCH, &alpitch) );
1982 pitch =
fl2i( pow(10.0, (alpitch + 2.0)) );
1994 if ( (channel_id < 0) || (channel_id >= MAX_CHANNELS) ) {
2006 OpenAL_ErrorCheck( alGetSourcei(Channels[channel_id].source_id, AL_SOURCE_STATE, &status),
return );
2008 if (status == AL_PLAYING) {
2009 ALfloat alpitch = log10f((
float)pitch) - 2.0f;
2010 OpenAL_ErrorPrint( alSourcef(Channels[channel_id].source_id, AL_PITCH, alpitch) );
2019 if ( (channel_id < 0) || (channel_id >= MAX_CHANNELS) ) {
2023 ALuint source_id = Channels[channel_id].
source_id;
2025 OpenAL_ErrorPrint( alSourcei(source_id, AL_LOOPING, loop ? AL_TRUE : AL_FALSE) );
2044 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,
bool is_ambient)
2050 if (!ds_initialized) {
2054 channel_id =
ds_get_free_channel(estimated_vol, snd_id, priority, enhanced_priority, *enhanced_sound_data);
2056 if (channel_id < 0) {
2060 if ( Channels[channel_id].source_id == 0 ) {
2070 OpenAL_ErrorPrint( alSourcef(Channels[channel_id].source_id, AL_GAIN, max_volume) );
2073 OpenAL_ErrorCheck( alGetSourcei(Channels[channel_id].source_id, AL_SOURCE_STATE, &status),
return -1 );
2075 if (status == AL_PLAYING) {
2080 OpenAL_ErrorCheck( alSourcei(Channels[channel_id].source_id, AL_BUFFER, sound_buffers[sid].buf_id),
return -1 );
2082 if (Ds_eax_inited) {
2086 OpenAL_ErrorPrint( alSourcei(Channels[channel_id].source_id, AL_SOURCE_RELATIVE, AL_FALSE) );
2088 OpenAL_ErrorPrint( alSourcei(Channels[channel_id].source_id, AL_LOOPING, (looping) ? AL_TRUE : AL_FALSE) );
2093 sound_buffers[sid].channel_id = channel_id;
2095 Channels[channel_id].
sid = sid;
2096 Channels[channel_id].
snd_id = snd_id;
2097 Channels[channel_id].
sig = channel_next_sig++;
2100 Channels[channel_id].
vol = max_volume;
2101 Channels[channel_id].
looping = looping;
2102 Channels[channel_id].
priority = enhanced_priority;
2103 Channels[channel_id].
is_ambient = is_ambient;
2105 if (channel_next_sig < 0 ) {
2106 channel_next_sig = 1;
2109 return Channels[channel_id].
sig;
2117 if ( (channel_id < 0) || (channel_id >= MAX_CHANNELS) ) {
2129 if ( (channel_id < 0) || (channel_id >= MAX_CHANNELS) ) {
2134 int sid = Channels[channel_id].
sid;
2136 if ( (sid < 0) || ((
size_t)sid >= sound_buffers.size()) ) {
2140 if (AL_play_position) {
2145 }
else if ( pos > 0 ) {
2148 ALuint buf_id = sound_buffers[sid].buf_id;
2153 pos = (
ALint)(pos * ((
float)sound_buffers[sid].nbytes / size));
2163 return (
unsigned int)
pos;
2179 if ( (channel_id < 0) || (channel_id >= MAX_CHANNELS) ) {
2183 int sid = Channels[channel_id].
sid;
2185 if ( (sid < 0) || ((
size_t)sid >= sound_buffers.size()) ) {
2189 ALuint buf_id = sound_buffers[sid].buf_id;
2190 ALint data_size = 0;
2192 if ( (buf_id != 0) && alIsBuffer(buf_id)) {
2196 return (
int) data_size;
2206 if (!ds_initialized) {
2211 for ( i = 0; i < MAX_CHANNELS; i++ ) {
2212 if ( Channels[i].source_id ) {
2237 if ( (sid < 0) || ((
size_t)sid >= sound_buffers.size()) ) {
2241 ALuint buf_id = sound_buffers[sid].buf_id;
2242 ALint data_size = 0;
2244 if ( (buf_id != 0) && alIsBuffer(buf_id)) {
2248 *size = (
int) data_size;
2270 if ( !Ds_eax_inited ) {
2274 CAP(volume, 0.0
f, 1.0
f);
2291 if ( !Ds_eax_inited ) {
2295 CAP(seconds, 0.1
f, 20.0
f);
2312 if ( !Ds_eax_inited ) {
2316 CAP(damp, 0.1
f, 2.0
f);
2334 al_efx_load_preset(envid);
2350 if ( !Ds_eax_inited ) {
2361 al_efx_load_preset(
id);
2363 CAP(vol, 0.0
f, 1.0
f);
2364 CAP(decay, 0.1
f, 20.0
f);
2365 CAP(damping, 0.1
f, 2.0
f);
2378 if ( !name || !strlen(name) ) {
2382 size_t count = EFX_presets.size();
2384 for (
size_t i = 0;
i <
count;
i++) {
2385 if ( !
stricmp(name, EFX_presets[
i].name.c_str()) ) {
2397 Assert( strlen(name) > 0 );
2399 int template_id = -1;
2404 *props = &EFX_presets[
id];
2406 id = EFX_presets.size();
2410 if ( (template_name != NULL) && (template_name[0] !=
'\0') ) {
2414 if (template_id >= 0) {
2415 n_prop = EFX_presets[template_id];
2448 EFX_presets.push_back( n_prop );
2450 *props = &EFX_presets[
id];
2453 if ( !
stricmp(name,
"default") ) {
2455 SND_ENV_DEFAULT =
id;
2475 if (Ds_active_env < 0) {
2484 }
else if (
id < (
int)EFX_presets.size()) {
2489 er->
fDamping = EFX_presets[
id].flDecayHFRatio;
2502 if (Ds_eax_inited == 0) {
2509 AL_EFX_effect_id = 0;
2523 if (Ds_eax_inited) {
2528 v_alGenFilters = (ALGENFILTERS) al_load_function(
"alGenFilters");
2530 v_alFilteri = (ALFILTERI) al_load_function(
"alFilteri");
2531 v_alGenEffecs = (ALGENEFFECTS) al_load_function(
"alGenEffects");
2533 v_alEffecti = (ALEFFECTI) al_load_function(
"alEffecti");
2534 v_alEffectf = (ALEFFECTF) al_load_function(
"alEffectf");
2535 v_alEffectfv = (ALEFFECTFV) al_load_function(
"alEffectfv");
2536 v_alGetEffectf = (ALGETEFFECTF) al_load_function(
"alGetEffectf");
2545 }
catch (
const char *err) {
2546 mprintf((
"\n EFX: Unable to load function: %s()\n", err));
2554 if (alGetError() != AL_NO_ERROR) {
2555 mprintf((
"\n EFX: Unable to create Aux effect!\n"));
2561 if (alGetError() != AL_NO_ERROR) {
2562 mprintf((
"\n EFX: Unable to create effect!\n"));
2568 if (alGetError() != AL_NO_ERROR) {
2569 mprintf((
"\n EFX: EAXReverb not supported!\n"));
2575 if (alGetError() != AL_NO_ERROR) {
2576 mprintf((
"\n EFX: Couldn't load effect!\n"));
2584 EFX_presets.push_back( EFX_Reverb_Defaults[
i] );
2600 return Ds_eax_inited;
2608 if (!ds_initialized) {
2615 for (i = 0; i < MAX_CHANNELS; i++) {
2625 if (current_position != 0) {
2626 if (current_position < cp->last_position) {
2641 Assert( channel_id >= 0 );
2643 return Channels[channel_id].
snd_id;
GLenum GLsizei GLenum format
#define vm_malloc_q(size)
int ds_get_free_channel(float volume, int snd_id, int priority, int &enhanced_priority, const EnhancedSoundData &enhanced_sound_data)
ALGETEFFECTF v_alGetEffectf
uint os_config_read_uint(const char *section, const char *name, uint default_value)
#define AL_EFFECTSLOT_NULL
#define OpenAL_ErrorCheck(x, y)
#define ALC_EFX_MINOR_VERSION
int ds_eax_set_environment(unsigned long envid)
#define WAVE_FORMAT_ADPCM
unsigned int ds_get_play_position(int channel_id)
float flReflectionsPan[3]
int ds_eax_set_volume(float volume)
#define AL_EAXREVERB_ECHO_TIME
#define AL_EAXREVERB_DECAY_HFRATIO
const char * audio_ext_list[]
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)
int cfread(void *buf, int elsize, int nelem, CFILE *fp)
#define AL_EAXREVERB_GAINLF
void ds_set_pan(int channel_id, float pan)
int Cmdline_no_enhanced_sound
void ds_set_pitch(int channel_id, int pitch)
void ds_stop_channel_all()
int ds_load_buffer(int *sid, int *final_size, void *header, sound_info *si, int flags)
Load a secondary buffer with sound data.
#define AL_EAXREVERB_GAIN
ALAUXILIARYEFFECTSLOTI v_alAuxiliaryEffectSloti
int ds_eax_get_all(EAX_REVERBPROPERTIES *er, int id)
#define AL_EAXREVERB_REFLECTIONS_GAIN
#define OpenAL_ErrorPrint(x)
unsigned int ds_get_write_position(int channel_id)
#define AL_AUXILIARY_SEND_FILTER
int ds_eax_get_preset_id(const char *name)
int cf_find_file_location_ext(const char *filename, const int ext_num, const char **ext_list, int pathtype, int max_out=0, char *pack_filename=NULL, int *size=NULL, int *offset=NULL, bool localize=false)
ALuint *typedef ALuint *typedef ALenum
#define AL_EAXREVERB_LATE_REVERB_DELAY
int ds_eax_set_decay_time(float seconds)
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
ALAUXILIARYEFFECTSLOTF v_alAuxiliaryEffectSlotf
unsigned int last_position
#define cfopen_special(...)
#define AL_EAXREVERB_DECAY_TIME
#define AL_EAXREVERB_DECAY_LFRATIO
#define CLAMP(x, min, max)
int ds3d_update_buffer(int channel_id, float min, float max, vec3d *pos, vec3d *vel)
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
int ds_create_buffer(int frequency, int bits_per_sample, int nchannels, int nseconds)
#define AL_EAXREVERB_LATE_REVERB_PAN
int ds_get_channel(int sig)
float flAirAbsorptionGainHF
ALuint *typedef ALuint *typedef ALint
ALDELETEEFFECTS v_alDeleteEffects
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
ALDELETEFILTERS v_alDeleteFilters
#define AL_EAXREVERB_MODULATION_DEPTH
ALGENAUXILIARYEFFECTSLOTS v_alGenAuxiliaryEffectSlots
ALGENEFFECTS v_alGenEffecs
#define AL_EAXREVERB_AIR_ABSORPTION_GAINHF
int ACM_convert_ADPCM_to_PCM(WAVEFORMATEX *pwfxSrc, ubyte *src, int src_len, ubyte **dest, int max_dest_bytes, int *dest_len, unsigned int *src_bytes_used, int dest_bps)
float flRoomRolloffFactor
ALDELETEAUXILIARYEFFECTSLOTS v_alDeleteAuxiliaryEffectSlots
int ds_get_size(int sid, int *size)
bool ds_check_for_openal_soft()
int ds_get_data(int sid, char *data)
#define AL_EFFECT_EAXREVERB
#define AL_EFFECTSLOT_EFFECT
float flReflectionsPan[3]
#define AL_EAXREVERB_LATE_REVERB_GAIN
int ds_get_pitch(int channel_id)
int ds_play_easy(int sid, float volume)
int ds_eax_set_damping(float damp)
ALfloat *typedef ALfloat *typedef ALuint *typedef ALuint *typedef ALboolean(AL_APIENTRY *ALISAUXILIARYEFFECTSLOT)(ALuint)
int ds_get_channel_size(int channel_id)
#define AL_EAXREVERB_HFREFERENCE
void _cdecl void void _cdecl Error(const char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
unsigned int SND_ENV_DEFAULT
int ds_get_number_channels()
GLuint const GLchar * name
void ds_close_channel_fast(int i)
ov_callbacks cfile_callbacks
struct sound_buffer sound_buffer
void ds_chg_loop_status(int channel_id, int loop)
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
#define AL_EAXREVERB_REFLECTIONS_PAN
void CAP(T &v, T mn, T mx)
#define AL_EAXREVERB_LFREFERENCE
ALuint *typedef ALvoid(AL_APIENTRY *ALDELETEFILTERS)(ALsizei
SCP_vector< sound_buffer > sound_buffers
int ds_eax_get_prop(EFXREVERBPROPERTIES **props, const char *name, const char *template_name)
const unsigned int SND_ENHANCED_MAX_LIMIT
ALenum openal_get_format(ALint bits, ALint n_channels)
#define AL_EAXREVERB_REFLECTIONS_DELAY
void ds_close_all_channels()
int ds_get_free_channel_retail(float new_volume, int snd_id, int priority)
ALCdevice * ds_sound_device
SCP_vector< EFXREVERBPROPERTIES > EFX_presets
int ds_get_free_channel_enhanced(float new_volume, int snd_id, int enhanced_priority, unsigned int enhanced_limit)
bool openal_init_device(SCP_string *playback, SCP_string *capture)
GLenum GLsizei GLenum GLenum const GLvoid * data
int ds_eax_set_all(unsigned long id, float vol, float damping, float decay)
#define ALC_MAX_AUXILIARY_SENDS
int ds_parse_sound_info(char *real_filename, sound_info *s_info)
#define AL_EAXREVERB_DENSITY
ushort cfread_ushort(CFILE *file, int ver, ushort deflt)
#define AL_EAXREVERB_DECAY_HFLIMIT
#define AL_EAXREVERB_ECHO_DEPTH
int ds_get_sound_id(int channel_id)
void ds_stop_channel(int channel_id)
ALISAUXILIARYEFFECTSLOT v_alIsAuxiliaryEffectSlot
void ds_stop_easy(int sid)
#define AL_EAXREVERB_GAINHF
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, bool is_ambient)
int ds_parse_sound(CFILE *fp, ubyte **dest, uint *dest_size, WAVEFORMATEX **header, bool ogg, OggVorbis_File *ovf)
Parse a wave file.
#define AL_EAXREVERB_ROOM_ROLLOFF_FACTOR
float flAirAbsorptionGainHF
void ds_close_channel(int i)
ALfloat *ALGENFILTERS v_alGenFilters
ALAUXILIARYEFFECTSLOTFV v_alAuxiliaryEffectSlotfv
const char * openal_error_string(int get_alc)
#define ALC_EFX_MAJOR_VERSION
void ds_unload_buffer(int sid)
int cfclose(CFILE *cfile)
int ds_lock_data(int sid, unsigned char *data, int size)
void ds_set_volume(int channel_id, float vol)
Set the volume for a channel. The volume is expected to be in linear scale.
ALAUXILIARYEFFECTSLOTIV v_alAuxiliaryEffectSlotiv
float flRoomRolloffFactor
int ds_is_channel_playing(int channel_id)
void ds_set_position(int channel_id, unsigned int offset)
#define AL_EAXREVERB_MODULATION_TIME
ALCcontext * ds_sound_context
uint cfread_uint(CFILE *file, int ver, uint deflt)
#define AL_EAXREVERB_DIFFUSION
#define WAVE_FORMAT_IEEE_FLOAT
int cfseek(CFILE *fp, int offset, int where)
#define OGG_FORMAT_VORBIS