#include <sound.h>
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_t > | pollRemovedSounds () |
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_t > | m_removed_sounds |
|
virtualdefault |
|
pure virtual |
Adds sound with name sound_name to group group_name
.
Creates the group if non-existent.
sound_name | The name of the sound, as used in loadSoundData . |
group_name | The name of the sound group. |
Implemented in DummySoundManager, and sound::ProxySoundManager.
Referenced by Client::loadMedia().
sound_handle_t ISoundManager::allocateId | ( | u32 | num_owners | ) |
Returns a positive id.
The id will be returned again until freeId is called.
num_owners | Owner-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().
|
pure virtual |
Implemented in DummySoundManager, and sound::ProxySoundManager.
Referenced by Client::handleCommand_FadeSound().
void ISoundManager::freeId | ( | sound_handle_t | id, |
u32 | num_owners = 1 ) |
Free an id allocated via allocateId.
num_owners | How 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().
|
pure virtual |
Same as loadSoundFile
, but reads the OggVorbis file from memory.
Implemented in DummySoundManager, and sound::ProxySoundManager.
Referenced by Client::loadMedia().
|
pure virtual |
Adds a sound to load from a file (only OggVorbis).
name | The name of the sound. Must be unique, otherwise call fails. |
filepath | The path for |
Implemented in DummySoundManager, and sound::ProxySoundManager.
|
pure virtual |
Pause all sound playback.
Implemented in DummySoundManager, and sound::ProxySoundManager.
Referenced by Game::updatePauseState().
|
pure virtual |
Plays a random sound from a sound group (position-less).
id | Id 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().
|
pure virtual |
Same as playSound
, but at a position.
pos | In node-space. |
vel | In node-space. |
Implemented in DummySoundManager, and sound::ProxySoundManager.
Referenced by Client::handleCommand_PlaySound(), ModApiClientSound::l_sound_play(), and GenericCAO::step().
|
inline |
Get and reset the list of sounds that were stopped.
References m_removed_sounds.
Referenced by Client::step().
|
protected |
References freeId(), and m_removed_sounds.
Referenced by sound::ProxySoundManager::handleMsg(), DummySoundManager::playSound(), and DummySoundManager::playSoundAt().
|
pure virtual |
Resume sound playback after pause.
Implemented in DummySoundManager, and sound::ProxySoundManager.
Referenced by Game::updatePauseState().
|
pure virtual |
Implemented in DummySoundManager, and sound::ProxySoundManager.
Referenced by sound_volume_control().
|
pure virtual |
Removes finished sounds, steps streamed sounds, and does similar tasks.
Should not be called while paused.
dtime | In seconds. |
Implemented in DummySoundManager, and sound::ProxySoundManager.
Referenced by GUIEngine::run(), and Client::step().
|
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().
|
pure virtual |
pos | In node-space. |
vel | In node-space. |
at | Vector in node-space pointing forwards. |
up | Vector in node-space pointing upwards, orthogonal to at . |
Implemented in DummySoundManager, and sound::ProxySoundManager.
Referenced by Game::updateSound().
|
pure virtual |
Update position and velocity of positional sound.
pos | In node-space. |
vel | In node-space. |
Implemented in DummySoundManager, and sound::ProxySoundManager.
Referenced by Client::step().
|
private |
Referenced by allocateId().
|
private |
Referenced by allocateId(), and freeId().
|
private |
Referenced by pollRemovedSounds(), and reportRemovedSound().