|
|
@ -32,6 +32,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
|
|
|
|
|
|
|
|
|
|
#include "hsTypes.h" |
|
|
|
#include "hsTypes.h" |
|
|
|
#include "hsThread.h" |
|
|
|
#include "hsThread.h" |
|
|
|
|
|
|
|
#ifndef EAX_SDK_AVAILABLE |
|
|
|
|
|
|
|
#include <EFX-Util.h> |
|
|
|
|
|
|
|
#endif |
|
|
|
#include "plEAXEffects.h" |
|
|
|
#include "plEAXEffects.h" |
|
|
|
#include "../plAudioCore/plAudioCore.h" |
|
|
|
#include "../plAudioCore/plAudioCore.h" |
|
|
|
#include "plDSoundBuffer.h" |
|
|
|
#include "plDSoundBuffer.h" |
|
|
@ -43,15 +46,19 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
|
|
|
|
|
|
|
|
|
|
#include <dmusici.h> |
|
|
|
#include <dmusici.h> |
|
|
|
#include <dxerr9.h> |
|
|
|
#include <dxerr9.h> |
|
|
|
|
|
|
|
#ifdef EAX_SDK_AVAILABLE |
|
|
|
#include <eax.h> |
|
|
|
#include <eax.h> |
|
|
|
#include <eax-util.h> |
|
|
|
#include <eax-util.h> |
|
|
|
#include <eaxlegacy.h> |
|
|
|
#include <eaxlegacy.h> |
|
|
|
|
|
|
|
#endif |
|
|
|
#include "../plStatusLog/plStatusLog.h" |
|
|
|
#include "../plStatusLog/plStatusLog.h" |
|
|
|
|
|
|
|
|
|
|
|
#define kDebugLog if( myLog != nil ) myLog->AddLineF( |
|
|
|
#define kDebugLog if( myLog != nil ) myLog->AddLineF( |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef EAX_SDK_AVAILABLE |
|
|
|
static EAXGet s_EAXGet; |
|
|
|
static EAXGet s_EAXGet; |
|
|
|
static EAXSet s_EAXSet; |
|
|
|
static EAXSet s_EAXSet; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//// GetInstance /////////////////////////////////////////////////////////////
|
|
|
|
//// GetInstance /////////////////////////////////////////////////////////////
|
|
|
@ -79,6 +86,7 @@ plEAXListener::~plEAXListener() |
|
|
|
|
|
|
|
|
|
|
|
hsBool plEAXListener::Init( void ) |
|
|
|
hsBool plEAXListener::Init( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef EAX_SDK_AVAILABLE |
|
|
|
if( fInited ) |
|
|
|
if( fInited ) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
@ -128,6 +136,10 @@ hsBool plEAXListener::Init( void ) |
|
|
|
ClearProcessCache(); |
|
|
|
ClearProcessCache(); |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
#else /* !EAX_SDK_AVAILABLE */ |
|
|
|
|
|
|
|
plStatusLog::AddLineS("audio.log", "EAX disabled in this build"); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//// Shutdown ////////////////////////////////////////////////////////////////
|
|
|
|
//// Shutdown ////////////////////////////////////////////////////////////////
|
|
|
@ -137,8 +149,10 @@ void plEAXListener::Shutdown( void ) |
|
|
|
if( !fInited ) |
|
|
|
if( !fInited ) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef EAX_SDK_AVAILABLE |
|
|
|
s_EAXSet = nil; |
|
|
|
s_EAXSet = nil; |
|
|
|
s_EAXGet = nil; |
|
|
|
s_EAXGet = nil; |
|
|
|
|
|
|
|
#endif |
|
|
|
IRelease(); |
|
|
|
IRelease(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -147,7 +161,9 @@ bool plEAXListener::SetGlobalEAXProperty(GUID guid, unsigned long ulProperty, vo |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(fInited) |
|
|
|
if(fInited) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef EAX_SDK_AVAILABLE |
|
|
|
return s_EAXSet(&guid, ulProperty, 0, pData, ulDataSize) == AL_NO_ERROR; |
|
|
|
return s_EAXSet(&guid, ulProperty, 0, pData, ulDataSize) == AL_NO_ERROR; |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -156,19 +172,29 @@ bool plEAXListener::GetGlobalEAXProperty(GUID guid, unsigned long ulProperty, vo |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(fInited) |
|
|
|
if(fInited) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef EAX_SDK_AVAILABLE |
|
|
|
return s_EAXGet(&guid, ulProperty, 0, pData, ulDataSize) == AL_NO_ERROR; |
|
|
|
return s_EAXGet(&guid, ulProperty, 0, pData, ulDataSize) == AL_NO_ERROR; |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool plEAXSource::SetSourceEAXProperty(unsigned source, GUID guid, unsigned long ulProperty, void *pData, unsigned long ulDataSize) |
|
|
|
bool plEAXSource::SetSourceEAXProperty(unsigned source, GUID guid, unsigned long ulProperty, void *pData, unsigned long ulDataSize) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef EAX_SDK_AVAILABLE |
|
|
|
return s_EAXSet(&guid, ulProperty, source, pData, ulDataSize) == AL_NO_ERROR; |
|
|
|
return s_EAXSet(&guid, ulProperty, source, pData, ulDataSize) == AL_NO_ERROR; |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool plEAXSource::GetSourceEAXProperty(unsigned source, GUID guid, unsigned long ulProperty, void *pData, unsigned long ulDataSize) |
|
|
|
bool plEAXSource::GetSourceEAXProperty(unsigned source, GUID guid, unsigned long ulProperty, void *pData, unsigned long ulDataSize) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef EAX_SDK_AVAILABLE |
|
|
|
return s_EAXGet(&guid, ulProperty, source, pData, ulDataSize) == AL_NO_ERROR; |
|
|
|
return s_EAXGet(&guid, ulProperty, source, pData, ulDataSize) == AL_NO_ERROR; |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -203,7 +229,7 @@ void plEAXListener::IFail( const char *msg, hsBool major ) |
|
|
|
// Mutes the given properties, so if you have some props that you want
|
|
|
|
// Mutes the given properties, so if you have some props that you want
|
|
|
|
// half strength, this function will do it for ya.
|
|
|
|
// half strength, this function will do it for ya.
|
|
|
|
|
|
|
|
|
|
|
|
void plEAXListener::IMuteProperties( EAXLISTENERPROPERTIES *props, hsScalar percent ) |
|
|
|
void plEAXListener::IMuteProperties( EAXREVERBPROPERTIES *props, hsScalar percent ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// We only mute the room, roomHF and roomLF, since those control the overall effect
|
|
|
|
// We only mute the room, roomHF and roomLF, since those control the overall effect
|
|
|
|
// application. All three are a direct linear blend as defined by eax-util.cpp, so
|
|
|
|
// application. All three are a direct linear blend as defined by eax-util.cpp, so
|
|
|
@ -212,7 +238,9 @@ void plEAXListener::IMuteProperties( EAXLISTENERPROPERTIES *props, hsScalar perc |
|
|
|
hsScalar invPercent = 1.f - percent; |
|
|
|
hsScalar invPercent = 1.f - percent; |
|
|
|
|
|
|
|
|
|
|
|
// The old way, as dictated by EAX sample code...
|
|
|
|
// The old way, as dictated by EAX sample code...
|
|
|
|
|
|
|
|
#ifdef EAX_SDK_AVAILABLE |
|
|
|
props->lRoom = (int)( ( (float)EAXLISTENER_MINROOM * invPercent ) + ( (float)props->lRoom * percent ) ); |
|
|
|
props->lRoom = (int)( ( (float)EAXLISTENER_MINROOM * invPercent ) + ( (float)props->lRoom * percent ) ); |
|
|
|
|
|
|
|
#endif |
|
|
|
// The new way, as suggested by EAX guys...
|
|
|
|
// The new way, as suggested by EAX guys...
|
|
|
|
// props->lRoom = (int)( 2000.f * log( invPercent ) ) + props->lRoom;
|
|
|
|
// props->lRoom = (int)( 2000.f * log( invPercent ) ) + props->lRoom;
|
|
|
|
|
|
|
|
|
|
|
@ -243,6 +271,7 @@ void plEAXListener::ClearProcessCache( void ) |
|
|
|
|
|
|
|
|
|
|
|
void plEAXListener::ProcessMods( hsTArray<plEAXListenerMod *> &modArray ) |
|
|
|
void plEAXListener::ProcessMods( hsTArray<plEAXListenerMod *> &modArray ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef EAX_SDK_AVAILABLE |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
float totalStrength; |
|
|
|
float totalStrength; |
|
|
|
hsBool firstOne; |
|
|
|
hsBool firstOne; |
|
|
@ -386,6 +415,7 @@ void plEAXListener::ProcessMods( hsTArray<plEAXListenerMod *> &modArray ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IFail( false ); |
|
|
|
IFail( false ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif /* EAX_SDK_AVAILABLE */ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -474,8 +504,13 @@ void plEAXSourceSettings::Enable( hsBool e ) |
|
|
|
fEnabled = e; |
|
|
|
fEnabled = e; |
|
|
|
if( !e ) |
|
|
|
if( !e ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef EAX_SDK_AVAILABLE |
|
|
|
fRoom = EAXBUFFER_MINROOM; |
|
|
|
fRoom = EAXBUFFER_MINROOM; |
|
|
|
fRoomHF = EAXBUFFER_MINROOMHF; |
|
|
|
fRoomHF = EAXBUFFER_MINROOMHF; |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
fRoom = 0; |
|
|
|
|
|
|
|
fRoomHF = 0; |
|
|
|
|
|
|
|
#endif |
|
|
|
fRoomAuto = true; |
|
|
|
fRoomAuto = true; |
|
|
|
fRoomHFAuto = true; |
|
|
|
fRoomHFAuto = true; |
|
|
|
|
|
|
|
|
|
|
@ -621,6 +656,7 @@ void plEAXSource::SetFrom( plEAXSourceSettings *settings, unsigned source, hsBoo |
|
|
|
dirtyParams = settings->fDirtyParams; |
|
|
|
dirtyParams = settings->fDirtyParams; |
|
|
|
|
|
|
|
|
|
|
|
// Do the params
|
|
|
|
// Do the params
|
|
|
|
|
|
|
|
#ifdef EAX_SDK_AVAILABLE |
|
|
|
if( dirtyParams & plEAXSourceSettings::kRoom ) |
|
|
|
if( dirtyParams & plEAXSourceSettings::kRoom ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
SetSourceEAXProperty(source, DSPROPSETID_EAX_BufferProperties, DSPROPERTY_EAXBUFFER_ROOM, &settings->fRoom, sizeof(settings->fRoom)); |
|
|
|
SetSourceEAXProperty(source, DSPROPSETID_EAX_BufferProperties, DSPROPERTY_EAXBUFFER_ROOM, &settings->fRoom, sizeof(settings->fRoom)); |
|
|
@ -647,10 +683,12 @@ void plEAXSource::SetFrom( plEAXSourceSettings *settings, unsigned source, hsBoo |
|
|
|
SetSourceEAXProperty(source, DSPROPSETID_EAX_BufferProperties, DSPROPERTY_EAXBUFFER_OCCLUSIONROOMRATIO, &settings->GetCurrSofts().fOcclusionRoomRatio, sizeof(settings->GetCurrSofts().fOcclusionRoomRatio)); |
|
|
|
SetSourceEAXProperty(source, DSPROPSETID_EAX_BufferProperties, DSPROPERTY_EAXBUFFER_OCCLUSIONROOMRATIO, &settings->GetCurrSofts().fOcclusionRoomRatio, sizeof(settings->GetCurrSofts().fOcclusionRoomRatio)); |
|
|
|
SetSourceEAXProperty(source, DSPROPSETID_EAX_BufferProperties, DSPROPERTY_EAXBUFFER_OCCLUSIONDIRECTRATIO, &settings->GetCurrSofts().fOcclusionDirectRatio, sizeof(settings->GetCurrSofts().fOcclusionDirectRatio)); |
|
|
|
SetSourceEAXProperty(source, DSPROPSETID_EAX_BufferProperties, DSPROPERTY_EAXBUFFER_OCCLUSIONDIRECTRATIO, &settings->GetCurrSofts().fOcclusionDirectRatio, sizeof(settings->GetCurrSofts().fOcclusionDirectRatio)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif /* EAX_SDK_AVAILABLE */ |
|
|
|
|
|
|
|
|
|
|
|
settings->ClearDirtyParams(); |
|
|
|
settings->ClearDirtyParams(); |
|
|
|
|
|
|
|
|
|
|
|
// Do all the flags in one pass
|
|
|
|
// Do all the flags in one pass
|
|
|
|
|
|
|
|
#ifdef EAX_SDK_AVAILABLE |
|
|
|
DWORD flags; |
|
|
|
DWORD flags; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -674,6 +712,7 @@ void plEAXSource::SetFrom( plEAXSourceSettings *settings, unsigned source, hsBoo |
|
|
|
// Flag setting failed somehow
|
|
|
|
// Flag setting failed somehow
|
|
|
|
hsAssert( false, "Unable to set EAX buffer flags" ); |
|
|
|
hsAssert( false, "Unable to set EAX buffer flags" ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif /* EAX_SDK_AVAILABLE */ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|