-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore EAX effects through OpenAL's EFX.
- Loading branch information
Showing
15 changed files
with
608 additions
and
527 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,15 +109,12 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
|
||
// EAX stuff | ||
#include "plAudio/plEAXListenerMod.h" | ||
#ifdef EAX_SDK_AVAILABLE | ||
# include <eax-util.h> | ||
# include <eaxlegacy.h> | ||
#endif | ||
#include "plAudio/plEAXStructures.h" | ||
|
||
#include "plResMgr/plLocalization.h" | ||
#include "plPhysical/plPhysicalSndGroup.h" | ||
|
||
// EAX3 values which eax4 no longer defines, but we still need. | ||
// EAX3 values which EAX4 no longer defines, but we still need. | ||
// Single window material preset | ||
#define EAX_MATERIAL_SINGLEWINDOW (-2800) | ||
#define EAX_MATERIAL_SINGLEWINDOWLF 0.71f | ||
|
@@ -158,6 +155,66 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
#define EAX_MATERIAL_CURTAINLF 0.15f | ||
#define EAX_MATERIAL_CURTAINROOMRATIO 1.00f | ||
|
||
#define EAX_NUM_LEGACY_PRESETS 26 | ||
const char* EAX_LEGACY_PRESET_NAMES[EAX_NUM_LEGACY_PRESETS] = | ||
{ | ||
"Generic", | ||
"Padded Cell", | ||
"Room", | ||
"Bathroom", | ||
"Living Room", | ||
"Stone Room", | ||
"Auditorium", | ||
"Concert Hall", | ||
"Cave", | ||
"Arena", | ||
"Hangar", | ||
"Carpetted Hallway", | ||
"Hallway", | ||
"Stone Corridor", | ||
"Alley", | ||
"Forest", | ||
"City", | ||
"Mountains", | ||
"Quarry", | ||
"Plain", | ||
"Parking Lot", | ||
"Sewer Pipe", | ||
"Underwater", | ||
"Drugged", | ||
"Dizzy", | ||
"Psychotic" | ||
}; | ||
|
||
EFXEAXREVERBPROPERTIES EAX_LEGACY_PRESETS[EAX_NUM_LEGACY_PRESETS] = { | ||
EFX_REVERB_PRESET_GENERIC, | ||
EFX_REVERB_PRESET_PADDEDCELL, | ||
EFX_REVERB_PRESET_ROOM, | ||
EFX_REVERB_PRESET_BATHROOM, | ||
EFX_REVERB_PRESET_LIVINGROOM, | ||
EFX_REVERB_PRESET_STONEROOM, | ||
EFX_REVERB_PRESET_AUDITORIUM, | ||
EFX_REVERB_PRESET_CONCERTHALL, | ||
EFX_REVERB_PRESET_CAVE, | ||
EFX_REVERB_PRESET_ARENA, | ||
EFX_REVERB_PRESET_HANGAR, | ||
EFX_REVERB_PRESET_CARPETEDHALLWAY, | ||
EFX_REVERB_PRESET_HALLWAY, | ||
EFX_REVERB_PRESET_STONECORRIDOR, | ||
EFX_REVERB_PRESET_ALLEY, | ||
EFX_REVERB_PRESET_FOREST, | ||
EFX_REVERB_PRESET_CITY, | ||
EFX_REVERB_PRESET_MOUNTAINS, | ||
EFX_REVERB_PRESET_QUARRY, | ||
EFX_REVERB_PRESET_PLAIN, | ||
EFX_REVERB_PRESET_PARKINGLOT, | ||
EFX_REVERB_PRESET_SEWERPIPE, | ||
EFX_REVERB_PRESET_UNDERWATER, | ||
EFX_REVERB_PRESET_DRUGGED, | ||
EFX_REVERB_PRESET_DIZZY, | ||
EFX_REVERB_PRESET_PSYCHOTIC | ||
}; | ||
|
||
void DummyCodeIncludeFuncAudio() {} | ||
|
||
|
||
|
@@ -2775,11 +2832,8 @@ class plEAXListenerDlgProc : public plSingleCompSelProc | |
HWND comboBox = GetDlgItem( hWnd, IDC_EAX_PRESET_COMBO ); | ||
ComboBox_ResetContent( comboBox ); | ||
|
||
#ifdef EAX_SDK_AVAILABLE | ||
for( int i = 0; i < /*sizeof( EAX30_ORIGINAL_PRESETS ) | ||
/ sizeof( EAXLISTENERPROPERTIES )*/26 ; i++ ) | ||
ComboBox_AddString( comboBox, EAX30_ORIGINAL_PRESET_NAMES[ i ] ); | ||
#endif | ||
for( int i = 0; i < EAX_NUM_LEGACY_PRESETS; i++ ) | ||
ComboBox_AddString(comboBox, EAX_LEGACY_PRESET_NAMES[i]); | ||
|
||
ComboBox_SetCurSel( comboBox, pb->GetInt( (ParamID)plEAXListenerComponent::kRefPreset ) ); | ||
|
||
|
@@ -2914,42 +2968,43 @@ bool plEAXListenerComponent::Convert(plMaxNode *node, plErrorMsg *errMsg) | |
// Add the soft region | ||
hsgResMgr::ResMgr()->AddViaNotify( softKey, new plGenRefMsg( listener->GetKey(), plRefMsg::kOnCreate, 0, plEAXListenerMod::kRefSoftRegion ), plRefFlags::kActiveRef ); | ||
|
||
#ifdef EAX_SDK_AVAILABLE | ||
// Set up the parameters of the listener mod | ||
EAXLISTENERPROPERTIES *listenerProps = listener->GetListenerProps(); | ||
if( fCompPB->GetInt( (ParamID)kRefWhichSettings ) == 0 ) | ||
{ | ||
if(fCompPB->GetInt( (ParamID)kRefWhichSettings ) == 0) { | ||
// Set params based on a preset | ||
listener->SetFromPreset( fCompPB->GetInt( (ParamID)kRefPreset ) ); | ||
} | ||
else | ||
{ | ||
listener->SetFromEFXPreset(EAX_LEGACY_PRESETS[fCompPB->GetInt((ParamID)kRefPreset)]); | ||
} else { | ||
// Set params based on artist selections | ||
EAXREVERBPROPERTIES *eaxProps = new EAXREVERBPROPERTIES; | ||
|
||
// Get the raw params | ||
listenerProps->flEnvironmentSize = fCompPB->GetFloat( (ParamID)kRefEnvironmentSize ); | ||
listenerProps->flEnvironmentDiffusion = fCompPB->GetFloat( (ParamID)kRefEnvironmentDiffusion ); | ||
listenerProps->lRoom = fCompPB->GetInt( (ParamID)kRefRoom ); | ||
listenerProps->lRoomHF = fCompPB->GetInt( (ParamID)kRefRoomHF ); | ||
listenerProps->lRoomLF = fCompPB->GetInt( (ParamID)kRefRoomLF ); | ||
listenerProps->flDecayTime = fCompPB->GetFloat( (ParamID)kRefDecayTime ); | ||
listenerProps->flDecayHFRatio = fCompPB->GetFloat( (ParamID)kRefDecayHFRatio ); | ||
listenerProps->flDecayLFRatio = fCompPB->GetFloat( (ParamID)kRefDecayLFRatio ); | ||
listenerProps->lReflections = fCompPB->GetInt( (ParamID)kRefReflections ); | ||
listenerProps->flReflectionsDelay = fCompPB->GetFloat( (ParamID)kRefReflectionsDelay ); | ||
//listenerProps->vReflectionsPan; // early reflections panning vector | ||
listenerProps->lReverb = fCompPB->GetInt( (ParamID)kRefReverb ); // late reverberation level relative to room effect | ||
listenerProps->flReverbDelay = fCompPB->GetFloat( (ParamID)kRefReverbDelay ); | ||
//listenerProps->vReverbPan; // late reverberation panning vector | ||
listenerProps->flEchoTime = fCompPB->GetFloat( (ParamID)kRefEchoTime ); | ||
listenerProps->flEchoDepth = fCompPB->GetFloat( (ParamID)kRefEchoDepth ); | ||
listenerProps->flModulationTime = fCompPB->GetFloat( (ParamID)kRefModulationTime ); | ||
listenerProps->flModulationDepth = fCompPB->GetFloat( (ParamID)kRefModulationDepth ); | ||
listenerProps->flAirAbsorptionHF = fCompPB->GetFloat( (ParamID)kRefAirAbsorptionHF ); | ||
listenerProps->flHFReference = fCompPB->GetFloat( (ParamID)kRefHFReference ); | ||
listenerProps->flLFReference = fCompPB->GetFloat( (ParamID)kRefLFReference ); | ||
listenerProps->flRoomRolloffFactor = fCompPB->GetFloat( (ParamID)kRefRoomRolloffFactor ); | ||
listenerProps->ulFlags = fCompPB->GetInt( (ParamID)kRefFlags ); | ||
eaxProps->flEnvironmentSize = fCompPB->GetFloat( (ParamID)kRefEnvironmentSize ); | ||
eaxProps->flEnvironmentDiffusion = fCompPB->GetFloat( (ParamID)kRefEnvironmentDiffusion ); | ||
eaxProps->lRoom = fCompPB->GetInt( (ParamID)kRefRoom ); | ||
eaxProps->lRoomHF = fCompPB->GetInt( (ParamID)kRefRoomHF ); | ||
eaxProps->lRoomLF = fCompPB->GetInt( (ParamID)kRefRoomLF ); | ||
eaxProps->flDecayTime = fCompPB->GetFloat( (ParamID)kRefDecayTime ); | ||
eaxProps->flDecayHFRatio = fCompPB->GetFloat( (ParamID)kRefDecayHFRatio ); | ||
eaxProps->flDecayLFRatio = fCompPB->GetFloat( (ParamID)kRefDecayLFRatio ); | ||
eaxProps->lReflections = fCompPB->GetInt( (ParamID)kRefReflections ); | ||
eaxProps->flReflectionsDelay = fCompPB->GetFloat( (ParamID)kRefReflectionsDelay ); | ||
//eaxProps->vReflectionsPan; // early reflections panning vector | ||
eaxProps->lReverb = fCompPB->GetInt( (ParamID)kRefReverb ); // late reverberation level relative to room effect | ||
eaxProps->flReverbDelay = fCompPB->GetFloat( (ParamID)kRefReverbDelay ); | ||
//eaxProps->vReverbPan; // late reverberation panning vector | ||
eaxProps->flEchoTime = fCompPB->GetFloat( (ParamID)kRefEchoTime ); | ||
eaxProps->flEchoDepth = fCompPB->GetFloat( (ParamID)kRefEchoDepth ); | ||
eaxProps->flModulationTime = fCompPB->GetFloat( (ParamID)kRefModulationTime ); | ||
eaxProps->flModulationDepth = fCompPB->GetFloat( (ParamID)kRefModulationDepth ); | ||
eaxProps->flAirAbsorptionHF = fCompPB->GetFloat( (ParamID)kRefAirAbsorptionHF ); | ||
eaxProps->flHFReference = fCompPB->GetFloat( (ParamID)kRefHFReference ); | ||
eaxProps->flLFReference = fCompPB->GetFloat( (ParamID)kRefLFReference ); | ||
eaxProps->flRoomRolloffFactor = fCompPB->GetFloat( (ParamID)kRefRoomRolloffFactor ); | ||
eaxProps->ulFlags = fCompPB->GetInt( (ParamID)kRefFlags ); | ||
|
||
// Convert to EFX and store them | ||
plEAXListenerMod::ConvertEAXToEFX(eaxProps, listener->GetListenerProps()); | ||
delete eaxProps; | ||
} | ||
#endif | ||
|
||
return true; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,12 +41,7 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
*==LICENSE==*/ | ||
#include "HeadSpin.h" | ||
#include <al.h> | ||
#ifdef USE_EFX | ||
# include <efx.h> | ||
#endif | ||
#ifdef EAX_SDK_AVAILABLE | ||
# include <eax.h> | ||
#endif | ||
#include <efx.h> | ||
#include <memory> | ||
#include <array> | ||
|
||
|
@@ -245,6 +240,7 @@ bool plAudioSystem::Init() | |
plStatusLog::AddLineSF("audio.log", "OpenAL version: {}", alGetString(AL_VERSION)); | ||
plStatusLog::AddLineSF("audio.log", "OpenAL renderer: {}", alGetString(AL_RENDERER)); | ||
plStatusLog::AddLineSF("audio.log", "OpenAL extensions: {}", alGetString(AL_EXTENSIONS)); | ||
plStatusLog::AddLineSF("audio.log", "OpenAL context extensions: {}", alcGetString(fPlaybackDevice, ALC_EXTENSIONS)); | ||
plStatusLog::AddLineS("audio.log", plStatusLog::kGreen, "ASYS: Detecting caps..."); | ||
|
||
// Detect maximum number of voices that can be created. | ||
|
@@ -264,15 +260,22 @@ bool plAudioSystem::Init() | |
plStatusLog::AddLineSF("audio.log", "Max Number of sources: {}", fMaxNumSources); | ||
SetMaxNumberOfActiveSounds(); | ||
|
||
// TODO: Detect EAX support. Not adding this in now until the replacement is implemented. | ||
// Detect EFX support. | ||
if (alcIsExtensionPresent(alcGetContextsDevice(alcGetCurrentContext()), "ALC_EXT_EFX")) | ||
fEAXSupported = true; | ||
|
||
// Attempt to init the EFX listener. | ||
if (fEAXSupported && plgAudioSys::fEnableEAX) { | ||
ALCint iVerMajor, iVerMinor; | ||
alcGetIntegerv(fPlaybackDevice, ALC_EFX_MAJOR_VERSION, 1, &iVerMajor); | ||
alcGetIntegerv(fPlaybackDevice, ALC_EFX_MAJOR_VERSION, 1, &iVerMinor); | ||
plStatusLog::AddLineSF("audio.log", "ASYS: EFX v{}.{} available.", iVerMajor, iVerMinor); | ||
|
||
// attempt to init the EAX listener. | ||
if (plgAudioSys::fEnableEAX) { | ||
fUsingEAX = plEAXListener::GetInstance().Init(); | ||
if (fUsingEAX) | ||
plStatusLog::AddLineS("audio.log", plStatusLog::kGreen, "ASYS: EAX support detected and enabled."); | ||
plStatusLog::AddLineS("audio.log", plStatusLog::kGreen, "ASYS: EFX support detected and enabled."); | ||
else | ||
plStatusLog::AddLineS("audio.log", plStatusLog::kRed, "ASYS: EAX support NOT detected. EAX effects disabled."); | ||
plStatusLog::AddLineS("audio.log", plStatusLog::kRed, "ASYS: Unable to initialize environmental audio. EFX effects disabled."); | ||
} else { | ||
fUsingEAX = false; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,12 +46,6 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
#include "HeadSpin.h" | ||
#include <al.h> | ||
#include <alc.h> | ||
#ifdef USE_EFX | ||
# include <efx.h> | ||
#endif | ||
#ifdef EAX_SDK_AVAILABLE | ||
# include <eax.h> | ||
#endif | ||
#include <memory> | ||
#include <set> | ||
#include <vector> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,6 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
#include "HeadSpin.h" | ||
#include "hsThread.h" | ||
#include "plDSoundBuffer.h" | ||
#include <al.h> | ||
|
||
#include "plgDispatch.h" | ||
#include "plAudioSystem.h" | ||
|
@@ -59,9 +58,10 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
#include "plEAXEffects.h" | ||
|
||
#include "plProfile.h" | ||
|
||
#include "plStatusLog/plStatusLog.h" | ||
|
||
#include <al.h> | ||
|
||
uint32_t plDSoundBuffer::fNumBuffers = 0; | ||
plProfile_CreateCounterNoReset( "Playing", "Sound", SoundPlaying ); | ||
plProfile_CreateCounterNoReset( "Allocated", "Sound", NumAllocated ); | ||
|
@@ -193,6 +193,8 @@ bool plDSoundBuffer::FillBuffer(void *data, unsigned bytes, plWAVHeader *header) | |
|
||
// Just make it quiet for now | ||
SetScalarVolume(0); | ||
|
||
alSource3i(source, AL_AUXILIARY_SEND_FILTER, 1, 0, AL_FILTER_NULL); | ||
|
||
alSourcef(source, AL_ROLLOFF_FACTOR, 0.3048f); | ||
alGetError(); | ||
|
@@ -265,7 +267,8 @@ bool plDSoundBuffer::SetupStreamingSource(plAudioFileReader *stream) | |
} | ||
alSourcei(source, AL_BUFFER, 0); | ||
SetScalarVolume(0); | ||
|
||
|
||
alSource3i(source, AL_AUXILIARY_SEND_FILTER, 1, 0, AL_FILTER_NULL); | ||
|
||
alSourcef(source, AL_ROLLOFF_FACTOR, 0.3048f); | ||
error = alGetError(); | ||
|
@@ -331,7 +334,9 @@ bool plDSoundBuffer::SetupStreamingSource(void *data, unsigned bytes) | |
} | ||
alSourcei(source, AL_BUFFER, 0); | ||
SetScalarVolume(0); | ||
|
||
|
||
alSource3i(source, AL_AUXILIARY_SEND_FILTER, 1, 0, AL_FILTER_NULL); | ||
|
||
alSourcef(source, AL_ROLLOFF_FACTOR, 0.3048f); | ||
error = alGetError(); | ||
if( error != AL_NO_ERROR ) | ||
|
@@ -489,6 +494,8 @@ bool plDSoundBuffer::SetupVoiceSource() | |
} | ||
|
||
SetScalarVolume(0); | ||
|
||
alSource3i(source, AL_AUXILIARY_SEND_FILTER, 1, 0, AL_FILTER_NULL); | ||
|
||
alSourcef(source, AL_ROLLOFF_FACTOR, 0.3048f); | ||
error = alGetError(); | ||
|
@@ -510,7 +517,7 @@ void plDSoundBuffer::UnQueueVoiceBuffers() | |
unsigned buffersProcessed = BuffersProcessed(); | ||
if(buffersProcessed) | ||
plStatusLog::AddLineSF("audio.log", "unqueuing buffers {}", buffersProcessed); | ||
for(int i = 0; i < buffersProcessed; i++) | ||
for(uint32_t i = 0; i < buffersProcessed; i++) | ||
{ | ||
ALuint unQueued; | ||
alSourceUnqueueBuffers( source, 1, &unQueued ); | ||
|
@@ -532,7 +539,7 @@ bool plDSoundBuffer::VoiceFillBuffer(const void *data, size_t bytes, unsigned bu | |
return false; | ||
|
||
ALenum error; | ||
unsigned int size = bytes < STREAM_BUFFER_SIZE ? bytes : STREAM_BUFFER_SIZE; | ||
size_t size = bytes < STREAM_BUFFER_SIZE ? bytes : STREAM_BUFFER_SIZE; | ||
|
||
ALenum format = IGetALFormat(fBufferDesc->fBitsPerSample, fBufferDesc->fNumChannels); | ||
alBufferData(bufferId, format, data, size, fBufferDesc->fNumSamplesPerSec); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
Mead, WA 99021 | ||
*==LICENSE==*/ | ||
|
||
////////////////////////////////////////////////////////////////////////////// | ||
// // | ||
// plDSoundBuffer - Simple wrapper class for a DirectSound buffer. // | ||
|
@@ -56,15 +57,12 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
#define STREAMING_BUFFERS 16 | ||
#define STREAM_BUFFER_SIZE 4608*4 | ||
|
||
//#define VOICE_BUFFERS 4 | ||
//#define VOICE_BUFFER_SIZE 4608 | ||
|
||
class plWAVHeader; | ||
class plAudioFileReader; | ||
|
||
|
||
// Ported to OpenAL from DirectSound May 2006. Idealy the openal sources would be seperate from this class. | ||
// OpenAl sound buffer, and source. | ||
// Ported to OpenAL from DirectSound May 2006. Ideally the OpenAL sources would be separate from this class. | ||
// OpenAL sound buffer, and source. | ||
class plDSoundBuffer | ||
{ | ||
public: | ||
|
Oops, something went wrong.