ManaPlus
|
#include <soundmanager.h>
Public Member Functions | |
SoundManager () | |
~SoundManager () | |
void | optionChanged (const std::string &value) |
void | init () |
void | testAudio () |
void | close () |
void | playMusic (const std::string &fileName, const SkipError skipError) |
void | stopMusic () |
void | fadeOutMusic (const int ms) |
void | fadeOutAndPlayMusic (const std::string &fileName, const int ms) |
void | setMusicVolume (const int volume) |
void | setSfxVolume (const int volume) |
void | playSfx (const std::string &path, const int x, const int y) const |
void | playGuiSfx (const std::string &path) |
void | playGuiSound (const std::string &name) |
void | changeAudio () |
void | volumeOff () const |
void | volumeRestore () const |
std::string | getCurrentMusicFile () const |
void | logic () |
void | shutdown () |
void | setChannels (const int channels) const |
Public Member Functions inherited from ConfigListener | |
ConfigListener () | |
virtual | ~ConfigListener () |
Static Public Member Functions | |
static int | getMaxVolume () |
Private Member Functions | |
void | haltMusic () |
Static Private Member Functions | |
static void | info () |
Private Attributes | |
std::string | mNextMusicFile |
bool | mInstalled |
int | mSfxVolume |
int | mMusicVolume |
std::string | mCurrentMusicFile |
SDLMusic * | mMusic |
int | mGuiChannel |
bool | mPlayBattle |
bool | mPlayGui |
bool | mPlayMusic |
bool | mFadeoutMusic |
bool | mCacheSounds |
Definition at line 44 of file soundmanager.h.
SoundManager::SoundManager | ( | ) |
SoundManager::~SoundManager | ( | ) |
Definition at line 93 of file soundmanager.cpp.
void SoundManager::changeAudio | ( | ) |
void SoundManager::close | ( | ) |
Removes all sound functionalities.
Definition at line 531 of file soundmanager.cpp.
References ResourceManager::decRefDelete(), Logger::log1(), logger, mCurrentMusicFile, mInstalled, and mMusic.
Referenced by Setup_Audio::apply(), changeAudio(), and Client::gameClear().
void SoundManager::fadeOutAndPlayMusic | ( | const std::string & | fileName, |
const int | ms | ||
) |
Fades out a background music and play a new one.
fileName | The name of the music file. |
ms | Duration of fade-out effect (ms) |
Definition at line 424 of file soundmanager.cpp.
References fadeOutMusic(), fileName, mNextMusicFile, and mPlayMusic.
Referenced by Game::changeMap(), and LocalPlayer::updateMusic().
void SoundManager::fadeOutMusic | ( | const int | ms | ) |
Fades in background music.
fileName | The name of the music file. |
ms | Duration of fade-in effect (ms) Fades out currently running background music track. |
ms | Duration of fade-out effect (ms) |
Definition at line 398 of file soundmanager.cpp.
References haltMusic(), Logger::log(), logger, mCurrentMusicFile, mFadeoutMusic, mInstalled, mMusic, mPlayMusic, and sFadingOutEnded.
Referenced by Game::changeMap(), fadeOutAndPlayMusic(), and LocalPlayer::updateMusic().
|
inline |
Definition at line 135 of file soundmanager.h.
References mCurrentMusicFile.
Referenced by LocalPlayer::updateMusic().
|
inlinestatic |
Definition at line 104 of file soundmanager.h.
Referenced by Setup_Audio::Setup_Audio().
|
private |
Halts and frees currently playing music.
Definition at line 550 of file soundmanager.cpp.
References Resource::decRef(), mCurrentMusicFile, and mMusic.
Referenced by fadeOutMusic(), playMusic(), and stopMusic().
|
staticprivate |
Logs various info about sound device.
< Unsigned 8-bit samples
< Signed 8-bit samples
< Unsigned 16-bit samples
< Signed 16-bit samples
< As above, but big-endian byte order
< As above, but big-endian byte order
Definition at line 260 of file soundmanager.cpp.
References Logger::log(), Logger::log1(), and logger.
Referenced by init().
void SoundManager::init | ( | ) |
Installs the sound engine.
< Signed 16-bit samples
< Signed 16-bit samples
Definition at line 127 of file soundmanager.cpp.
References Configuration::addListener(), config, Configuration::getBoolValue(), Configuration::getIntValue(), info(), Logger::log(), Logger::log1(), logger, mCacheSounds, mCurrentMusicFile, mFadeoutMusic, mInstalled, SDL::MixOpenAudio(), mMusicVolume, mPlayBattle, mPlayGui, mPlayMusic, mSfxVolume, playMusic(), and SkipError_true.
Referenced by Setup_Audio::apply(), changeAudio(), and Client::initSoundManager().
void SoundManager::logic | ( | ) |
The sound logic. Currently used to check whether the music file can be freed after a fade out, and whether new music has to be played.
Definition at line 434 of file soundmanager.cpp.
References BLOCK_END, BLOCK_START, Resource::decRef(), mMusic, mNextMusicFile, playMusic(), sFadingOutEnded, and SkipError_false.
Referenced by Client::gameExec().
|
virtual |
Called when an option changed. The config listener will have to be registered to the option name first.
Implements ConfigListener.
Definition at line 107 of file soundmanager.cpp.
References config, Configuration::getBoolValue(), Configuration::getIntValue(), mCacheSounds, mFadeoutMusic, mPlayBattle, mPlayGui, mPlayMusic, setChannels(), setMusicVolume(), and setSfxVolume().
void SoundManager::playGuiSfx | ( | const std::string & | path | ) |
Plays an item for gui.
path | The resource path to the sound file. |
Definition at line 505 of file soundmanager.cpp.
References Resource::decRef(), Loader::getSoundEffect(), ConfigurationObject::getValue(), Logger::log(), logger, mCacheSounds, mGuiChannel, mInstalled, mPlayGui, pathJoin(), paths, and SoundEffect::play().
Referenced by SetupItemSound::action(), playGuiSound(), and TestLauncher::testSound().
void SoundManager::playGuiSound | ( | const std::string & | name | ) |
Definition at line 496 of file soundmanager.cpp.
References branding, config, Configuration::getStringValue(), pathJoin(), and playGuiSfx().
Referenced by QuitDialog::action(), ChatTab::chatLog(), LocalPlayer::checkNewName(), ConfirmDialog::ConfirmDialog(), OkDialog::OkDialog(), ChatTab::playNewMessageSound(), ClanTab::playNewMessageSound(), EmulateGuildTab::playNewMessageSound(), GuildTab::playNewMessageSound(), PartyTab::playNewMessageSound(), NpcDialog::postInit(), QuitDialog::postInit(), ShopWindow::processRequest(), and Window::setVisible().
void SoundManager::playMusic | ( | const std::string & | fileName, |
const SkipError | skipError | ||
) |
Starts background music.
fileName | The name of the music file. |
Definition at line 352 of file soundmanager.cpp.
References fileName, haltMusic(), loadMusic(), mCurrentMusicFile, mInstalled, mMusic, mPlayMusic, and SDLMusic::play().
Referenced by Setup_Audio::apply(), init(), Client::initSoundManager(), logic(), Ea::PlayerRecv::processMapMusic(), and TestLauncher::testSound().
void SoundManager::playSfx | ( | const std::string & | path, |
const int | x, | ||
const int | y | ||
) | const |
Plays an item.
path | The resource path to the sound file. |
Definition at line 463 of file soundmanager.cpp.
References Resource::decRef(), Loader::getSoundEffect(), Configuration::getStringValue(), Being::getTileX(), Being::getTileY(), localPlayer, Logger::log(), logger, mCacheSounds, mInstalled, mPlayBattle, pathJoin(), paths, SoundEffect::play(), x, and y.
Referenced by Being::logic(), NotifyManager::notify(), StatusEffect::playSFX(), ItemSoundManager::playSfx(), Being::playSfx(), TestLauncher::testSound(), EffectManager::trigger(), and EffectManager::triggerReturn().
void SoundManager::setChannels | ( | const int | channels | ) | const |
Definition at line 587 of file soundmanager.cpp.
References mInstalled.
Referenced by optionChanged().
void SoundManager::setMusicVolume | ( | const int | volume | ) |
Definition at line 322 of file soundmanager.cpp.
References mInstalled, and mMusicVolume.
Referenced by Client::initSoundManager(), and optionChanged().
void SoundManager::setSfxVolume | ( | const int | volume | ) |
Definition at line 330 of file soundmanager.cpp.
References mInstalled, and mSfxVolume.
Referenced by Client::initSoundManager(), and optionChanged().
void SoundManager::shutdown | ( | ) |
Definition at line 97 of file soundmanager.cpp.
References CHECKLISTENERS, config, and Configuration::removeListeners().
Referenced by Client::gameClear().
void SoundManager::stopMusic | ( | ) |
Stops currently running background music track.
Definition at line 374 of file soundmanager.cpp.
References haltMusic().
Referenced by Setup_Audio::apply(), and TestLauncher::testSound().
void SoundManager::testAudio | ( | ) |
< Signed 16-bit samples
Definition at line 197 of file soundmanager.cpp.
References CAST_U8, config, Configuration::getBoolValue(), Configuration::getIntValue(), Logger::log(), logger, mCacheSounds, mFadeoutMusic, mMusicVolume, mPlayBattle, mPlayGui, mPlayMusic, and mSfxVolume.
void SoundManager::volumeOff | ( | ) | const |
Definition at line 569 of file soundmanager.cpp.
References mInstalled.
Referenced by GameModifiers::changeAwayMode().
void SoundManager::volumeRestore | ( | ) | const |
Definition at line 578 of file soundmanager.cpp.
References mInstalled, mMusicVolume, and mSfxVolume.
Referenced by GameModifiers::changeAwayMode(), and LocalPlayer::~LocalPlayer().
|
private |
Definition at line 174 of file soundmanager.h.
Referenced by init(), optionChanged(), playGuiSfx(), playSfx(), and testAudio().
|
private |
Definition at line 167 of file soundmanager.h.
Referenced by close(), fadeOutMusic(), getCurrentMusicFile(), haltMusic(), init(), and playMusic().
|
private |
Definition at line 173 of file soundmanager.h.
Referenced by fadeOutMusic(), init(), optionChanged(), and testAudio().
|
private |
Definition at line 169 of file soundmanager.h.
Referenced by playGuiSfx().
|
private |
Definition at line 162 of file soundmanager.h.
Referenced by changeAudio(), close(), fadeOutMusic(), init(), playGuiSfx(), playMusic(), playSfx(), setChannels(), setMusicVolume(), setSfxVolume(), volumeOff(), and volumeRestore().
|
private |
Definition at line 168 of file soundmanager.h.
Referenced by close(), fadeOutMusic(), haltMusic(), logic(), and playMusic().
|
private |
Definition at line 165 of file soundmanager.h.
Referenced by init(), setMusicVolume(), testAudio(), and volumeRestore().
|
private |
When calling fadeOutAndPlayMusic(), the music file below will then be played
Definition at line 160 of file soundmanager.h.
Referenced by fadeOutAndPlayMusic(), and logic().
|
private |
Definition at line 170 of file soundmanager.h.
Referenced by init(), optionChanged(), playSfx(), and testAudio().
|
private |
Definition at line 171 of file soundmanager.h.
Referenced by init(), optionChanged(), playGuiSfx(), and testAudio().
|
private |
Definition at line 172 of file soundmanager.h.
Referenced by fadeOutAndPlayMusic(), fadeOutMusic(), init(), optionChanged(), playMusic(), and testAudio().
|
private |
Definition at line 164 of file soundmanager.h.
Referenced by init(), setSfxVolume(), testAudio(), and volumeRestore().