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

Encapsulates the XP12 Sound System. More...

#include <Sound.h>

+ Inheritance diagram for XPMP2::SoundSystemXP:

Public Member Functions

 SoundSystemXP ()
 Construtor, throws exception if XP sound system unavailable (prior to XP12.04) More...
 
 ~SoundSystemXP () 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...
 
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 (not for XP system) More...
 
void SetMasterVolume (float volMaster) override
 Set Master Volume, effectively a multiplicator to SetVolume() More...
 
void SetAllMute (bool bMute) override
 Mute all sounds (temporarily) 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...
 
virtual bool IsValid (uint64_t sndId)
 Is the sound id available? More...
 

Protected Member Functions

void ChnSetVol (const SoundChannel &chn)
 Update an individual channel's volume. More...
 
void AllChnSetVol ()
 Update all channels' volume. 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 void PlayCallback (void *inRefcon, FMOD_RESULT status)
 Callback required by XPLMPlayPCMOnBus. More...
 

Protected Attributes

float volMaster = 1.0f
 Master volume, effectively a multiplicator for individual volume. More...
 
bool bAllMuted = false
 All sounds (temporarily) muted? 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...
 

Detailed Description

Encapsulates the XP12 Sound System.

Looks for availability of the new XP12.04 sound functions (see XPLMSound.h), and use those for playing sounds. Only PCM16 sounds from memory can be played this way, which means that we need to read WAV files and load their PCM data to memory.

Constructor & Destructor Documentation

◆ SoundSystemXP()

XPMP2::SoundSystemXP::SoundSystemXP ( )

Construtor, throws exception if XP sound system unavailable (prior to XP12.04)

◆ ~SoundSystemXP()

XPMP2::SoundSystemXP::~SoundSystemXP ( )
inlineoverride

Destructor.

Member Function Documentation

◆ AllChnSetVol()

void XPMP2::SoundSystemXP::AllChnSetVol ( )
protected

Update all channels' volume.

◆ ChnSetVol()

void XPMP2::SoundSystemXP::ChnSetVol ( const SoundChannel chn)
protected

Update an individual channel's volume.

◆ LoadSoundFile()

bool XPMP2::SoundSystemXP::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::SoundSystemXP::Play ( const std::string &  sndName,
float  vol,
const Aircraft ac 
)
overridevirtual

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

Implements XPMP2::SoundSystem.

◆ PlayCallback()

void XPMP2::SoundSystemXP::PlayCallback ( void *  inRefcon,
FMOD_RESULT  status 
)
staticprotected

Callback required by XPLMPlayPCMOnBus.

◆ SetAllMute()

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

Mute all sounds (temporarily)

Implements XPMP2::SoundSystem.

◆ SetMasterVolume()

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

Set Master Volume, effectively a multiplicator to SetVolume()

Implements XPMP2::SoundSystem.

◆ SetMute()

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

Mute the sound (temporarily)

Implements XPMP2::SoundSystem.

◆ SetPosOrientation()

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

Update sound's position and orientation.

Implements XPMP2::SoundSystem.

◆ SetVolume()

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

Set sound's volume.

Implements XPMP2::SoundSystem.

◆ Stop()

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

Stop the sound.

Implements XPMP2::SoundSystem.

◆ Unpause()

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

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

Note
Only available if built with FMOD library

Implements XPMP2::SoundSystem.

◆ Update()

void XPMP2::SoundSystemXP::Update ( )
inlineoverridevirtual

Any updates to be done at the end of the frame (not for XP system)

Implements XPMP2::SoundSystem.

Member Data Documentation

◆ bAllMuted

bool XPMP2::SoundSystemXP::bAllMuted = false
protected

All sounds (temporarily) muted?

◆ volMaster

float XPMP2::SoundSystemXP::volMaster = 1.0f
protected

Master volume, effectively a multiplicator for individual volume.


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