Remove unused sound lib files

This commit is contained in:
Louis Gombert 2024-06-23 16:36:43 +02:00
parent 5d413b9f30
commit ca079d8dd5
6 changed files with 0 additions and 5016 deletions

View File

@ -1,244 +0,0 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
--- HISTORICAL COMMENTS FOLLOW ---
* $Source: $
* $Revision: 8 $
* $Author: Jeff $
* $Date: 10/21/99 9:28p $
*
* Hardware occlusion and reflection sound support
*
* $Log: /DescentIII/Main/dd_sndlib/geometry.cpp $
*
* 8 10/21/99 9:28p Jeff
* B.A. Macintosh code merge
*
* 7 8/13/99 2:00p Samir
* more aureal and geometry fixes.
*
* 6 8/11/99 3:12p Samir
* fixes for aureal support.
*
* 5 4/13/99 4:09p Samir
* more priority stuff.
*
* 4 4/06/99 8:30p Samir
* added reflection support.
*
* 3 3/30/99 5:36p Matt
* Fixed compile warnings
*
* 2 3/29/99 10:52a Samir
* occlusion support almost complete.
*
*/
#include "ds3dlib_internal.h"
#include "auddev.h"
#include "pserror.h"
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
llsGeometry::llsGeometry() {
m_snd_system = NULL;
m_snd_mixer = SOUND_MIXER_NONE;
m_lib_init = false;
}
// specify a sound library to associate geometry with
bool llsGeometry::Init(llsSystem *snd_sys) {
int i;
if (m_lib_init) {
Int3(); // really, this shouldn't happen.
return true;
}
if (!snd_sys) {
Int3();
return false;
}
if (!m_lib_init) {
mprintf(0, "DDSNDGEO: Failed to initialize geometry interface.\n");
return false;
}
m_snd_mixer = snd_sys->GetSoundMixer();
m_snd_system = snd_sys;
m_lib_init = true;
// create material list.
for (i = 0; i < SNDGEO_MATERIAL_COUNT; i++) {
m_snd_materials[i] = NULL;
}
CreateMaterial(SNDGEO_MATERIAL_ROCK, 0.2f, 0.5f, 0.9f, 0.8f);
CreateMaterial(SNDGEO_MATERIAL_WATER, 1.0f, 0.3f, 0.8f, 0.7f);
CreateMaterial(SNDGEO_MATERIAL_METAL, 0.1f, 0.1f, 0.95f, 0.85f);
mprintf(0, "DDSNDGEO: Initialized.\n");
return true;
}
// closes low level geometry system.
void llsGeometry::Shutdown() {
int i;
if (!m_lib_init) { // damn this shouldn't happen.
Int3();
return;
}
// destroy materials list
for (i = 0; i < SNDGEO_MATERIAL_COUNT; i++) {
DestroyMaterial(i);
}
m_snd_mixer = SOUND_MIXER_NONE;
m_snd_system = NULL;
m_lib_init = false;
mprintf(0, "DDSNDGEO: Shutdown.\n");
}
void llsGeometry::StartFrame() {
n_primatives_used = 0;
n_reflections_used = 0;
n_materials_used = 0;
}
void llsGeometry::EndFrame() {
mprintf_at(3, 4, 20, "sndpoly=%04d", n_primatives_used);
mprintf_at(3, 4, 38, "sndmat=%04d", n_materials_used);
mprintf_at(3, 5, 20, "sndref=%04d", n_reflections_used);
}
// polygon lists
// marks beginning of a list of polygons to render
// -1 group if non cached (user doesn't want to reuse this.
void llsGeometry::StartPolygonGroup(int group) {
ASSERT(m_lib_init);
}
// ends a list of polygons to render.
void llsGeometry::EndPolygonGroup(int group) {
ASSERT(m_lib_init);
}
// renders a group.
void llsGeometry::RenderGroup(int group) {
ASSERT(m_lib_init);
}
void llsGeometry::Clear() {
ASSERT(m_lib_init);
}
// primatives
// 4 verts here.
void llsGeometry::AddQuad(unsigned tag, vector **verts) {
n_primatives_used++;
}
// 3 verts here.
void llsGeometry::AddTriangle(unsigned tag, vector **verts) {
n_primatives_used++;
}
void llsGeometry::AddPoly(int nv, vector **verts, unsigned tag, tSoundMaterial material) {
int i, saved_primatives_used; //,p;
void *matp = NULL;
if (nv < 3) {
Int3();
return;
}
if (material >= 0 && material < SNDGEO_MATERIAL_COUNT) {
matp = m_snd_materials[material];
}
if (matp) {
n_materials_used++;
}
saved_primatives_used = n_primatives_used;
// add polygons or split.
switch (nv) {
case 3:
AddTriangle(tag, verts);
break;
case 4:
AddQuad(tag, verts);
break;
default:
Int3();
}
if (matp) {
n_reflections_used += (n_primatives_used - saved_primatives_used);
}
}
// values MUST be from 0 to 1 for gain and highfreq.
void llsGeometry::CreateMaterial(tSoundMaterial material, float transmit_gain, float transmit_highfreq,
float reflect_gain, float reflect_highfreq) {
if (m_snd_materials[material] || material < 0 || material >= SNDGEO_MATERIAL_COUNT) {
Int3(); // get samir, trying to intiialize a material in an existing slot.
return;
}
// check values.
if (transmit_gain < 0) {
transmit_gain = 0;
} else if (transmit_gain > 1) {
transmit_gain = 1;
}
if (transmit_highfreq < 0) {
transmit_highfreq = 0;
} else if (transmit_highfreq > 1) {
transmit_highfreq = 1;
}
if (reflect_gain < 0) {
reflect_gain = 0;
} else if (reflect_gain > 1) {
reflect_gain = 1;
}
if (reflect_highfreq < 0) {
reflect_highfreq = 0;
} else if (reflect_highfreq > 1) {
reflect_highfreq = 1;
}
}
void llsGeometry::DestroyMaterial(tSoundMaterial material) {
if (!m_snd_materials[material]) {
if (material < 0 || material >= SNDGEO_MATERIAL_COUNT) {
Int3(); // get samir, trying to destroy a material in an nonexisting slot.
}
return;
}
if (m_snd_materials[material]) {
m_snd_materials[material] = NULL;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,616 +0,0 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
--- HISTORICAL COMMENTS FOLLOW ---
* $Source: $
* $Revision: 6 $
* $Author: Samir $
* $Date: 5/03/99 3:12a $
*
* Direct Sound subsystem.
*
* $Log: /DescentIII/Main/dd_sndlib/dsound3d.cpp $
*
* 6 5/03/99 3:12a Samir
* fixed up aureal so it works (a little slow though...)
*
* 5 4/29/99 3:01p Samir
* added code for direct sound mixers only (and function for Aureal
* really) that will use direct sound looping for simple loops.
*
* 4 4/25/99 9:53p Samir
* added debugging.
*
* 3 4/23/99 7:51p Samir
* looping fixes for directsound.
*
* 2 4/22/99 10:33p Samir
* modifications so that DirectSound mixers use one thread for all looping
* and streaming sounds. It worked without crashing for about twenty
* minutes of playing from level 1 to level 2 of D3. We'll see.
*
* 1 4/22/99 10:30p Samir
* initial revision ( a bit messy)
*
*/
#include "ds3dlib_internal.h"
#include "auddev.h"
#include "pserror.h"
#include <process.h>
static struct t_sb_loop_thread_data {
win_llsSystem *m_ll_sndsys;
uintptr_t thread_handle;
int16_t no_callbacks;
bool request_kill;
bool thread_alive;
} m_ds;
static uint8_t m_sb_cur_timeslice;
////////////////////////////////////////////////////////////////////////////////
// DSLOOP_STREAM_METHOD
inline void sb_loop_thread_clean_buffer(sound_buffer_info *sb) {
m_ds.m_ll_sndsys->GetSoundPos(sb->m_unique_id);
sb_stop_buffer(sb);
sb->s->playing = 0;
sb->s->kill_me = true;
// TODO: investigate why this is -1 sometimes, 32bit builds seem to work by
// chance while 64bit builds crash without this ckeck
if (sb->m_sound_index < 0) {
return;
}
if (SoundFiles[Sounds[sb->m_sound_index].sample_index].use_count > 0) {
SoundFiles[Sounds[sb->m_sound_index].sample_index].use_count--;
// DUPSND if (SoundFiles[Sounds[sb->m_sound_index].sample_index].use_count == 0) {
// Global_DS_alloced_sounds--;
// DUPSND }
}
}
// helper functions for loop streaming.
void sb_loop_stream_copy(sound_buffer_info *sb, char *ptr, DWORD len) {
DWORD amt;
bool f_looping = (sb->m_status & SSF_PLAY_LOOPING) != 0;
char *sample_ptr;
if (f_looping) {
const int sound_index = sb->m_sound_index;
int loop_start = Sounds[sound_index].loop_start;
int loop_end = Sounds[sound_index].loop_end;
if (sb->s->f_sample_16bit) {
loop_start = loop_start << 1;
loop_end = loop_end << 1;
sample_ptr = (char *)SoundFiles[Sounds[sound_index].sample_index].sample_16bit;
} else {
sample_ptr = (char *)SoundFiles[Sounds[sound_index].sample_index].sample_8bit;
}
while (sb->s->num_written + (int)len >= loop_end) {
int num_till_loop_end = loop_end - sb->s->num_written;
int num_to_loop_start = sb->s->num_written - loop_start;
if (num_till_loop_end > 0) {
memcpy(ptr, sb->s->current_position, num_till_loop_end);
len -= num_till_loop_end;
}
ptr += num_till_loop_end;
sb->s->current_position = sample_ptr + loop_start;
// ASSERT(sb->s->current_position >= sample_ptr && sample_ptr == sb->sample_data);
sb->s->num_written -= num_to_loop_start;
sb->s->bytes_left += num_to_loop_start;
// ASSERT(sb->s->num_written == loop_start);
}
}
amt = (len > sb->s->bytes_left) ? sb->s->bytes_left : len;
// int i_amt = (int)amt;
// ASSERT(i_amt >= 0);
if (amt) {
memcpy(ptr, sb->s->current_position, amt);
sb->s->current_position += amt;
sb->s->bytes_left -= amt;
sb->s->num_written += amt;
// ASSERT(sb->s->current_position >= sb->sample_data);
}
len -= amt;
if (len) {
memset(ptr + amt, sb->s->silence_byte, len);
sb->s->close_on_next = 1;
}
}
// helper functions for loop streaming.
void sb_loop_stream_fillhalf(sound_buffer_info *sb, DWORD half) {
char *ptr1 = NULL;
char *ptr2 = NULL;
uint32_t len1, len2;
if (sb_lock_buffer(sb, half, sb->s->half_buffer_point, (void **)&ptr1, &len1, (void **)&ptr2, &len2)) {
// memset(ptr1, sb->s->silence_byte, len1);
sb_loop_stream_copy(sb, ptr1, len1);
if (ptr2) {
sb_loop_stream_copy(sb, ptr2, len2);
}
sb_unlock_buffer(sb, ptr1, len1, ptr2, len2);
}
}
// helper functions for streaming
void sb_stream_copy(sound_buffer_info *sb, char *ptr, DWORD len) {
DWORD amt;
new_data:
amt = (len > sb->s->bytes_left) ? sb->s->bytes_left : len;
ASSERT(amt >= 0);
if (amt) {
ASSERT(sb->s->current_position);
memcpy(ptr, sb->s->current_position, amt);
sb->s->current_position += amt;
sb->s->bytes_left -= amt;
}
len -= amt;
if (len) {
if (sb->play_info->m_stream_cback && sb->s->current_position) {
memset(ptr + amt, sb->s->silence_byte, len);
int new_len = sb->play_info->m_stream_size;
sb->s->current_position =
(char *)(*sb->play_info->m_stream_cback)(sb->play_info->user_data, sb->play_info->m_stream_handle, &new_len);
sb->play_info->m_stream_data = sb->s->current_position;
ASSERT(!(sb->play_info->m_stream_data && sb->play_info->m_stream_size <= 0));
sb->s->bytes_left = sb->play_info->m_stream_size;
if (sb->s->current_position == NULL) {
sb->s->bytes_left = sb->play_info->m_stream_size = 0;
}
goto new_data;
}
memset(ptr + amt, sb->s->silence_byte, len);
sb->s->close_on_next = 1;
}
}
void sb_stream_fillhalf(sound_buffer_info *sb, DWORD half) {
char *ptr1 = NULL;
char *ptr2 = NULL;
uint32_t len1, len2;
if (sb_lock_buffer(sb, half, sb->s->half_buffer_point, (void **)&ptr1, &len1, (void **)&ptr2, &len2)) {
sb_stream_copy(sb, ptr1, len1);
if (ptr2) {
sb_stream_copy(sb, ptr2, len2);
}
sb_unlock_buffer(sb, ptr1, len1, ptr2, len2);
}
}
// main looping thread.
void __cdecl sb_loop_thread(void *user_ptr) {
sound_buffer_cache *sndcache;
DWORD playp, writep, whichhalf;
int i;
uint8_t iteration;
// validate thread
m_ds.m_ll_sndsys = (win_llsSystem *)user_ptr;
m_ds.thread_alive = true;
sndcache = &m_ds.m_ll_sndsys->m_sound_mixer;
iteration = 0;
mprintf(0, "DS3DLIB: Looping thread begins.\n");
// main thread body
while (!m_ds.request_kill) {
if (m_ds.no_callbacks++ == 0) {
for (i = 0; i < sndcache->m_max_sounds_played; i++) {
sound_buffer_info *sb = &sndcache->m_sound_cache[i];
// skip unused slots and only handle looping (maybe streaming) slots.
if ((sb->m_status == SSF_UNUSED) || (sb->m_status & SSF_BUFFERED_LOOP) || !sb->s) {
continue;
}
if (!sb->s->playing) { // loops before calling play do have SSF_PLAY_LOOPING set, and MUST!!
continue;
}
// at this point it's definitely either a streaming buffer or loop streaming buffer
if (sb->m_status & SSF_PLAY_STREAMING) {
// streams will stop at the request of the application always, unlike looping buffers (see below)
if (sb->s->please_close) {
sb_loop_thread_clean_buffer(sb);
// mprintf(0, "ds thread pleas_close request processed.\n");
} else if (sb->m_status & SSF_PAUSED) {
continue; // just continue
} else if ((iteration % 4) == (sb->s->time_slice % 4)) {
// update streamed buffer only when allowed
playp = sb_get_current_position(sb, (uint32_t *)&writep);
whichhalf = (playp < sb->s->half_buffer_point) ? 0 : sb->s->half_buffer_point;
if (whichhalf != sb->s->last_half) {
if (sb->s->close_on_next) {
sb_loop_thread_clean_buffer(sb);
} else {
sb_stream_fillhalf(sb, sb->s->last_half);
sb->s->last_half = whichhalf;
}
}
// mprintf(0, "ds thread stream update.\n");
}
} else if (!(sb->m_status & SSF_BUFFERED_LOOP)) {
// this slot is a looping slot. check to see if app requested closing this loop.
// also we don't check the looping flag because we could be playing the end part of a loop
// and the stream filling code below will set close_on_next when done itself.
if (sb->s->please_close) {
sb_loop_thread_clean_buffer(sb);
} else if (sb->m_status & SSF_PAUSED) {
continue; // just continue
} else if ((iteration % 4) == (sb->s->time_slice % 4)) {
// update looped buffer only when allowed
playp = sb_get_current_position(sb, (uint32_t *)&writep);
whichhalf = (playp < sb->s->half_buffer_point) ? 0 : sb->s->half_buffer_point;
if (whichhalf != sb->s->last_half) {
if (sb->s->close_on_next) {
sb_loop_thread_clean_buffer(sb);
} else {
sb_loop_stream_fillhalf(sb, sb->s->last_half);
sb->s->last_half = whichhalf;
}
}
}
}
}
iteration++;
}
m_ds.no_callbacks--;
Sleep(DSPB_TICK_MILLISECONDS); // defer to OS
}
// invalidate thread
m_ds.thread_alive = false;
m_ds.m_ll_sndsys = NULL;
mprintf(0, "DS3DLIB: Looping thread done.\n");
}
///////////////////////////////////////////////////////////////////////////////
// this will initialize the looping thread
bool sb_loop_thread_init(win_llsSystem *lls) {
// start looping thread
m_sb_cur_timeslice = 0;
m_ds.request_kill = false;
m_ds.thread_alive = false;
m_ds.no_callbacks = 1;
m_ds.thread_handle = _beginthread(sb_loop_thread, 16384, (void *)lls);
if (m_ds.thread_handle == -1) {
return false;
}
if (!SetThreadPriority((HANDLE)m_ds.thread_handle, THREAD_PRIORITY_TIME_CRITICAL)) {
return false;
}
m_ds.no_callbacks = 0;
return true;
}
void sb_loop_thread_kill() {
if (m_ds.thread_alive) {
mprintf(0, "DS3DLIB: Killing looping thread.\n");
m_ds.request_kill = true;
while (m_ds.thread_alive) {
Sleep(DSPB_TICK_MILLISECONDS);
}
}
}
// a lot of looping info will be initialized here, including copying data, etc.
bool sb_loop_element_init(sound_buffer_info *sb, char *sample_ptr, int sound_length, int buffer_size) {
// finish initting loop
if (!sb->s) {
Int3();
return false;
}
sb->s->time_slice = m_sb_cur_timeslice; // allocate timeslice for updating.
sb->s->half_buffer_point = buffer_size / 2;
sb->s->current_position = sample_ptr;
sb->s->bytes_left = sound_length;
sb->s->silence_byte = (sb->s->f_sample_16bit) ? 0 : 128;
sb_loop_stream_fillhalf(sb, 0);
sb_loop_stream_fillhalf(sb, sb->s->half_buffer_point);
sb->s->close_on_next = 0;
sb->s->kill_me = false;
m_ds.m_ll_sndsys->SetSoundPos(sb->m_unique_id, sb->play_info->m_samples_played);
m_sb_cur_timeslice++;
return true;
}
void sb_loop_element_kill(sound_buffer_info *sb) { sb->s->please_close = 1; }
void sb_loop_element_wait_until_dead(sound_buffer_info *sb) {
if (!sb->s)
return;
while (!sb->s->kill_me) {
}
}
// initialize streaming audio.
bool sb_stream_element_init(sound_buffer_info *sb, char *sample_ptr, int sound_length, int buffer_size) {
// finish initting loop
if (!sb->s) {
Int3();
return false;
}
sb->s->time_slice = m_sb_cur_timeslice; // allocate timeslice for updating.
sb->s->half_buffer_point = buffer_size / 2;
sb->s->current_position = sample_ptr;
sb->s->bytes_left = sound_length;
sb->s->silence_byte = (sb->s->f_sample_16bit) ? 0 : 128;
sb_stream_fillhalf(sb, 0);
sb_stream_fillhalf(sb, sb->s->half_buffer_point);
sb->s->close_on_next = 0;
sb->s->kill_me = false;
if (sb->m_status & SSF_BUFFERED_STRM) {
sb->s->hEvent = NULL;
/* sb->s->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (sb->m_mixer_type == SOUND_MIXER_AUREAL) {
if (!A3D_SetSourceWaveEvent(sb->m_snd_obj, sb->s->half_buffer_point, sb->s->hEvent)) {
CloseHandle(sb->s->hEvent);
sb->s->hEvent = NULL;
return false;
}
}
else {
Int3();
// unimplemented for normal DirectSound CloseHandle(sb->s->hEvent); sb->s->hEvent = NULL;
}
*/
}
m_sb_cur_timeslice++;
return true;
}
// these work on buffered streams only
void sb_stream_element_kill(sound_buffer_info *sb) {
if (sb->m_status & SSF_BUFFERED_STRM) {
if (sb->s->hEvent) {
CloseHandle(sb->s->hEvent);
sb->s->hEvent = NULL;
}
}
}
void sb_stream_buffered_update(sound_buffer_info *sb) {
DWORD playp, writep, whichhalf;
ASSERT((sb->m_status & SSF_BUFFERED_STRM));
playp = sb_get_current_position(sb, (uint32_t *)&writep);
whichhalf = (playp < sb->s->half_buffer_point) ? 0 : sb->s->half_buffer_point;
if (whichhalf != sb->s->last_half) {
// mprintf(0, "DSOUND3D: event triggered. Updating stream half %d.\n", sb->s->last_half);
if (sb->s->close_on_next) {
extern win_llsSystem *ll_sound_ptr;
ll_sound_ptr->StopSound(sb->m_unique_id);
} else {
sb_stream_fillhalf(sb, sb->s->last_half);
sb->s->last_half = whichhalf;
}
}
/* if (WaitForSingleObject(sb->s->hEvent, 0) == WAIT_OBJECT_0) {
// event was signaled by DirectSound/Aureal. do appropriate stream fill.
if (sb->s->close_on_next) {
extern win_llsSystem *ll_sound_ptr;
ll_sound_ptr->StopSound(sb->m_unique_id);
}
else {
mprintf(0, "DSOUND3D: event triggered. Updating stream half %d.\n", sb->s->last_half);
A3D_ClearSourceWaveEvents(sb->m_snd_obj);
sb_stream_fillhalf(sb, sb->s->last_half);
sb->s->last_half = (sb->s->last_half) ? 0 : sb->s->half_buffer_point;
ResetEvent(sb->s->hEvent);
if (sb->m_mixer_type == SOUND_MIXER_AUREAL) {
A3D_SetSourceWaveEvent(sb->m_snd_obj, sb->s->last_half, sb->s->hEvent);
}
else {
Int3();
}
}
}
*/
}
////////////////////////////////////////////////////////////////////////////////
// DSLOOP_BUFFER_METHOD
char *sb_get_loop_info(const sound_buffer_info *sb, int *loop_start, int *loop_end, bool *is_16_bit) {
int sound_index = sb->m_sound_index;
if (sound_index > -1) {
*loop_start = Sounds[sound_index].loop_start;
*loop_end = Sounds[sound_index].loop_end;
if (SoundFiles[Sounds[sound_index].sample_index].sample_16bit) {
*is_16_bit = true;
return (char *)SoundFiles[Sounds[sound_index].sample_index].sample_16bit;
}
if (SoundFiles[Sounds[sound_index].sample_index].sample_8bit) {
*is_16_bit = false;
return (char *)SoundFiles[Sounds[sound_index].sample_index].sample_8bit;
}
}
Int3();
return NULL;
}
char *sb_get_loop_step_info(const sound_buffer_info *sb, int step, bool is16bit, int *length) {
sound_file_info *sf;
char *sample_ptr;
if (sb->m_sound_index < 0) {
Int3();
return NULL;
}
int loop_start_byte = Sounds[sb->m_sound_index].loop_start;
int loop_end_byte = Sounds[sb->m_sound_index].loop_end;
if (is16bit) {
loop_start_byte = loop_start_byte << 1;
loop_end_byte = loop_end_byte << 1;
}
sf = &SoundFiles[Sounds[sb->m_sound_index].sample_index];
sample_ptr = is16bit ? (char *)sf->sample_16bit : (char *)sf->sample_8bit;
if (step == DSBUFLOOP_INIT_STEP) {
*length = loop_start_byte;
return sample_ptr;
}
if (step == DSBUFLOOP_LOOP_STEP) {
*length = (loop_end_byte - loop_start_byte);
return (sample_ptr + loop_start_byte);
}
if (step == DSBUFLOOP_FINISH_STEP) {
int sample_length_byte = is16bit ? (sf->np_sample_length * 2) : sf->np_sample_length;
*length = (sample_length_byte - loop_end_byte);
return (sample_ptr + loop_end_byte);
}
Int3(); // illegal step!!
*length = 0;
return NULL;
}
// steps to next state of buffered loop.
// force_next_step = -2, do it automatically, otherwise set 'next_step' using passed value.
// this will stop and free the current ds object
// advance to next valid step (may skip a step)
// if new step is > 1, then we're done.
// else create and play the new one if we can.
// before destroying old object, we must get the current sound properties depending on buffer type.
// and set them for the new sound object.
// we will call either direct sound or custom mixer functions.
// yuck.
void sb_buffered_loop_step(win_llsSystem *lls, sound_buffer_info *sb, int force_next_step) {
if (!sb->s)
return;
if (!(sb->m_status & SSF_BUFFERED_LOOP))
return;
tPSBInfo psb;
char *sample_ptr;
int sound_length;
pos_state old_pos_state;
float old_pan;
float old_volume = 0.0f;
ASSERT(lls->m_mixer_type != SOUND_MIXER_SOFTWARE_16 && lls->m_mixer_type != SOUND_MIXER_NONE);
// get current properties.
old_pan = 0;
// advance to next step.
sound_length = 0;
sb->s->loop_step = (force_next_step == -2) ? (sb->s->loop_step + 1) : force_next_step;
while (!sound_length && sb->s->loop_step < 2) {
sample_ptr = sb_get_loop_step_info(sb, sb->s->loop_step, sb->s->f_sample_16bit, &sound_length);
sb->s->loop_step++;
}
if (!sound_length && sb->s->loop_step == 2) {
// mprintf(0, "DS3DLIB: Buffered loop %d advancing to post-end step (done)\n", sb->m_unique_id);
lls->StopSound(sb->m_unique_id);
return;
} else {
sb_stop_buffer(sb);
sb_free_buffer(sb);
}
sb->s->loop_step--; // return to proper step.
sb->s->loop_timer = 0.0f;
sb->s->bytes_left = sound_length;
sb->m_status = SSF_PLAY_LOOPING | SSF_BUFFERED_LOOP;
sb->sample_data = sample_ptr;
// allocate buffer for playback
if (!lls->CreateSoundBuffer(sb, false, sb->s->bytes_left, true)) {
return;
}
if (!sb_load_buffer(sb, sb->sample_data, sound_length)) {
return;
}
// using old sound properties, play the next buffer with those qualities!
psb.looping = (sb->s->loop_step == 0) ? true : false;
if (sb->m_buffer_type == SBT_3D) {
psb.cur_pos = &old_pos_state;
} else {
psb.pan = old_pan;
}
psb.volume = old_volume;
psb.freq = 22050;
lls->PlaySoundBuffer(sb, &psb);
// must be at end to initiate thread management.
sb->s->playing = 1;
// mprintf(0, "DDSNDLIB: Buffered loop %d advancing to step %d.\n", sb->m_unique_id, sb->s->loop_step);
}

View File

@ -1,335 +0,0 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
--- HISTORICAL COMMENTS FOLLOW ---
* $Source: $
* $Revision: 10 $
* $Author: Samir $
* $Date: 9/27/99 5:38p $
*
*
*
* $Log: /DescentIII/Main/dd_sndlib/eax.cpp $
*
* 10 9/27/99 5:38p Samir
* EAX 2.0->1.0 compatibility checkin.
*
* 9 8/24/99 3:42p Samir
* load EAX dynamically
*
* 8 8/24/99 1:47p Samir
* updated header file.
*
* 7 8/23/99 5:29p Samir
* incremental EAX 2.0 checkin
*
* 6 1/11/99 5:54p Samir
* made environment a hangar.
*
* 5 1/11/99 5:52p Samir
* updated EAX support.
*
* 4 1/08/99 6:31p Samir
* added reverb
*
* 3 12/23/98 11:50a Samir
*
* 2 12/23/98 11:48a Samir
* basic functionality.
*
* 1 12/21/98 7:06p Samir
* Creative Labs EAX
*
*/
#include "auddev.h"
#include <objbase.h>
#include <initguid.h>
#include "eax.h"
#include "eax2.h"
#include "pserror.h"
// DATA
#define EAX_ENVIRONMENTS_AVAILABLE (1 << 0)
#define VOICE_MANAGMENT_AVAILABLE (1 << 1)
struct {
HINSTANCE m_dll;
LPDIRECTSOUND m_lpds;
LPDIRECTSOUNDBUFFER m_lpdsb;
LPKSPROPERTYSET m_lpksps;
DWORD m_dwSoundProperties;
VmMode m_vmode;
EAX_REVERBPROPERTIES m_preset;
} EAX = {NULL, NULL, 0, 0, 0};
const EAX_REVERBPROPERTIES EAX_Environments[EAX_ENVIRONMENT_COUNT] = {
{EAX_PRESET_GENERIC}, {EAX_PRESET_PADDEDCELL}, {EAX_PRESET_ROOM}, {EAX_PRESET_BATHROOM},
{EAX_PRESET_LIVINGROOM}, {EAX_PRESET_STONEROOM}, {EAX_PRESET_AUDITORIUM}, {EAX_PRESET_CONCERTHALL},
{EAX_PRESET_CAVE}, {EAX_PRESET_ARENA}, {EAX_PRESET_HANGAR}, {EAX_PRESET_CARPETEDHALLWAY},
{EAX_PRESET_HALLWAY}, {EAX_PRESET_STONECORRIDOR}, {EAX_PRESET_ALLEY}, {EAX_PRESET_FOREST},
{EAX_PRESET_CITY}, {EAX_PRESET_MOUNTAINS}, {EAX_PRESET_QUARRY}, {EAX_PRESET_PLAIN},
{EAX_PRESET_PARKINGLOT}, {EAX_PRESET_SEWERPIPE}, {EAX_PRESET_UNDERWATER}, {EAX_PRESET_DRUGGED},
{EAX_PRESET_DIZZY}, {EAX_PRESET_PSYCHOTIC}};
// FUNCTIONS
HRESULT(FAR PASCAL *DLLEAXDirectSoundCreate)(GUID *, LPDIRECTSOUND *, IUnknown FAR *) = NULL;
// EAX 1.0 support.
bool EAX_SetEnvironmentPreset(unsigned environment);
bool EAX_SetEnvironmentalReverb(float volume, float damping, float decay);
// CODE
bool EAX_Create(GUID *pGuid, LPDIRECTSOUND *lpds) {
HRESULT hr;
EAX.m_dll = LoadLibrary("eax.dll");
if (EAX.m_dll) {
DLLEAXDirectSoundCreate = (LPEAXDIRECTSOUNDCREATE)GetProcAddress(EAX.m_dll, "EAXDirectSoundCreate");
if (!DLLEAXDirectSoundCreate) {
Error("EAX DLL doesn't contain latest code for 2.0 functionality.");
return false;
}
mprintf(0, "EAX 2.0 support detected.\n");
hr = (*DLLEAXDirectSoundCreate)(pGuid, &EAX.m_lpds, NULL);
} else {
mprintf(0, "EAX 1.0 support detected.\n");
hr = DirectSoundCreate(pGuid, &EAX.m_lpds, NULL);
}
if (hr != DS_OK) {
*lpds = NULL;
return false;
}
EAX.m_lpdsb = NULL;
EAX.m_dwSoundProperties = 0;
*lpds = EAX.m_lpds;
return true;
}
void EAX_Destroy() {
if (EAX.m_lpds) {
if (EAX.m_lpksps != NULL) {
EAX.m_lpksps->Release();
EAX.m_lpksps = NULL;
}
if (EAX.m_lpdsb) {
EAX.m_lpdsb->Release();
EAX.m_lpdsb = NULL;
}
EAX.m_lpds->Release();
EAX.m_lpds = NULL;
}
if (EAX.m_dll) {
FreeLibrary(EAX.m_dll);
EAX.m_dll = NULL;
DLLEAXDirectSoundCreate = NULL;
}
EAX.m_dwSoundProperties = 0;
}
// returns EAX caps
int EAX_Caps() { return EAX.m_dwSoundProperties; }
// initializes EAX specific interfaces.
bool EAX_SetPrimaryBuffer() {
HRESULT hr;
DWORD support;
bool retval = true;
WAVEFORMATEX wave;
DSBUFFERDESC dsbdesc;
EAX_REVERBPROPERTIES props = {EAX_PRESET_HANGAR};
ASSERT(EAX.m_lpds);
memset(&wave, 0, sizeof(WAVEFORMATEX));
wave.wFormatTag = WAVE_FORMAT_PCM;
wave.nChannels = 2;
wave.nSamplesPerSec = 22050;
wave.wBitsPerSample = 16;
wave.nBlockAlign = wave.wBitsPerSample / 8 * wave.nChannels;
wave.nAvgBytesPerSec = wave.nSamplesPerSec * wave.nBlockAlign;
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_STATIC | DSBCAPS_CTRL3D;
dsbdesc.dwBufferBytes = DSBSIZE_MIN * 2;
dsbdesc.lpwfxFormat = &wave;
if (FAILED(EAX.m_lpds->CreateSoundBuffer(&dsbdesc, &EAX.m_lpdsb, NULL))) {
return false;
}
if (EAX.m_lpksps == NULL) {
if (FAILED(EAX.m_lpdsb->QueryInterface(IID_IKsPropertySet, (LPVOID *)&EAX.m_lpksps))) {
mprintf(0, "EAX: Error failed to query property set interface.\n");
Int3();
retval = false;
goto error_sub;
}
}
// now, query support depending on EAX 2.0 availability
if (EAX.m_dll) {
hr = EAX.m_lpksps->QuerySupport(DSPROPSETID_EAX_ListenerProperties, DSPROPERTY_EAXLISTENER_ENVIRONMENT, &support);
if (SUCCEEDED(hr)) {
if ((support & (KSPROPERTY_SUPPORT_SET | KSPROPERTY_SUPPORT_GET)) ==
(KSPROPERTY_SUPPORT_SET | KSPROPERTY_SUPPORT_GET)) {
EAX.m_dwSoundProperties |= EAX_ENVIRONMENTS_AVAILABLE;
}
}
hr = EAX.m_lpksps->QuerySupport(DSPROPSETID_EAX_BufferProperties, DSPROPERTY_EAXBUFFER_OBSTRUCTION, &support);
if (SUCCEEDED(hr)) {
if ((support & (KSPROPERTY_SUPPORT_SET | KSPROPERTY_SUPPORT_GET)) ==
(KSPROPERTY_SUPPORT_SET | KSPROPERTY_SUPPORT_GET)) {
EAX.m_dwSoundProperties |= EAXF_SOURCE_OBSTRUCTION;
}
}
} else {
hr = EAX.m_lpksps->QuerySupport(DSPROPSETID_EAX_ReverbProperties, DSPROPERTY_EAX_ALL, &support);
if (SUCCEEDED(hr)) {
if ((support & KSPROPERTY_SUPPORT_SET | KSPROPERTY_SUPPORT_GET) ==
(KSPROPERTY_SUPPORT_SET | KSPROPERTY_SUPPORT_GET)) {
EAX.m_dwSoundProperties |= EAX_ENVIRONMENTS_AVAILABLE;
/*
Here the reverb environment is initialized to off.
*/
EAX_SetEnvironmentPreset(EAX_ENVIRONMENT_HANGAR);
}
}
}
retval = (EAX.m_dwSoundProperties & EAX_ENVIRONMENTS_AVAILABLE) ? true : false;
EAX_SetEnvironmentalReverb(props.fVolume, props.fDamping, props.fDecayTime_sec);
error_sub:
if (retval == false) {
mprintf(0, "EAX: Error failed to query environmental support.\n");
Int3();
if (EAX.m_lpksps) {
EAX.m_lpksps->Release();
EAX.m_lpksps = NULL;
}
}
return retval;
}
/*
This routine can be used to change the current EAX preset environment. The environment applies
to all 3D buffers.
*/
// sets up current global environment reverb
bool EAX_SetEnvironmentalReverb(float volume, float damping, float decay) {
if (EAX.m_dwSoundProperties & EAX_ENVIRONMENTS_AVAILABLE) {
int i;
EAX.m_preset.environment = EAX_ENVIRONMENT_GENERIC;
EAX.m_preset.fVolume = volume;
EAX.m_preset.fDecayTime_sec = decay;
EAX.m_preset.fDamping = damping;
if (EAX.m_dll) {
for (i = 0; i < EAX_ENVIRONMENT_COUNT; i++) {
if (volume == EAX_Environments[i].fVolume && damping == EAX_Environments[i].fDamping &&
decay == EAX_Environments[i].fDecayTime_sec) {
EAX.m_preset.environment = (uint32_t)i;
break;
}
}
if (FAILED(EAX.m_lpksps->Set(DSPROPSETID_EAX_ListenerProperties, DSPROPERTY_EAXLISTENER_ENVIRONMENT, NULL, 0,
&EAX.m_preset.environment, sizeof(uint32_t)))) {
return false;
}
} else {
if (FAILED(EAX.m_lpksps->Set(DSPROPSETID_EAX_ReverbProperties, DSPROPERTY_EAX_VOLUME, NULL, 0,
&EAX.m_preset.fVolume, sizeof(float)))) {
return false;
}
if (FAILED(EAX.m_lpksps->Set(DSPROPSETID_EAX_ReverbProperties, DSPROPERTY_EAX_DECAYTIME, NULL, 0,
&EAX.m_preset.fDecayTime_sec, sizeof(float)))) {
return false;
}
if (FAILED(EAX.m_lpksps->Set(DSPROPSETID_EAX_ReverbProperties, DSPROPERTY_EAX_DAMPING, NULL, 0,
&EAX.m_preset.fDamping, sizeof(float)))) {
return false;
}
}
return true;
}
return false;
}
// intializes a sound source for EAX
bool EAX_InitSource(LPDIRECTSOUND3DBUFFER lpBuffer3D, LPKSPROPERTYSET *plpksp) {
if (!lpBuffer3D)
return true;
if (SUCCEEDED(lpBuffer3D->QueryInterface(IID_IKsPropertySet, (void **)plpksp))) {
return true;
}
return false;
}
// frees an eax sound source
void EAX_FreeSource(LPKSPROPERTYSET lpksp) {
if (lpksp) {
lpksp->Release();
}
}
// sets source properties
void EAX_SetSourceProperties(LPKSPROPERTYSET lpksp, float obstruction) {
if (!lpksp)
return;
if (EAX.m_dwSoundProperties & EAXF_SOURCE_OBSTRUCTION) {
LONG lValue = (DWORD)(-10000 * obstruction);
lpksp->Set(DSPROPSETID_EAX_BufferProperties, DSPROPERTY_EAXBUFFER_OBSTRUCTION, NULL, 0, &lValue, sizeof(LONG));
}
}
/*
This routine can be used to change the current EAX preset environment. The environment applies
to all 3D buffers.
*/
// sets up current global environment reverb
bool EAX_SetEnvironmentPreset(unsigned environment) {
EAX.m_preset.environment = environment;
if (FAILED(EAX.m_lpksps->Set(DSPROPSETID_EAX_ReverbProperties, DSPROPERTY_EAX_ENVIRONMENT, NULL, 0,
&EAX.m_preset.environment, sizeof(float)))) {
return false;
}
return true;
}

View File

@ -1,105 +0,0 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// EAX.H -- DirectSound Environmental Audio Extensions
#ifndef EAX_H_INCLUDED
#define EAX_H_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// EAX (listener) reverb property set {4a4e6fc1-c341-11d1-b73a-444553540000}
DEFINE_GUID(DSPROPSETID_EAX_ReverbProperties, 0x4a4e6fc1, 0xc341, 0x11d1, 0xb7, 0x3a, 0x44, 0x45, 0x53, 0x54, 0x00,
0x00);
enum DSPROPERTY_EAX_REVERBPROPERTY {
DSPROPERTY_EAX_ALL, // all reverb properties
DSPROPERTY_EAX_ENVIRONMENT, // standard environment no.
DSPROPERTY_EAX_VOLUME, // loudness of the reverb
DSPROPERTY_EAX_DECAYTIME, // how long the reverb lasts
DSPROPERTY_EAX_DAMPING // the high frequencies decay faster
};
#define EAX_NUM_STANDARD_PROPERTIES (DSPROPERTY_EAX_DAMPING + 1)
// use this structure for get/set all properties...
struct EAX_REVERBPROPERTIES {
uint32_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
};
// #define EAX_MAX_ENVIRONMENT (EAX_ENVIRONMENT_COUNT - 1)
// presets
#define EAX_PRESET_GENERIC EAX_ENVIRONMENT_GENERIC, 0.5F, 1.493F, 0.5F
#define EAX_PRESET_PADDEDCELL EAX_ENVIRONMENT_PADDEDCELL, 0.25F, 0.1F, 0.0F
#define EAX_PRESET_ROOM EAX_ENVIRONMENT_ROOM, 0.417F, 0.4F, 0.666F
#define EAX_PRESET_BATHROOM EAX_ENVIRONMENT_BATHROOM, 0.653F, 1.499F, 0.166F
#define EAX_PRESET_LIVINGROOM EAX_ENVIRONMENT_LIVINGROOM, 0.208F, 0.478F, 0.0F
#define EAX_PRESET_STONEROOM EAX_ENVIRONMENT_STONEROOM, 0.5F, 2.309F, 0.888F
#define EAX_PRESET_AUDITORIUM EAX_ENVIRONMENT_AUDITORIUM, 0.403F, 4.279F, 0.5F
#define EAX_PRESET_CONCERTHALL EAX_ENVIRONMENT_CONCERTHALL, 0.5F, 3.961F, 0.5F
#define EAX_PRESET_CAVE EAX_ENVIRONMENT_CAVE, 0.5F, 2.886F, 1.304F
#define EAX_PRESET_ARENA EAX_ENVIRONMENT_ARENA, 0.361F, 7.284F, 0.332F
#define EAX_PRESET_HANGAR EAX_ENVIRONMENT_HANGAR, 0.5F, 10.0F, 0.3F
#define EAX_PRESET_CARPETEDHALLWAY EAX_ENVIRONMENT_CARPETEDHALLWAY, 0.153F, 0.259F, 2.0F
#define EAX_PRESET_HALLWAY EAX_ENVIRONMENT_HALLWAY, 0.361F, 1.493F, 0.0F
#define EAX_PRESET_STONECORRIDOR EAX_ENVIRONMENT_STONECORRIDOR, 0.444F, 2.697F, 0.638F
#define EAX_PRESET_ALLEY EAX_ENVIRONMENT_ALLEY, 0.25F, 1.752F, 0.776F
#define EAX_PRESET_FOREST EAX_ENVIRONMENT_FOREST, 0.111F, 3.145F, 0.472F
#define EAX_PRESET_CITY EAX_ENVIRONMENT_CITY, 0.111F, 2.767F, 0.224F
#define EAX_PRESET_MOUNTAINS EAX_ENVIRONMENT_MOUNTAINS, 0.194F, 7.841F, 0.472F
#define EAX_PRESET_QUARRY EAX_ENVIRONMENT_QUARRY, 1.0F, 1.499F, 0.5F
#define EAX_PRESET_PLAIN EAX_ENVIRONMENT_PLAIN, 0.097F, 2.767F, 0.224F
#define EAX_PRESET_PARKINGLOT EAX_ENVIRONMENT_PARKINGLOT, 0.208F, 1.652F, 1.5F
#define EAX_PRESET_SEWERPIPE EAX_ENVIRONMENT_SEWERPIPE, 0.652F, 2.886F, 0.25F
#define EAX_PRESET_UNDERWATER EAX_ENVIRONMENT_UNDERWATER, 1.0F, 1.499F, 0.0F
#define EAX_PRESET_DRUGGED EAX_ENVIRONMENT_DRUGGED, 0.875F, 8.392F, 1.388F
#define EAX_PRESET_DIZZY EAX_ENVIRONMENT_DIZZY, 0.139F, 17.234F, 0.666F
#define EAX_PRESET_PSYCHOTIC EAX_ENVIRONMENT_PSYCHOTIC, 0.486F, 7.563F, 0.806F
// EAX buffer reverb property set {4a4e6fc0-c341-11d1-b73a-444553540000}
DEFINE_GUID(DSPROPSETID_EAXBUFFER_ReverbProperties, 0x4a4e6fc0, 0xc341, 0x11d1, 0xb7, 0x3a, 0x44, 0x45, 0x53, 0x54,
0x00, 0x00);
enum DSPROPERTY_EAXBUFFER_REVERBPROPERTY {
DSPROPERTY_EAXBUFFER_ALL, // all reverb buffer properties
DSPROPERTY_EAXBUFFER_REVERBMIX // the wet source amount
};
// use this structure for get/set all properties...
struct EAXBUFFER_REVERBPROPERTIES {
float fMix; // linear factor, 0.0F to 1.0F
};
#define EAX_REVERBMIX_USEDISTANCE \
-1.0F // out of normal range
// signifies the reverb engine should
// calculate it's own reverb mix value
// based on distance
#ifdef __cplusplus
}
#endif // __cplusplus
#endif

View File

@ -1,404 +0,0 @@
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/******************************************************************
*
* EAX.H - DirectSound3D Environmental Audio Extensions version 2.0
* Updated June 18, 1999
*
*******************************************************************
*/
#ifndef EAX2_H_INCLUDED
#define EAX2_H_INCLUDED
#include <dsound.h>
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#pragma pack(push, 4)
/*
EAX Wrapper Interface
*/
// {4FF53B81-1CE0-11d3-AAB8-00A0C95949D5}
DEFINE_GUID(CLSID_EAXDirectSound, 0x4ff53b81, 0x1ce0, 0x11d3, 0xaa, 0xb8, 0x0, 0xa0, 0xc9, 0x59, 0x49, 0xd5);
__declspec(dllimport) HRESULT WINAPI EAXDirectSoundCreate(GUID *, LPDIRECTSOUND *, IUnknown FAR *);
typedef HRESULT(FAR PASCAL *LPEAXDIRECTSOUNDCREATE)(GUID *, LPDIRECTSOUND *, IUnknown FAR *);
/*
* EAX 2.0 listener property set {0306A6A8-B224-11d2-99E5-0000E8D8C722}
*/
DEFINE_GUID(DSPROPSETID_EAX20_ListenerProperties, 0x306a6a8, 0xb224, 0x11d2, 0x99, 0xe5, 0x0, 0x0, 0xe8, 0xd8, 0xc7,
0x22);
// For compatibility with future EAX versions:
#define DSPROPSETID_EAX_ListenerProperties DSPROPSETID_EAX20_ListenerProperties
enum DSPROPERTY_EAX_LISTENERPROPERTY {
DSPROPERTY_EAXLISTENER_NONE,
DSPROPERTY_EAXLISTENER_ALLPARAMETERS,
DSPROPERTY_EAXLISTENER_ROOM,
DSPROPERTY_EAXLISTENER_ROOMHF,
DSPROPERTY_EAXLISTENER_ROOMROLLOFFFACTOR,
DSPROPERTY_EAXLISTENER_DECAYTIME,
DSPROPERTY_EAXLISTENER_DECAYHFRATIO,
DSPROPERTY_EAXLISTENER_REFLECTIONS,
DSPROPERTY_EAXLISTENER_REFLECTIONSDELAY,
DSPROPERTY_EAXLISTENER_REVERB,
DSPROPERTY_EAXLISTENER_REVERBDELAY,
DSPROPERTY_EAXLISTENER_ENVIRONMENT,
DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE,
DSPROPERTY_EAXLISTENER_ENVIRONMENTDIFFUSION,
DSPROPERTY_EAXLISTENER_AIRABSORPTIONHF,
DSPROPERTY_EAXLISTENER_FLAGS
};
// OR these flags with property id
#define DSPROPERTY_EAXLISTENER_IMMEDIATE 0x00000000 // changes take effect immediately
#define DSPROPERTY_EAXLISTENER_DEFERRED 0x80000000 // changes take effect later
#define DSPROPERTY_EAXLISTENER_COMMITDEFERREDSETTINGS (DSPROPERTY_EAXLISTENER_NONE | DSPROPERTY_EAXLISTENER_IMMEDIATE)
// Use this structure for DSPROPERTY_EAXLISTENER_ALLPARAMETERS
// - all levels are hundredths of decibels
// - all times are in seconds
// - the reference for high frequency controls is 5 kHz
//
// NOTE: This structure may change in future EAX versions.
// It is recommended to initialize fields by name:
// myListener.lRoom = -1000;
// myListener.lRoomHF = -100;
// ...
// myListener.dwFlags = myFlags /* see EAXLISTENERFLAGS below */ ;
// instead of:
// myListener = { -1000, -100, ... , 0x00000009 };
// If you want to save and load presets in binary form, you
// should define your own structure to insure future compatibility.
//
struct EAXLISTENERPROPERTIES {
LONG lRoom; // room effect level at low frequencies
LONG lRoomHF; // room effect high-frequency level re. low frequency level
FLOAT flRoomRolloffFactor; // like DS3D flRolloffFactor but for room effect
FLOAT flDecayTime; // reverberation decay time at low frequencies
FLOAT flDecayHFRatio; // high-frequency to low-frequency decay time ratio
LONG lReflections; // early reflections level relative to room effect
FLOAT flReflectionsDelay; // initial reflection delay time
LONG lReverb; // late reverberation level relative to room effect
FLOAT flReverbDelay; // late reverberation delay time relative to initial reflection
DWORD dwEnvironment; // sets all listener properties
FLOAT flEnvironmentSize; // environment size in meters
FLOAT flEnvironmentDiffusion; // environment diffusion
FLOAT flAirAbsorptionHF; // change in level per meter at 5 kHz
DWORD dwFlags; // modifies the behavior of properties
};
// used by DSPROPERTY_EAXLISTENER_ENVIRONMENT
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
};
// Used by DSPROPERTY_EAXLISTENER_FLAGS
//
// Note: The number and order of flags may change in future EAX versions.
// It is recommended to use the flag defines as follows:
// myFlags = EAXLISTENERFLAGS_DECAYTIMESCALE | EAXLISTENERFLAGS_REVERBSCALE;
// instead of:
// myFlags = 0x00000009;
//
// These flags determine what properties are affected by environment size.
#define EAXLISTENERFLAGS_DECAYTIMESCALE 0x00000001 // reverberation decay time
#define EAXLISTENERFLAGS_REFLECTIONSSCALE 0x00000002 // reflection level
#define EAXLISTENERFLAGS_REFLECTIONSDELAYSCALE 0x00000004 // initial reflection delay time
#define EAXLISTENERFLAGS_REVERBSCALE 0x00000008 // reflections level
#define EAXLISTENERFLAGS_REVERBDELAYSCALE 0x00000010 // late reverberation delay time
// This flag limits high-frequency decay time according to air absorption.
#define EAXLISTENERFLAGS_DECAYHFLIMIT 0x00000020
#define EAXLISTENERFLAGS_RESERVED 0xFFFFFFC0 // reserved future use
// property ranges and defaults:
#define EAXLISTENER_MINROOM -10000
#define EAXLISTENER_MAXROOM 0
#define EAXLISTENER_DEFAULTROOM -1000
#define EAXLISTENER_MINROOMHF -10000
#define EAXLISTENER_MAXROOMHF 0
#define EAXLISTENER_DEFAULTROOMHF -100
#define EAXLISTENER_MINROOMROLLOFFFACTOR 0.0f
#define EAXLISTENER_MAXROOMROLLOFFFACTOR 10.0f
#define EAXLISTENER_DEFAULTROOMROLLOFFFACTOR 0.0f
#define EAXLISTENER_MINDECAYTIME 0.1f
#define EAXLISTENER_MAXDECAYTIME 20.0f
#define EAXLISTENER_DEFAULTDECAYTIME 1.49f
#define EAXLISTENER_MINDECAYHFRATIO 0.1f
#define EAXLISTENER_MAXDECAYHFRATIO 2.0f
#define EAXLISTENER_DEFAULTDECAYHFRATIO 0.83f
#define EAXLISTENER_MINREFLECTIONS -10000
#define EAXLISTENER_MAXREFLECTIONS 1000
#define EAXLISTENER_DEFAULTREFLECTIONS -2602
#define EAXLISTENER_MINREFLECTIONSDELAY 0.0f
#define EAXLISTENER_MAXREFLECTIONSDELAY 0.3f
#define EAXLISTENER_DEFAULTREFLECTIONSDELAY 0.007f
#define EAXLISTENER_MINREVERB -10000
#define EAXLISTENER_MAXREVERB 2000
#define EAXLISTENER_DEFAULTREVERB 200
#define EAXLISTENER_MINREVERBDELAY 0.0f
#define EAXLISTENER_MAXREVERBDELAY 0.1f
#define EAXLISTENER_DEFAULTREVERBDELAY 0.011f
#define EAXLISTENER_MINENVIRONMENT 0
#define EAXLISTENER_MAXENVIRONMENT (EAX_ENVIRONMENT_COUNT - 1)
#define EAXLISTENER_DEFAULTENVIRONMENT EAX_ENVIRONMENT_GENERIC
#define EAXLISTENER_MINENVIRONMENTSIZE 1.0f
#define EAXLISTENER_MAXENVIRONMENTSIZE 100.0f
#define EAXLISTENER_DEFAULTENVIRONMENTSIZE 7.5f
#define EAXLISTENER_MINENVIRONMENTDIFFUSION 0.0f
#define EAXLISTENER_MAXENVIRONMENTDIFFUSION 1.0f
#define EAXLISTENER_DEFAULTENVIRONMENTDIFFUSION 1.0f
#define EAXLISTENER_MINAIRABSORPTIONHF -100.0f
#define EAXLISTENER_MAXAIRABSORPTIONHF 0.0f
#define EAXLISTENER_DEFAULTAIRABSORPTIONHF -5.0f
#define EAXLISTENER_DEFAULTFLAGS \
(EAXLISTENERFLAGS_DECAYTIMESCALE | EAXLISTENERFLAGS_REFLECTIONSSCALE | EAXLISTENERFLAGS_REFLECTIONSDELAYSCALE | \
EAXLISTENERFLAGS_REVERBSCALE | EAXLISTENERFLAGS_REVERBDELAYSCALE | EAXLISTENERFLAGS_DECAYHFLIMIT)
/*
* EAX 2.0 buffer property set {0306A6A7-B224-11d2-99E5-0000E8D8C722}
*/
DEFINE_GUID(DSPROPSETID_EAX20_BufferProperties, 0x306a6a7, 0xb224, 0x11d2, 0x99, 0xe5, 0x0, 0x0, 0xe8, 0xd8, 0xc7,
0x22);
// For compatibility with future EAX versions:
#define DSPROPSETID_EAX_BufferProperties DSPROPSETID_EAX20_BufferProperties
enum DSPROPERTY_EAX_BUFFERPROPERTY {
DSPROPERTY_EAXBUFFER_NONE,
DSPROPERTY_EAXBUFFER_ALLPARAMETERS,
DSPROPERTY_EAXBUFFER_DIRECT,
DSPROPERTY_EAXBUFFER_DIRECTHF,
DSPROPERTY_EAXBUFFER_ROOM,
DSPROPERTY_EAXBUFFER_ROOMHF,
DSPROPERTY_EAXBUFFER_ROOMROLLOFFFACTOR,
DSPROPERTY_EAXBUFFER_OBSTRUCTION,
DSPROPERTY_EAXBUFFER_OBSTRUCTIONLFRATIO,
DSPROPERTY_EAXBUFFER_OCCLUSION,
DSPROPERTY_EAXBUFFER_OCCLUSIONLFRATIO,
DSPROPERTY_EAXBUFFER_OCCLUSIONROOMRATIO,
DSPROPERTY_EAXBUFFER_OUTSIDEVOLUMEHF,
DSPROPERTY_EAXBUFFER_AIRABSORPTIONFACTOR,
DSPROPERTY_EAXBUFFER_FLAGS
};
// OR these flags with property id
#define DSPROPERTY_EAXBUFFER_IMMEDIATE 0x00000000 // changes take effect immediately
#define DSPROPERTY_EAXBUFFER_DEFERRED 0x80000000 // changes take effect later
#define DSPROPERTY_EAXBUFFER_COMMITDEFERREDSETTINGS (DSPROPERTY_EAXBUFFER_NONE | DSPROPERTY_EAXBUFFER_IMMEDIATE)
// Use this structure for DSPROPERTY_EAXBUFFER_ALLPARAMETERS
// - all levels are hundredths of decibels
//
// NOTE: This structure may change in future EAX versions.
// It is recommended to initialize fields by name:
// myBuffer.lDirect = 0;
// myBuffer.lDirectHF = -200;
// ...
// myBuffer.dwFlags = myFlags /* see EAXBUFFERFLAGS below */ ;
// instead of:
// myBuffer = { 0, -200, ... , 0x00000003 };
//
struct EAXBUFFERPROPERTIES {
LONG lDirect; // direct path level
LONG lDirectHF; // direct path level at high frequencies
LONG lRoom; // room effect level
LONG lRoomHF; // room effect level at high frequencies
FLOAT flRoomRolloffFactor; // like DS3D flRolloffFactor but for room effect
LONG lObstruction; // main obstruction control (attenuation at high frequencies)
FLOAT flObstructionLFRatio; // obstruction low-frequency level re. main control
LONG lOcclusion; // main occlusion control (attenuation at high frequencies)
FLOAT flOcclusionLFRatio; // occlusion low-frequency level re. main control
FLOAT flOcclusionRoomRatio; // occlusion room effect level re. main control
LONG lOutsideVolumeHF; // outside sound cone level at high frequencies
FLOAT flAirAbsorptionFactor; // multiplies DSPROPERTY_EAXLISTENER_AIRABSORPTIONHF
DWORD dwFlags; // modifies the behavior of properties
};
// Used by DSPROPERTY_EAXBUFFER_FLAGS
// TRUE: value is computed automatically - property is an offset
// FALSE: value is used directly
//
// Note: The number and order of flags may change in future EAX versions.
// To insure future compatibility, use flag defines as follows:
// myFlags = EAXBUFFERFLAGS_DIRECTHFAUTO | EAXBUFFERFLAGS_ROOMAUTO;
// instead of:
// myFlags = 0x00000003;
//
#define EAXBUFFERFLAGS_DIRECTHFAUTO 0x00000001 // affects DSPROPERTY_EAXBUFFER_DIRECTHF
#define EAXBUFFERFLAGS_ROOMAUTO 0x00000002 // affects DSPROPERTY_EAXBUFFER_ROOM
#define EAXBUFFERFLAGS_ROOMHFAUTO 0x00000004 // affects DSPROPERTY_EAXBUFFER_ROOMHF
#define EAXBUFFERFLAGS_RESERVED 0xFFFFFFF8 // reserved future use
// property ranges and defaults:
#define EAXBUFFER_MINDIRECT -10000
#define EAXBUFFER_MAXDIRECT 1000
#define EAXBUFFER_DEFAULTDIRECT 0
#define EAXBUFFER_MINDIRECTHF -10000
#define EAXBUFFER_MAXDIRECTHF 0
#define EAXBUFFER_DEFAULTDIRECTHF 0
#define EAXBUFFER_MINROOM -10000
#define EAXBUFFER_MAXROOM 1000
#define EAXBUFFER_DEFAULTROOM 0
#define EAXBUFFER_MINROOMHF -10000
#define EAXBUFFER_MAXROOMHF 0
#define EAXBUFFER_DEFAULTROOMHF 0
#define EAXBUFFER_MINROOMROLLOFFFACTOR 0.0f
#define EAXBUFFER_MAXROOMROLLOFFFACTOR 10.f
#define EAXBUFFER_DEFAULTROOMROLLOFFFACTOR 0.0f
#define EAXBUFFER_MINOBSTRUCTION -10000
#define EAXBUFFER_MAXOBSTRUCTION 0
#define EAXBUFFER_DEFAULTOBSTRUCTION 0
#define EAXBUFFER_MINOBSTRUCTIONLFRATIO 0.0f
#define EAXBUFFER_MAXOBSTRUCTIONLFRATIO 1.0f
#define EAXBUFFER_DEFAULTOBSTRUCTIONLFRATIO 0.0f
#define EAXBUFFER_MINOCCLUSION -10000
#define EAXBUFFER_MAXOCCLUSION 0
#define EAXBUFFER_DEFAULTOCCLUSION 0
#define EAXBUFFER_MINOCCLUSIONLFRATIO 0.0f
#define EAXBUFFER_MAXOCCLUSIONLFRATIO 1.0f
#define EAXBUFFER_DEFAULTOCCLUSIONLFRATIO 0.25f
#define EAXBUFFER_MINOCCLUSIONROOMRATIO 0.0f
#define EAXBUFFER_MAXOCCLUSIONROOMRATIO 10.0f
#define EAXBUFFER_DEFAULTOCCLUSIONROOMRATIO 0.5f
#define EAXBUFFER_MINOUTSIDEVOLUMEHF -10000
#define EAXBUFFER_MAXOUTSIDEVOLUMEHF 0
#define EAXBUFFER_DEFAULTOUTSIDEVOLUMEHF 0
#define EAXBUFFER_MINAIRABSORPTIONFACTOR 0.0f
#define EAXBUFFER_MAXAIRABSORPTIONFACTOR 10.0f
#define EAXBUFFER_DEFAULTAIRABSORPTIONFACTOR 1.0f
#define EAXBUFFER_DEFAULTFLAGS (EAXBUFFERFLAGS_DIRECTHFAUTO | EAXBUFFERFLAGS_ROOMAUTO | EAXBUFFERFLAGS_ROOMHFAUTO)
// Material transmission presets
// 3 values in this order:
// 1: occlusion (or obstruction)
// 2: occlusion LF Ratio (or obstruction LF Ratio)
// 3: occlusion Room Ratio
// Single window material preset
#define EAX_MATERIAL_SINGLEWINDOW -2800
#define EAX_MATERIAL_SINGLEWINDOWLF 0.71
#define EAX_MATERIAL_SINGLEWINDOWROOMRATIO 0.43
// Double window material preset
#define EAX_MATERIAL_DOUBLEWINDOW -5000
#define EAX_MATERIAL_DOUBLEWINDOWHF 0.40
#define EAX_MATERIAL_DOUBLEWINDOWROOMRATIO 0.24
// Thin door material preset
#define EAX_MATERIAL_THINDOOR -1800
#define EAX_MATERIAL_THINDOORLF 0.66
#define EAX_MATERIAL_THINDOORROOMRATIO 0.66
// Thick door material preset
#define EAX_MATERIAL_THICKDOOR -4400
#define EAX_MATERIAL_THICKDOORLF 0.64
#define EAX_MATERIAL_THICKDOORROOMRTATION 0.27
// Wood wall material preset
#define EAX_MATERIAL_WOODWALL -4000
#define EAX_MATERIAL_WOODWALLLF 0.50
#define EAX_MATERIAL_WOODWALLROOMRATIO 0.30
// Brick wall material preset
#define EAX_MATERIAL_BRICKWALL -5000
#define EAX_MATERIAL_BRICKWALLLF 0.60
#define EAX_MATERIAL_BRICKWALLROOMRATIO 0.24
// Stone wall material preset
#define EAX_MATERIAL_STONEWALL -6000
#define EAX_MATERIAL_STONEWALLLF 0.68
#define EAX_MATERIAL_STONEWALLROOMRATIO 0.20
// Curtain material preset
#define EAX_MATERIAL_CURTAIN -1200
#define EAX_MATERIAL_CURTAINLF 0.15
#define EAX_MATERIAL_CURTAINROOMRATIO 1.00
#pragma pack(pop)
#ifdef __cplusplus
}
#endif // __cplusplus
#endif