mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-05-07 06:16:04 +00:00
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
126 lines
4.1 KiB
C++
126 lines
4.1 KiB
C++
//-----------------------------------------------------------------------------
|
|
// Copyright (c) 2012 GarageGames, LLC
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to
|
|
// deal in the Software without restriction, including without limitation the
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
// IN THE SOFTWARE.
|
|
//-----------------------------------------------------------------------------
|
|
|
|
#ifndef _SFXAMBIENCE_H_
|
|
#define _SFXAMBIENCE_H_
|
|
|
|
#ifndef _SIMDATABLOCK_H_
|
|
#include "console/simDatablock.h"
|
|
#endif
|
|
#ifndef _CONSOLETYPES_H_
|
|
#include "console/consoleTypes.h"
|
|
#endif
|
|
#ifndef _TSIGNAL_H_
|
|
#include "core/util/tSignal.h"
|
|
#endif
|
|
|
|
#ifndef SOUND_ASSET_H
|
|
#include "T3D/assets/SoundAsset.h"
|
|
#endif
|
|
|
|
class SFXEnvironment;
|
|
class SFXTrack;
|
|
class SFXState;
|
|
|
|
|
|
/// Datablock for describing an ambient audio space.
|
|
///
|
|
class SFXAmbience : public SimDataBlock
|
|
{
|
|
public:
|
|
|
|
typedef SimDataBlock Parent;
|
|
typedef Signal< void( SFXAmbience* ) > ChangeSignal;
|
|
|
|
enum
|
|
{
|
|
/// Maximum number of states that can be tied to an ambient space.
|
|
MaxStates = 4
|
|
};
|
|
|
|
protected:
|
|
|
|
/// Doppler shift factor for this space.
|
|
F32 mDopplerFactor;
|
|
|
|
/// Speed of sound for this space.
|
|
F32 mSpeedOfSound;
|
|
|
|
/// Rolloff factor for this space. Only applies to logarithmic distance model.
|
|
F32 mRolloffFactor;
|
|
|
|
/// Sound track to play when inside the ambient space.
|
|
DECLARE_SOUNDASSET(SFXAmbience, SoundTrack);
|
|
DECLARE_ASSET_SETGET(SFXAmbience, SoundTrack);
|
|
|
|
/// Reverb environment to apply when inside the ambient space.
|
|
SFXEnvironment* mEnvironment;
|
|
|
|
/// SFXStates to activate when in this ambient space.
|
|
SFXState* mState[ MaxStates ];
|
|
|
|
///
|
|
static ChangeSignal smChangeSignal;
|
|
|
|
public:
|
|
|
|
SFXAmbience();
|
|
|
|
/// Ensure all properties of this ambience adhere to their value contraints.
|
|
void validate();
|
|
|
|
/// Return the rolloff factor to apply to distance-based volume attenuation in this space (logarithmic distance model only).
|
|
F32 getRolloffFactor() const { return mRolloffFactor; }
|
|
|
|
/// Return the doppler shift factor to apply in this space.
|
|
F32 getDopplerFactor() const { return mDopplerFactor; }
|
|
|
|
F32 getSpeedOfSound() const { return mSpeedOfSound; }
|
|
|
|
/// Return the reverb environment of the ambient space.
|
|
SFXEnvironment* getEnvironment() const { return mEnvironment; }
|
|
|
|
/// Return the given state bound to this ambient space.
|
|
SFXState* getState( U32 i ) const
|
|
{
|
|
AssertFatal( i < MaxStates, "SFXState::getState() - index out of range" );
|
|
return mState[ i ];
|
|
}
|
|
|
|
///
|
|
static ChangeSignal& getChangeSignal() { return smChangeSignal; }
|
|
|
|
// SimDataBlock.
|
|
bool onAdd() override;
|
|
void packData( BitStream* stream ) override;
|
|
void unpackData( BitStream* stream ) override;
|
|
bool preload( bool server, String& errorStr ) override;
|
|
void inspectPostApply() override;
|
|
|
|
static void initPersistFields();
|
|
|
|
DECLARE_CONOBJECT( SFXAmbience );
|
|
DECLARE_CATEGORY( "SFX" );
|
|
DECLARE_DESCRIPTION( "An ambient sound environment." );
|
|
};
|
|
|
|
#endif // !_SFXAMBIENCE_H_
|