Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
ISoundManager Class Referenceabstract

#include <sound.h>

+ Inheritance diagram for ISoundManager:
+ Collaboration diagram for ISoundManager:

Public Member Functions

virtual ~ISoundManager ()=default
 
virtual void step (f32 dtime)=0
 Removes finished sounds, steps streamed sounds, and does similar tasks.
 
virtual void pauseAll ()=0
 Pause all sound playback.
 
virtual void resumeAll ()=0
 Resume sound playback after pause.
 
virtual void updateListener (const v3f &pos, const v3f &vel, const v3f &at, const v3f &up)=0
 
virtual void setListenerGain (f32 gain)=0
 
virtual bool loadSoundFile (const std::string &name, const std::string &filepath)=0
 Adds a sound to load from a file (only OggVorbis).
 
virtual bool loadSoundData (const std::string &name, std::string &&filedata)=0
 Same as loadSoundFile, but reads the OggVorbis file from memory.
 
virtual void addSoundToGroup (const std::string &sound_name, const std::string &group_name)=0
 Adds sound with name sound_name to group group_name.
 
virtual void playSound (sound_handle_t id, const SoundSpec &spec)=0
 Plays a random sound from a sound group (position-less).
 
virtual void playSoundAt (sound_handle_t id, const SoundSpec &spec, const v3f &pos, const v3f &vel)=0
 Same as playSound, but at a position.
 
virtual void stopSound (sound_handle_t sound)=0
 Request the sound to be stopped.
 
virtual void fadeSound (sound_handle_t sound, f32 step, f32 target_gain)=0
 
virtual void updateSoundPosVel (sound_handle_t sound, const v3f &pos, const v3f &vel)=0
 Update position and velocity of positional sound.
 
std::vector< sound_handle_tpollRemovedSounds ()
 Get and reset the list of sounds that were stopped.
 
sound_handle_t allocateId (u32 num_owners)
 Returns a positive id.
 
void freeId (sound_handle_t id, u32 num_owners=1)
 Free an id allocated via allocateId.
 

Protected Member Functions

void reportRemovedSound (sound_handle_t id)
 

Private Attributes

std::unordered_map< sound_handle_t, u32 > m_occupied_ids
 
sound_handle_t m_next_id = 1
 
std::vector< sound_handle_tm_removed_sounds
 

Constructor & Destructor Documentation

◆ ~ISoundManager()

virtual ISoundManager::~ISoundManager ( )
virtualdefault

Member Function Documentation

◆ addSoundToGroup()

virtual void ISoundManager::addSoundToGroup ( const std::string & sound_name,
const std::string & group_name )
pure virtual

Adds sound with name sound_name to group group_name.

Creates the group if non-existent.

Parameters
sound_nameThe name of the sound, as used in loadSoundData.
group_nameThe name of the sound group.

Implemented in DummySoundManager, and sound::ProxySoundManager.

Referenced by Client::loadMedia().

+ Here is the caller graph for this function:

◆ allocateId()

sound_handle_t ISoundManager::allocateId ( u32 num_owners)

Returns a positive id.

The id will be returned again until freeId is called.

Parameters
num_ownersOwner-counter for id. Set this to 2, if you want to play a sound and store the id also otherwhere.

References m_next_id, m_occupied_ids, myrand(), and SOUND_HANDLE_T_MAX.

Referenced by Client::handleCommand_PlaySound(), ModApiClientSound::l_sound_play(), ModApiMainMenuSound::l_sound_play(), sound::ProxySoundManager::playSound(), and sound::ProxySoundManager::playSoundAt().

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

◆ fadeSound()

virtual void ISoundManager::fadeSound ( sound_handle_t sound,
f32 step,
f32 target_gain )
pure virtual

Implemented in DummySoundManager, and sound::ProxySoundManager.

Referenced by Client::handleCommand_FadeSound().

+ Here is the caller graph for this function:

◆ freeId()

void ISoundManager::freeId ( sound_handle_t id,
u32 num_owners = 1 )

Free an id allocated via allocateId.

Parameters
num_ownersHow much the owner-counter should be decreased. Id can be reused when counter reaches 0.

References m_occupied_ids.

Referenced by Client::~Client(), Client::handleCommand_PlaySound(), reportRemovedSound(), and Client::step().

+ Here is the caller graph for this function:

◆ loadSoundData()

virtual bool ISoundManager::loadSoundData ( const std::string & name,
std::string && filedata )
pure virtual

Same as loadSoundFile, but reads the OggVorbis file from memory.

Implemented in DummySoundManager, and sound::ProxySoundManager.

Referenced by Client::loadMedia().

+ Here is the caller graph for this function:

◆ loadSoundFile()

virtual bool ISoundManager::loadSoundFile ( const std::string & name,
const std::string & filepath )
pure virtual

Adds a sound to load from a file (only OggVorbis).

Parameters
nameThe name of the sound. Must be unique, otherwise call fails.
filepathThe path for
Returns
true on success, false on failure (ie. sound was already added or file does not exist).

Implemented in DummySoundManager, and sound::ProxySoundManager.

◆ pauseAll()

virtual void ISoundManager::pauseAll ( )
pure virtual

Pause all sound playback.

Implemented in DummySoundManager, and sound::ProxySoundManager.

Referenced by Game::updatePauseState().

+ Here is the caller graph for this function:

◆ playSound()

virtual void ISoundManager::playSound ( sound_handle_t id,
const SoundSpec & spec )
pure virtual

Plays a random sound from a sound group (position-less).

Parameters
idId for new sound. Move semantics apply if id > 0.

Implemented in DummySoundManager, and sound::ProxySoundManager.

Referenced by SoundMaker::cameraPunchLeft(), SoundMaker::cameraPunchRight(), Client::handleCommand_PlaySound(), ModApiClientSound::l_sound_play(), ModApiMainMenuSound::l_sound_play(), SoundMaker::nodeDug(), GUIFormSpecMenu::OnEvent(), SoundMaker::playerDamage(), SoundMaker::playerFallingDamage(), SoundMaker::playPlayerJump(), and SoundMaker::playPlayerStep().

+ Here is the caller graph for this function:

◆ playSoundAt()

virtual void ISoundManager::playSoundAt ( sound_handle_t id,
const SoundSpec & spec,
const v3f & pos,
const v3f & vel )
pure virtual

Same as playSound, but at a position.

Parameters
posIn node-space.
velIn node-space.

Implemented in DummySoundManager, and sound::ProxySoundManager.

Referenced by Client::handleCommand_PlaySound(), ModApiClientSound::l_sound_play(), and GenericCAO::step().

+ Here is the caller graph for this function:

◆ pollRemovedSounds()

std::vector< sound_handle_t > ISoundManager::pollRemovedSounds ( )
inline

Get and reset the list of sounds that were stopped.

References m_removed_sounds.

Referenced by Client::step().

+ Here is the caller graph for this function:

◆ reportRemovedSound()

void ISoundManager::reportRemovedSound ( sound_handle_t id)
protected

References freeId(), and m_removed_sounds.

Referenced by sound::ProxySoundManager::handleMsg(), DummySoundManager::playSound(), and DummySoundManager::playSoundAt().

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

◆ resumeAll()

virtual void ISoundManager::resumeAll ( )
pure virtual

Resume sound playback after pause.

Implemented in DummySoundManager, and sound::ProxySoundManager.

Referenced by Game::updatePauseState().

+ Here is the caller graph for this function:

◆ setListenerGain()

virtual void ISoundManager::setListenerGain ( f32 gain)
pure virtual

Implemented in DummySoundManager, and sound::ProxySoundManager.

Referenced by sound_volume_control().

+ Here is the caller graph for this function:

◆ step()

virtual void ISoundManager::step ( f32 dtime)
pure virtual

Removes finished sounds, steps streamed sounds, and does similar tasks.

Should not be called while paused.

Parameters
dtimeIn seconds.

Implemented in DummySoundManager, and sound::ProxySoundManager.

Referenced by GUIEngine::run(), and Client::step().

+ Here is the caller graph for this function:

◆ stopSound()

virtual void ISoundManager::stopSound ( sound_handle_t sound)
pure virtual

Request the sound to be stopped.

The id should be freed afterwards.

Implemented in DummySoundManager, and sound::ProxySoundManager.

Referenced by Client::handleCommand_StopSound().

+ Here is the caller graph for this function:

◆ updateListener()

virtual void ISoundManager::updateListener ( const v3f & pos,
const v3f & vel,
const v3f & at,
const v3f & up )
pure virtual
Parameters
posIn node-space.
velIn node-space.
atVector in node-space pointing forwards.
upVector in node-space pointing upwards, orthogonal to at.

Implemented in DummySoundManager, and sound::ProxySoundManager.

Referenced by Game::updateSound().

+ Here is the caller graph for this function:

◆ updateSoundPosVel()

virtual void ISoundManager::updateSoundPosVel ( sound_handle_t sound,
const v3f & pos,
const v3f & vel )
pure virtual

Update position and velocity of positional sound.

Parameters
posIn node-space.
velIn node-space.

Implemented in DummySoundManager, and sound::ProxySoundManager.

Referenced by Client::step().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_next_id

sound_handle_t ISoundManager::m_next_id = 1
private

Referenced by allocateId().

◆ m_occupied_ids

std::unordered_map<sound_handle_t, u32> ISoundManager::m_occupied_ids
private

Referenced by allocateId(), and freeId().

◆ m_removed_sounds

std::vector<sound_handle_t> ISoundManager::m_removed_sounds
private

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