SFX API Changes

DSound has since been deprecated and xaudio2 would require us to write our own 3d spatialization and mixer
Load devices the same way we load in the gfx end
setup sfx provider
run sfx devices on startup
various fixes around sfx null device
added the bitrate and samplerate globals
added the hrtf global code is in to use this but not setup yet
Adds speed of sound to the sound system
SFXAmbience now has a property for speed of sound for different mediums, can also be set directly
This commit is contained in:
marauder2k7 2026-03-13 08:05:42 +00:00
parent 54b6c3ec47
commit d56bf257c7
53 changed files with 1870 additions and 6401 deletions

View file

@ -23,21 +23,19 @@
#ifndef _SFXDEVICE_H_
#define _SFXDEVICE_H_
#ifndef _SFXPROVIDER_H_
#include "sfx/sfxProvider.h"
#endif
#ifndef _PLATFORM_H_
#include "platform/platform.h"
#endif
#ifndef _TVECTOR_H_
#include "core/util/tVector.h"
#endif
#ifndef _SFXCOMMON_H_
#include "sfx/sfxCommon.h"
#endif
#ifndef _THREADSAFEREF_H_
#include "platform/threads/threadSafeRefCount.h"
#endif
class SFXProvider;
class SFXListener;
class SFXBuffer;
class SFXVoice;
@ -46,8 +44,6 @@ class SFXDevice;
class SFXStream;
class SFXDescription;
/// Abstract base class for back-end sound API implementations.
class SFXDevice
{
@ -58,13 +54,26 @@ class SFXDevice
/// Device capability flags.
enum ECaps
{
CAPS_Reverb = BIT( 0 ), ///< Device supports reverb environments.
CAPS_VoiceManagement = BIT( 1 ), ///< Device manages voices on its own; deactivates virtualization code in SFX system.
CAPS_Occlusion = BIT( 2 ), ///< Device has its own sound occlusion handling (SFXOcclusionManager).
CAPS_DSPEffects = BIT( 3 ), ///< Device implements DSP effects (SFXDSPManager).
CAPS_MultiListener = BIT( 4 ), ///< Device supports multiple listeners.
CAPS_Reverb = BIT(0), ///< Device supports reverb environments.
CAPS_VoiceManagement = BIT(1), ///< Device manages voices on its own; deactivates virtualization code in SFX system.
CAPS_Occlusion = BIT(2), ///< Device has its own sound occlusion handling (SFXOcclusionManager).
CAPS_DSPEffects = BIT(3), ///< Device implements DSP effects (SFXDSPManager).
CAPS_MultiListener = BIT(4), ///< Device supports multiple listeners.
CAPS_HRTF = BIT(5), ///< Device supports HRTF (3D audio positioning).
CAPS_Float32 = BIT(6), ///< Device supports 32-bit float playback.
CAPS_MonoStereo = BIT(7), ///< Device supports mono/stereo output modes.
};
static void initConsole();
static S32 smUpdateInterval;
/// The device frequency, used when reading in buffers for the device.
static S32 smDeviceFrequency;
/// The device bitrate.
static S8 smDeviceBitrate;
/// Does the device use hrtf
static bool smDeviceHRTF;
protected:
typedef Vector< SFXBuffer* > BufferVector;
@ -73,13 +82,11 @@ class SFXDevice
typedef BufferVector::iterator BufferIterator;
typedef VoiceVector::iterator VoiceIterator;
SFXDevice( const String& name, SFXProvider* provider, bool useHardware, S32 maxBuffers );
/// The name of this device.
String mName;
/// The provider which created this device.
SFXProvider* mProvider;
SFXProvider mProvider;
/// Should the device try to use hardware processing.
bool mUseHardware;
@ -125,11 +132,12 @@ class SFXDevice
void _releaseAllResources();
public:
SFXDevice();
virtual ~SFXDevice();
/// Returns the provider which created this device.
SFXProvider* getProvider() const { return mProvider; }
virtual const SFXProvider& getProvider() { return mProvider; }
virtual void setProvider(const SFXProvider& provider) { mProvider = provider; }
/// Is the device set to use hardware processing.
bool getUseHardware() const { return mUseHardware; }
@ -174,6 +182,9 @@ public:
/// Set the scale factor to use for doppler effects on 3D sounds.
virtual void setDopplerFactor( F32 factor ) {}
/// Set the speed of sound for the device.
virtual void setSpeedOfSound(F32 speedOfSound) {}
/// Set the rolloff scale factor for distance attenuation of 3D sounds.
virtual void setRolloffFactor( F32 factor ) {}