XPMP2
X-Plane multiplayer library 2 - using instancing
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
XPMP2::SoundSystemFMOD Class Reference

Encapsulates direct access to the FMOD Sound System. More...

#include <SoundFMOD.h>

+ Inheritance diagram for XPMP2::SoundSystemFMOD:

Public Member Functions

 SoundSystemFMOD ()
 Construtor, throws exception if FMOD sound system cannot be initialized. More...
 
 ~SoundSystemFMOD () override
 Destructor. More...
 
bool LoadSoundFile (const std::string &_sndName, const std::string &_filePath, bool _bLoop, float _coneDir, float _conePitch, float _coneInAngle, float _coneOutAngle, float _coneOutVol) override
 Loads a sound file so it becomes ready to play. More...
 
bool UsePreV2Fmod ()
 Use pre-v2 FMOD version structures? More...
 
FMOD_SYSTEM * GetSys () const
 Return the FMOD sound system. More...
 
unsigned int GetVer () const
 Return the FMOD version. More...
 
void SoundLogEnable (bool bEnable=true)
 Enables/disables FMOD logging. More...
 
uint64_t Play (const std::string &sndName, float vol, const Aircraft &ac) override
 Play a new sound, returns an id for that sound. More...
 
void Unpause (uint64_t sndId) override
 Unpause a sound, which got started in a paused state to avoid crackling. More...
 
void Stop (uint64_t sndId) override
 Stop the sound. More...
 
void SetPosOrientation (uint64_t sndId, const Aircraft &ac, bool bDoOrientation) override
 Update sound's position and orientation. More...
 
void SetVolume (uint64_t sndId, float vol) override
 Set sound's volume. More...
 
void SetMute (uint64_t sndId, bool bMute) override
 Mute the sound (temporarily) More...
 
void Update () override
 Any updates to be done at the end of the frame. More...
 
void SetMasterVolume (float volMaster) override
 Set Master Volume on our channel group. More...
 
void SetAllMute (bool bMute) override
 Mute all sounds (temporarily) More...
 
bool IsValid (uint64_t sndId) override
 Is the sound id available? More...
 
- Public Member Functions inherited from XPMP2::SoundSystem
 SoundSystem ()
 Construtor. More...
 
virtual ~SoundSystem ()
 Destructor. More...
 
const char * EnumerateSounds (const char *prevName, const char **ppFilePath)
 Enumerate all loaded sounds. More...
 

Protected Member Functions

void SetLowPassGain (bool bOn)
 Set low pass gain on all active sounds. More...
 
template<class T_ADVSET >
void SoundSetFmodSettings (T_ADVSET &advSet)
 Helper functon to set FMOD settings. More...
 
- Protected Member Functions inherited from XPMP2::SoundSystem
std::pair< uint64_t, SoundChannel * > AddChn (SoundFile *pSnd, float vol, FMOD_CHANNEL *pChn=nullptr)
 Add one more channel, returning the newly created id. More...
 
SoundChannelGetChn (uint64_t sndId)
 Return the SoundChannel object for a given id, or nullptr if not found. More...
 
void RemoveChn (uint64_t sndId)
 Remove a channel from out tracking. More...
 

Static Protected Member Functions

static FMOD_RESULT F_CALLBACK ChnCB (FMOD_CHANNELCONTROL *channelcontrol, FMOD_CHANNELCONTROL_TYPE controltype, FMOD_CHANNELCONTROL_CALLBACK_TYPE callbacktype, void *commanddata1, void *commanddata2)
 Callback function for when sound ends, allows for internal bookkeeping. More...
 
static FMOD_RESULT F_CALLBACK SoundLogCB (FMOD_DEBUG_FLAGS flags, const char *file, int line, const char *func, const char *message)
 Callback function called by FMOD for logging purposes. More...
 
static uint64_t GetSndId (FMOD_CHANNEL *pFmodChn)
 Read SoundChannel from FMOD Channel's user data. More...
 

Protected Attributes

FMOD_SYSTEM * pFmodSystem = nullptr
 FMOD system. More...
 
unsigned int fmodVer = 0
 FMOD version. More...
 
FMOD_CHANNELGROUP * pChnGrp = nullptr
 Our channel group that we place everything under. More...
 
bool bLowPass = false
 Low Pass filter currently active? More...
 
- Protected Attributes inherited from XPMP2::SoundSystem
mapSoundPtrTy mapSounds
 Map of all sounds, indexed by a sound name (type) More...
 
std::map< uint64_t, SoundChannelmapChn
 Keeps track of currently playing sounds, their key serving as id. More...
 

Static Protected Attributes

static SoundSystemFMODme = nullptr
 static pointer to myself More...
 

Detailed Description

Encapsulates direct access to the FMOD Sound System.

Constructor & Destructor Documentation

◆ SoundSystemFMOD()

XPMP2::SoundSystemFMOD::SoundSystemFMOD ( )

Construtor, throws exception if FMOD sound system cannot be initialized.

FMOD 1.08.30 version of FMOD_ADVANCEDSETTINGS

◆ ~SoundSystemFMOD()

XPMP2::SoundSystemFMOD::~SoundSystemFMOD ( )
override

Destructor.

Member Function Documentation

◆ ChnCB()

FMOD_RESULT F_CALLBACK XPMP2::SoundSystemFMOD::ChnCB ( FMOD_CHANNELCONTROL *  channelcontrol,
FMOD_CHANNELCONTROL_TYPE  controltype,
FMOD_CHANNELCONTROL_CALLBACK_TYPE  callbacktype,
void *  commanddata1,
void *  commanddata2 
)
staticprotected

Callback function for when sound ends, allows for internal bookkeeping.

◆ GetSndId()

uint64_t XPMP2::SoundSystemFMOD::GetSndId ( FMOD_CHANNEL *  pFmodChn)
staticprotected

Read SoundChannel from FMOD Channel's user data.

◆ GetSys()

FMOD_SYSTEM* XPMP2::SoundSystemFMOD::GetSys ( ) const
inline

Return the FMOD sound system.

◆ GetVer()

unsigned int XPMP2::SoundSystemFMOD::GetVer ( ) const
inline

Return the FMOD version.

◆ IsValid()

bool XPMP2::SoundSystemFMOD::IsValid ( uint64_t  sndId)
overridevirtual

Is the sound id available?

Reimplemented from XPMP2::SoundSystem.

◆ LoadSoundFile()

bool XPMP2::SoundSystemFMOD::LoadSoundFile ( const std::string &  _sndName,
const std::string &  _filePath,
bool  _bLoop,
float  _coneDir,
float  _conePitch,
float  _coneInAngle,
float  _coneOutAngle,
float  _coneOutVol 
)
overridevirtual

Loads a sound file so it becomes ready to play.

Note
In this sound system, we can only deal with WAV files as we have to read the ourselves

Implements XPMP2::SoundSystem.

◆ Play()

uint64_t XPMP2::SoundSystemFMOD::Play ( const std::string &  sndName,
float  vol,
const Aircraft ac 
)
overridevirtual

Play a new sound, returns an id for that sound.

Implements XPMP2::SoundSystem.

◆ SetAllMute()

void XPMP2::SoundSystemFMOD::SetAllMute ( bool  bMute)
overridevirtual

Mute all sounds (temporarily)

Implements XPMP2::SoundSystem.

◆ SetLowPassGain()

void XPMP2::SoundSystemFMOD::SetLowPassGain ( bool  bOn)
protected

Set low pass gain on all active sounds.

◆ SetMasterVolume()

void XPMP2::SoundSystemFMOD::SetMasterVolume ( float  volMaster)
overridevirtual

Set Master Volume on our channel group.

Implements XPMP2::SoundSystem.

◆ SetMute()

void XPMP2::SoundSystemFMOD::SetMute ( uint64_t  sndId,
bool  bMute 
)
overridevirtual

Mute the sound (temporarily)

Implements XPMP2::SoundSystem.

◆ SetPosOrientation()

void XPMP2::SoundSystemFMOD::SetPosOrientation ( uint64_t  sndId,
const Aircraft ac,
bool  bDoOrientation 
)
overridevirtual

Update sound's position and orientation.

Implements XPMP2::SoundSystem.

◆ SetVolume()

void XPMP2::SoundSystemFMOD::SetVolume ( uint64_t  sndId,
float  vol 
)
overridevirtual

Set sound's volume.

Implements XPMP2::SoundSystem.

◆ SoundLogCB()

FMOD_RESULT F_CALLBACK XPMP2::SoundSystemFMOD::SoundLogCB ( FMOD_DEBUG_FLAGS  flags,
const char *  file,
int  line,
const char *  func,
const char *  message 
)
staticprotected

Callback function called by FMOD for logging purposes.

Note
FMOD warns this can be called from any thread, so strictly speaking we must not call XPLMDebugString(), but so far it didn't hurt, and it should be debug builds only anyway.

◆ SoundLogEnable()

void XPMP2::SoundSystemFMOD::SoundLogEnable ( bool  bEnable = true)

Enables/disables FMOD logging.

Note
FMOD Logging only works if linked to the L versions of the FMOD library

◆ SoundSetFmodSettings()

template<class T_ADVSET >
void XPMP2::SoundSystemFMOD::SoundSetFmodSettings ( T_ADVSET &  advSet)
protected

Helper functon to set FMOD settings.

Implemented as template function so it works with both FMOD_ADVANCEDSETTINGS and FMOD_10830_ADVANCEDSETTINGS for backwards compatibility with v1.8 of FMOD as used in XP11.

◆ Stop()

void XPMP2::SoundSystemFMOD::Stop ( uint64_t  sndId)
overridevirtual

Stop the sound.

Implements XPMP2::SoundSystem.

◆ Unpause()

void XPMP2::SoundSystemFMOD::Unpause ( uint64_t  sndId)
overridevirtual

Unpause a sound, which got started in a paused state to avoid crackling.

Implements XPMP2::SoundSystem.

◆ Update()

void XPMP2::SoundSystemFMOD::Update ( )
overridevirtual

Any updates to be done at the end of the frame.

Implements XPMP2::SoundSystem.

◆ UsePreV2Fmod()

bool XPMP2::SoundSystemFMOD::UsePreV2Fmod ( )
inline

Use pre-v2 FMOD version structures?

Member Data Documentation

◆ bLowPass

bool XPMP2::SoundSystemFMOD::bLowPass = false
protected

Low Pass filter currently active?

◆ fmodVer

unsigned int XPMP2::SoundSystemFMOD::fmodVer = 0
protected

FMOD version.

◆ me

SoundSystemFMOD * XPMP2::SoundSystemFMOD::me = nullptr
staticprotected

static pointer to myself

◆ pChnGrp

FMOD_CHANNELGROUP* XPMP2::SoundSystemFMOD::pChnGrp = nullptr
protected

Our channel group that we place everything under.

◆ pFmodSystem

FMOD_SYSTEM* XPMP2::SoundSystemFMOD::pFmodSystem = nullptr
protected

FMOD system.


The documentation for this class was generated from the following files: