Minetest  5.4.0
OpenALSoundManager Class Reference
+ Inheritance diagram for OpenALSoundManager:
+ Collaboration diagram for OpenALSoundManager:

Classes

struct  FadeState
 

Public Member Functions

 OpenALSoundManager (SoundManagerSingleton *smg, OnDemandSoundFetcher *fetcher)
 
 ~OpenALSoundManager ()
 
void step (float dtime)
 
void addBuffer (const std::string &name, SoundBuffer *buf)
 
SoundBuffergetBuffer (const std::string &name)
 
PlayingSoundcreatePlayingSound (SoundBuffer *buf, bool loop, float volume, float pitch)
 
PlayingSoundcreatePlayingSoundAt (SoundBuffer *buf, bool loop, float volume, v3f pos, float pitch)
 
int playSoundRaw (SoundBuffer *buf, bool loop, float volume, float pitch)
 
int playSoundRawAt (SoundBuffer *buf, bool loop, float volume, const v3f &pos, float pitch)
 
void deleteSound (int id)
 
SoundBuffergetFetchBuffer (const std::string &name)
 
void maintain ()
 
bool loadSoundFile (const std::string &name, const std::string &filepath)
 
bool loadSoundData (const std::string &name, const std::string &filedata)
 
void updateListener (const v3f &pos, const v3f &vel, const v3f &at, const v3f &up)
 
void setListenerGain (float gain)
 
int playSound (const std::string &name, bool loop, float volume, float fade, float pitch)
 
int playSoundAt (const std::string &name, bool loop, float volume, v3f pos, float pitch)
 
void stopSound (int sound)
 
void fadeSound (int soundid, float step, float gain)
 
void doFades (float dtime)
 
bool soundExists (int sound)
 
void updateSoundPosition (int id, v3f pos)
 
bool updateSoundGain (int id, float gain)
 
float getSoundGain (int id)
 
- Public Member Functions inherited from ISoundManager
virtual ~ISoundManager ()=default
 
int playSound (const SimpleSoundSpec &spec, bool loop)
 
int playSoundAt (const SimpleSoundSpec &spec, bool loop, const v3f &pos)
 

Private Attributes

OnDemandSoundFetcherm_fetcher
 
ALCdevice * m_device
 
ALCcontext * m_context
 
int m_next_id
 
std::unordered_map< std::string, std::vector< SoundBuffer * > > m_buffers
 
std::unordered_map< int, PlayingSound * > m_sounds_playing
 
std::unordered_map< int, FadeStatem_sounds_fading
 

Constructor & Destructor Documentation

◆ OpenALSoundManager()

OpenALSoundManager::OpenALSoundManager ( SoundManagerSingleton smg,
OnDemandSoundFetcher fetcher 
)
inline

References infostream.

◆ ~OpenALSoundManager()

OpenALSoundManager::~OpenALSoundManager ( )
inline

References deleteSound(), infostream, m_buffers, and m_sounds_playing.

+ Here is the call graph for this function:

Member Function Documentation

◆ addBuffer()

void OpenALSoundManager::addBuffer ( const std::string &  name,
SoundBuffer buf 
)
inline

References m_buffers.

Referenced by loadSoundData(), and loadSoundFile().

+ Here is the caller graph for this function:

◆ createPlayingSound()

PlayingSound* OpenALSoundManager::createPlayingSound ( SoundBuffer buf,
bool  loop,
float  volume,
float  pitch 
)
inline

References SoundBuffer::buffer_id, infostream, PlayingSound::source_id, and warn_if_error().

Referenced by playSoundRaw().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createPlayingSoundAt()

PlayingSound* OpenALSoundManager::createPlayingSoundAt ( SoundBuffer buf,
bool  loop,
float  volume,
v3f  pos,
float  pitch 
)
inline

References SoundBuffer::buffer_id, infostream, PlayingSound::source_id, and warn_if_error().

Referenced by playSoundRawAt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteSound()

void OpenALSoundManager::deleteSound ( int  id)
inline

References m_sounds_playing, and PlayingSound::source_id.

Referenced by ~OpenALSoundManager(), maintain(), and stopSound().

+ Here is the caller graph for this function:

◆ doFades()

void OpenALSoundManager::doFades ( float  dtime)
inline

References OpenALSoundManager::FadeState::current_gain, m_sounds_fading, OpenALSoundManager::FadeState::step, stopSound(), OpenALSoundManager::FadeState::target_gain, and updateSoundGain().

Referenced by step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fadeSound()

void OpenALSoundManager::fadeSound ( int  soundid,
float  step,
float  gain 
)
inlinevirtual

Implements ISoundManager.

References getSoundGain(), m_sounds_fading, rangelim, and step().

Referenced by playSound().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBuffer()

SoundBuffer* OpenALSoundManager::getBuffer ( const std::string &  name)
inline

References m_buffers, and myrand().

Referenced by getFetchBuffer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFetchBuffer()

SoundBuffer* OpenALSoundManager::getFetchBuffer ( const std::string &  name)
inline

References OnDemandSoundFetcher::fetchSounds(), getBuffer(), loadSoundData(), loadSoundFile(), and m_fetcher.

Referenced by playSound(), and playSoundAt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSoundGain()

float OpenALSoundManager::getSoundGain ( int  id)
inlinevirtual

Implements ISoundManager.

References m_sounds_playing, and PlayingSound::source_id.

Referenced by fadeSound().

+ Here is the caller graph for this function:

◆ loadSoundData()

bool OpenALSoundManager::loadSoundData ( const std::string &  name,
const std::string &  filedata 
)
inlinevirtual

Implements ISoundManager.

References addBuffer(), and load_ogg_from_buffer().

Referenced by getFetchBuffer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadSoundFile()

bool OpenALSoundManager::loadSoundFile ( const std::string &  name,
const std::string &  filepath 
)
inlinevirtual

Implements ISoundManager.

References addBuffer(), and load_ogg_from_file().

Referenced by getFetchBuffer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maintain()

void OpenALSoundManager::maintain ( )
inline

References deleteSound(), m_buffers, m_sounds_playing, PlayingSound::source_id, and verbosestream.

Referenced by playSound(), playSoundAt(), soundExists(), and stopSound().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ playSound()

int OpenALSoundManager::playSound ( const std::string &  name,
bool  loop,
float  volume,
float  fade,
float  pitch 
)
inlinevirtual

Implements ISoundManager.

References fadeSound(), getFetchBuffer(), infostream, maintain(), and playSoundRaw().

+ Here is the call graph for this function:

◆ playSoundAt()

int OpenALSoundManager::playSoundAt ( const std::string &  name,
bool  loop,
float  volume,
v3f  pos,
float  pitch 
)
inlinevirtual

Implements ISoundManager.

References getFetchBuffer(), infostream, maintain(), and playSoundRawAt().

+ Here is the call graph for this function:

◆ playSoundRaw()

int OpenALSoundManager::playSoundRaw ( SoundBuffer buf,
bool  loop,
float  volume,
float  pitch 
)
inline

References createPlayingSound(), m_next_id, and m_sounds_playing.

Referenced by playSound().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ playSoundRawAt()

int OpenALSoundManager::playSoundRawAt ( SoundBuffer buf,
bool  loop,
float  volume,
const v3f pos,
float  pitch 
)
inline

References createPlayingSoundAt(), m_next_id, and m_sounds_playing.

Referenced by playSoundAt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setListenerGain()

void OpenALSoundManager::setListenerGain ( float  gain)
inlinevirtual

Implements ISoundManager.

◆ soundExists()

bool OpenALSoundManager::soundExists ( int  sound)
inlinevirtual

Implements ISoundManager.

References m_sounds_playing, and maintain().

+ Here is the call graph for this function:

◆ step()

void OpenALSoundManager::step ( float  dtime)
inlinevirtual

Implements ISoundManager.

References doFades().

Referenced by fadeSound().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stopSound()

void OpenALSoundManager::stopSound ( int  sound)
inlinevirtual

Implements ISoundManager.

References deleteSound(), and maintain().

Referenced by doFades().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateListener()

void OpenALSoundManager::updateListener ( const v3f pos,
const v3f vel,
const v3f at,
const v3f up 
)
inlinevirtual

Implements ISoundManager.

References f3_set(), and warn_if_error().

+ Here is the call graph for this function:

◆ updateSoundGain()

bool OpenALSoundManager::updateSoundGain ( int  id,
float  gain 
)
inlinevirtual

Implements ISoundManager.

References m_sounds_playing, and PlayingSound::source_id.

Referenced by doFades().

+ Here is the caller graph for this function:

◆ updateSoundPosition()

void OpenALSoundManager::updateSoundPosition ( int  id,
v3f  pos 
)
inlinevirtual

Member Data Documentation

◆ m_buffers

std::unordered_map<std::string, std::vector<SoundBuffer*> > OpenALSoundManager::m_buffers
private

◆ m_context

ALCcontext* OpenALSoundManager::m_context
private

◆ m_device

ALCdevice* OpenALSoundManager::m_device
private

◆ m_fetcher

OnDemandSoundFetcher* OpenALSoundManager::m_fetcher
private

Referenced by getFetchBuffer().

◆ m_next_id

int OpenALSoundManager::m_next_id
private

Referenced by playSoundRaw(), and playSoundRawAt().

◆ m_sounds_fading

std::unordered_map<int, FadeState> OpenALSoundManager::m_sounds_fading
private

Referenced by doFades(), and fadeSound().

◆ m_sounds_playing

std::unordered_map<int, PlayingSound*> OpenALSoundManager::m_sounds_playing
private

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