ManaPlus
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
SoundManager Class Reference

#include <soundmanager.h>

Inheritance diagram for SoundManager:
ConfigListener

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
 
SDLMusicmMusic
 
int mGuiChannel
 
bool mPlayBattle
 
bool mPlayGui
 
bool mPlayMusic
 
bool mFadeoutMusic
 
bool mCacheSounds
 

Detailed Description

SoundManager

Definition at line 44 of file soundmanager.h.

Constructor & Destructor Documentation

◆ SoundManager()

SoundManager::SoundManager ( )

Definition at line 72 of file soundmanager.cpp.

72  :
75  mInstalled(false),
76  mSfxVolume(100),
77  mMusicVolume(60),
79  mMusic(nullptr),
80  mGuiChannel(-1),
81  mPlayBattle(false),
82  mPlayGui(false),
83  mPlayMusic(false),
84  mFadeoutMusic(true),
85  mCacheSounds(true)
86 {
87  // This set up our callback function used to
88  // handle fade outs endings.
89  sFadingOutEnded = false;
90  Mix_HookMusicFinished(&fadeOutCallBack);
91 }
SDLMusic * mMusic
Definition: soundmanager.h:168
bool mFadeoutMusic
Definition: soundmanager.h:173
std::string mCurrentMusicFile
Definition: soundmanager.h:167
std::string mNextMusicFile
Definition: soundmanager.h:160
static void fadeOutCallBack()
static bool sFadingOutEnded

References fadeOutCallBack(), and sFadingOutEnded.

◆ ~SoundManager()

SoundManager::~SoundManager ( )

Definition at line 93 of file soundmanager.cpp.

94 {
95 }

Member Function Documentation

◆ changeAudio()

void SoundManager::changeAudio ( )

Definition at line 561 of file soundmanager.cpp.

562 {
563  if (mInstalled)
564  close();
565  else
566  init();
567 }

References close(), init(), and mInstalled.

◆ close()

void SoundManager::close ( )

Removes all sound functionalities.

Definition at line 531 of file soundmanager.cpp.

532 {
533  if (!mInstalled)
534  return;
535 
536  if (mMusic != nullptr)
537  {
538  Mix_HaltMusic();
540  mMusic = nullptr;
541  mCurrentMusicFile.clear();
542  }
543 
544  logger->log1("SoundManager::close() Shutting down sound...");
545  Mix_CloseAudio();
546 
547  mInstalled = false;
548 }
void log1(const char *const log_text)
Definition: logger.cpp:238
Logger * logger
Definition: logger.cpp:89
void decRefDelete(Resource *const res)

References ResourceManager::decRefDelete(), Logger::log1(), logger, mCurrentMusicFile, mInstalled, and mMusic.

Referenced by Setup_Audio::apply(), changeAudio(), and Client::gameClear().

◆ fadeOutAndPlayMusic()

void SoundManager::fadeOutAndPlayMusic ( const std::string &  fileName,
const int  ms 
)

Fades out a background music and play a new one.

Parameters
fileNameThe name of the music file.
msDuration of fade-out effect (ms)

Definition at line 424 of file soundmanager.cpp.

426 {
427  if (!mPlayMusic)
428  return;
429 
431  fadeOutMusic(ms);
432 }
void fadeOutMusic(const int ms)
std::string fileName
Definition: testmain.cpp:39

References fadeOutMusic(), fileName, mNextMusicFile, and mPlayMusic.

Referenced by Game::changeMap(), and LocalPlayer::updateMusic().

◆ fadeOutMusic()

void SoundManager::fadeOutMusic ( const int  ms)

Fades in background music.

Parameters
fileNameThe name of the music file.
msDuration of fade-in effect (ms) Fades out currently running background music track.
msDuration of fade-out effect (ms)

Definition at line 398 of file soundmanager.cpp.

399 {
400  if (!mPlayMusic)
401  return;
402 
403  mCurrentMusicFile.clear();
404 
405  if (!mInstalled)
406  return;
407 
408  logger->log("SoundManager::fadeOutMusic() Fading-out (%i ms)", ms);
409 
410  if ((mMusic != nullptr) && mFadeoutMusic)
411  {
412  Mix_FadeOutMusic(ms);
413  // Note: The fadeOutCallBack handler will take care about freeing
414  // the music file at fade out ending.
415  }
416  else
417  {
418  sFadingOutEnded = true;
419  if (!mFadeoutMusic)
420  haltMusic();
421  }
422 }
void log(const char *const log_text,...)
Definition: logger.cpp:269

References haltMusic(), Logger::log(), logger, mCurrentMusicFile, mFadeoutMusic, mInstalled, mMusic, mPlayMusic, and sFadingOutEnded.

Referenced by Game::changeMap(), fadeOutAndPlayMusic(), and LocalPlayer::updateMusic().

◆ getCurrentMusicFile()

std::string SoundManager::getCurrentMusicFile ( ) const
inline

Definition at line 135 of file soundmanager.h.

136  { return mCurrentMusicFile; }

References mCurrentMusicFile.

Referenced by LocalPlayer::updateMusic().

◆ getMaxVolume()

static int SoundManager::getMaxVolume ( )
inlinestatic

Definition at line 104 of file soundmanager.h.

105  { return MIX_MAX_VOLUME; }

Referenced by Setup_Audio::Setup_Audio().

◆ haltMusic()

void SoundManager::haltMusic ( )
private

Halts and frees currently playing music.

Definition at line 550 of file soundmanager.cpp.

551 {
552  if (mMusic == nullptr)
553  return;
554 
555  Mix_HaltMusic();
556  mMusic->decRef();
557  mMusic = nullptr;
558  mCurrentMusicFile.clear();
559 }
virtual void decRef()
Definition: resource.cpp:50

References Resource::decRef(), mCurrentMusicFile, and mMusic.

Referenced by fadeOutMusic(), playMusic(), and stopMusic().

◆ info()

void SoundManager::info ( )
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.

261 {
262  SDL_version compiledVersion;
263  const char *format = "Unknown";
264  int rate = 0;
265  uint16_t audioFormat = 0;
266  int channels = 0;
267 
268  MIX_VERSION(&compiledVersion)
269  const SDL_version *const linkedVersion = Mix_Linked_Version();
270 
271 #ifdef USE_SDL2
272  const char *driver = SDL_GetCurrentAudioDriver();
273 #else // USE_SDL2
274  char driver[40] = "Unknown";
275  SDL_AudioDriverName(driver, 40);
276 #endif // USE_SDL2
277 
278  Mix_QuerySpec(&rate, &audioFormat, &channels);
279  switch (audioFormat)
280  {
281  case AUDIO_U8:
282  format = "U8";
283  break;
284  case AUDIO_S8:
285  format = "S8"; break;
286  case AUDIO_U16LSB:
287  format = "U16LSB";
288  break;
289  case AUDIO_S16LSB:
290  format = "S16LSB";
291  break;
292  case AUDIO_U16MSB:
293  format = "U16MSB";
294  break;
295  case AUDIO_S16MSB:
296  format = "S16MSB";
297  break;
298  default: break;
299  }
300 
301  logger->log("SoundManager::info() SDL_mixer: %i.%i.%i (compiled)",
302  compiledVersion.major,
303  compiledVersion.minor,
304  compiledVersion.patch);
305  if (linkedVersion != nullptr)
306  {
307  logger->log("SoundManager::info() SDL_mixer: %i.%i.%i (linked)",
308  linkedVersion->major,
309  linkedVersion->minor,
310  linkedVersion->patch);
311  }
312  else
313  {
314  logger->log1("SoundManager::info() SDL_mixer: unknown");
315  }
316  logger->log("SoundManager::info() Driver: %s", driver);
317  logger->log("SoundManager::info() Format: %s", format);
318  logger->log("SoundManager::info() Rate: %i", rate);
319  logger->log("SoundManager::info() Channels: %i", channels);
320 }

References Logger::log(), Logger::log1(), and logger.

Referenced by init().

◆ init()

void SoundManager::init ( )

Installs the sound engine.

< Signed 16-bit samples

< Signed 16-bit samples

Definition at line 127 of file soundmanager.cpp.

128 {
129  // Don't initialize sound engine twice
130  if (mInstalled)
131  return;
132 
133  logger->log1("SoundManager::init() Initializing sound...");
134 
135  mPlayBattle = config.getBoolValue("playBattleSound");
136  mPlayGui = config.getBoolValue("playGuiSound");
137  mPlayMusic = config.getBoolValue("playMusic");
138  mFadeoutMusic = config.getBoolValue("fadeoutmusic");
139  mMusicVolume = config.getIntValue("musicVolume");
140  mSfxVolume = config.getIntValue("sfxVolume");
141  mCacheSounds = (config.getIntValue("uselonglivesounds") != 0);
142 
143  config.addListener("playBattleSound", this);
144  config.addListener("playGuiSound", this);
145  config.addListener("playMusic", this);
146  config.addListener("sfxVolume", this);
147  config.addListener("musicVolume", this);
148  config.addListener("fadeoutmusic", this);
149  config.addListener("uselonglivesounds", this);
150  config.addListener("parallelAudioChannels", this);
151 
152  if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1)
153  {
154  logger->log1("SoundManager::init() Failed to "
155  "initialize audio subsystem");
156  return;
157  }
158 
159  const size_t audioBuffer = 4096;
160  int channels = config.getIntValue("audioChannels");
161  switch (channels)
162  {
163  case 3:
164  channels = 4;
165  break;
166  case 4:
167  channels = 6;
168  break;
169  default:
170  break;
171  }
172 
173  const int res = SDL::MixOpenAudio(config.getIntValue("audioFrequency"),
174  MIX_DEFAULT_FORMAT, channels, audioBuffer);
175 
176  if (res < 0)
177  {
178  logger->log("SoundManager::init Could not initialize audio: %s",
179  SDL_GetError());
180  if (SDL::MixOpenAudio(22010, MIX_DEFAULT_FORMAT, 2, audioBuffer) < 0)
181  return;
182  logger->log("Fallback to stereo audio");
183  }
184 
185  Mix_AllocateChannels(config.getIntValue("parallelAudioChannels"));
186  Mix_VolumeMusic(mMusicVolume);
187  Mix_Volume(-1, mSfxVolume);
188 
189  info();
190 
191  mInstalled = true;
192 
193  if (!mCurrentMusicFile.empty() && mPlayMusic)
195 }
bool getBoolValue(const std::string &key) const
void addListener(const std::string &key, ConfigListener *const listener)
int getIntValue(const std::string &key) const
void playMusic(const std::string &fileName, const SkipError skipError)
static void info()
Configuration config
int MixOpenAudio(const int frequency, const uint16_t format, const int nchannels, const int chunksize)
const bool SkipError_true
Definition: skiperror.h:30

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().

◆ logic()

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.

435 {
436  BLOCK_START("SoundManager::logic")
438  {
439  if (mMusic != nullptr)
440  {
441  mMusic->decRef();
442  mMusic = nullptr;
443  }
444  sFadingOutEnded = false;
445 
446  if (!mNextMusicFile.empty())
447  {
450  mNextMusicFile.clear();
451  }
452  }
453  BLOCK_END("SoundManager::logic")
454 }
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79
const bool SkipError_false
Definition: skiperror.h:30

References BLOCK_END, BLOCK_START, Resource::decRef(), mMusic, mNextMusicFile, playMusic(), sFadingOutEnded, and SkipError_false.

Referenced by Client::gameExec().

◆ optionChanged()

void SoundManager::optionChanged ( const std::string &  name)
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.

108 {
109  if (value == "playBattleSound")
110  mPlayBattle = config.getBoolValue("playBattleSound");
111  else if (value == "playGuiSound")
112  mPlayGui = config.getBoolValue("playGuiSound");
113  else if (value == "playMusic")
114  mPlayMusic = config.getBoolValue("playMusic");
115  else if (value == "sfxVolume")
116  setSfxVolume(config.getIntValue("sfxVolume"));
117  else if (value == "musicVolume")
118  setMusicVolume(config.getIntValue("musicVolume"));
119  else if (value == "fadeoutmusic")
120  mFadeoutMusic = (config.getIntValue("fadeoutmusic") != 0);
121  else if (value == "uselonglivesounds")
122  mCacheSounds = (config.getIntValue("uselonglivesounds") != 0);
123  else if (value == "parallelAudioChannels")
124  setChannels(config.getIntValue("parallelAudioChannels"));
125 }
void setChannels(const int channels) const
void setSfxVolume(const int volume)
void setMusicVolume(const int volume)

References config, Configuration::getBoolValue(), Configuration::getIntValue(), mCacheSounds, mFadeoutMusic, mPlayBattle, mPlayGui, mPlayMusic, setChannels(), setMusicVolume(), and setSfxVolume().

◆ playGuiSfx()

void SoundManager::playGuiSfx ( const std::string &  path)

Plays an item for gui.

Parameters
pathThe resource path to the sound file.

Definition at line 505 of file soundmanager.cpp.

506 {
507  if (!mInstalled ||
508  !mPlayGui ||
509  path.empty())
510  {
511  return;
512  }
513 
514  std::string tmpPath;
515  if (path.compare(0, 4, "sfx/") == 0)
516  tmpPath = path;
517  else
518  tmpPath = pathJoin(paths.getValue("sfx", "sfx"), path);
519  SoundEffect *const sample = Loader::getSoundEffect(tmpPath);
520  if (sample != nullptr)
521  {
522  logger->log("SoundManager::playGuiSfx() Playing: %s", path.c_str());
523  const int ret = static_cast<int>(sample->play(0, 120, mGuiChannel));
524  if (ret != -1)
525  mGuiChannel = ret;
526  if (!mCacheSounds)
527  sample->decRef();
528  }
529 }
std::string getValue(const std::string &key, const std::string &deflt) const
bool play(const int loops, const int volume, const int channel) const
Definition: soundeffect.cpp:33
Configuration paths
SoundEffect * getSoundEffect(const std::string &idPath)
Definition: soundloader.cpp:71
std::string pathJoin(std::string str1, const std::string &str2)

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().

◆ playGuiSound()

void SoundManager::playGuiSound ( const std::string &  name)

Definition at line 496 of file soundmanager.cpp.

497 {
498  const std::string sound = config.getStringValue(name);
499  if (sound == "(no sound)")
500  return;
501  playGuiSfx(pathJoin(branding.getStringValue("systemsounds"),
502  std::string(sound).append(".ogg")));
503 }
std::string getStringValue(const std::string &key) const
void playGuiSfx(const std::string &path)
Configuration branding

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().

◆ playMusic()

void SoundManager::playMusic ( const std::string &  fileName,
const SkipError  skipError 
)

Starts background music.

Parameters
fileNameThe name of the music file.

Definition at line 352 of file soundmanager.cpp.

354 {
355  if (!mInstalled || !mPlayMusic)
356  return;
357 
359  return;
360 
362 
363  haltMusic();
364 
365  if (!fileName.empty())
366  {
368  skipError);
369  if (mMusic != nullptr)
370  mMusic->play(-1, 0);
371  }
372 }
bool play(const int loops, const int fadeIn) const
Definition: sdlmusic.cpp:64
static SDLMusic * loadMusic(const std::string &fileName, const SkipError skipError)

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().

◆ playSfx()

void SoundManager::playSfx ( const std::string &  path,
const int  x,
const int  y 
) const

Plays an item.

Parameters
pathThe resource path to the sound file.

Definition at line 463 of file soundmanager.cpp.

465 {
466  if (!mInstalled || path.empty() || !mPlayBattle)
467  return;
468 
469  std::string tmpPath = pathJoin(paths.getStringValue("sfx"), path);
470  SoundEffect *const sample = Loader::getSoundEffect(tmpPath);
471  if (sample != nullptr)
472  {
473  logger->log("SoundManager::playSfx() Playing: %s", path.c_str());
474  int vol = 120;
475  if ((localPlayer != nullptr) && (x > 0 || y > 0))
476  {
477  int dx = localPlayer->getTileX() - x;
478  int dy = localPlayer->getTileY() - y;
479  if (dx < 0)
480  dx = -dx;
481  if (dy < 0)
482  dy = -dy;
483  const int dist = dx > dy ? dx : dy;
484  if (dist * 8 > vol)
485  return;
486 
487  vol -= dist * 8;
488  }
489  sample->play(0, vol, -1);
490  if (!mCacheSounds)
491  sample->decRef();
492  }
493 }
int getTileX() const
Definition: being.h:168
int getTileY() const
Definition: being.h:174
LocalPlayer * localPlayer

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().

◆ setChannels()

void SoundManager::setChannels ( const int  channels) const

Definition at line 587 of file soundmanager.cpp.

588 {
589  if (mInstalled)
590  Mix_AllocateChannels(channels);
591 }

References mInstalled.

Referenced by optionChanged().

◆ setMusicVolume()

void SoundManager::setMusicVolume ( const int  volume)

Definition at line 322 of file soundmanager.cpp.

323 {
324  mMusicVolume = volume;
325 
326  if (mInstalled)
327  Mix_VolumeMusic(mMusicVolume);
328 }

References mInstalled, and mMusicVolume.

Referenced by Client::initSoundManager(), and optionChanged().

◆ setSfxVolume()

void SoundManager::setSfxVolume ( const int  volume)

Definition at line 330 of file soundmanager.cpp.

331 {
332  mSfxVolume = volume;
333 
334  if (mInstalled)
335  Mix_Volume(-1, mSfxVolume);
336 }

References mInstalled, and mSfxVolume.

Referenced by Client::initSoundManager(), and optionChanged().

◆ shutdown()

void SoundManager::shutdown ( )

Definition at line 97 of file soundmanager.cpp.

98 {
99  config.removeListeners(this);
100 
101  // Unlink the callback function.
102  Mix_HookMusicFinished(nullptr);
103 
105 }
void removeListeners(ConfigListener *const listener)
#define CHECKLISTENERS
Definition: localconsts.h:277

References CHECKLISTENERS, config, and Configuration::removeListeners().

Referenced by Client::gameClear().

◆ stopMusic()

void SoundManager::stopMusic ( )

Stops currently running background music track.

Definition at line 374 of file soundmanager.cpp.

375 {
376  haltMusic();
377 }

References haltMusic().

Referenced by Setup_Audio::apply(), and TestLauncher::testSound().

◆ testAudio()

void SoundManager::testAudio ( )

< Signed 16-bit samples

Definition at line 197 of file soundmanager.cpp.

198 {
199  mPlayBattle = config.getBoolValue("playBattleSound");
200  mPlayGui = config.getBoolValue("playGuiSound");
201  mPlayMusic = config.getBoolValue("playMusic");
202  mFadeoutMusic = config.getBoolValue("fadeoutmusic");
203  mMusicVolume = config.getIntValue("musicVolume");
204  mSfxVolume = config.getIntValue("sfxVolume");
205  mCacheSounds = (config.getIntValue("uselonglivesounds") != 0);
206 
207  const size_t audioBuffer = 4096;
208  int channels = config.getIntValue("audioChannels");
209  switch (channels)
210  {
211  case 3:
212  channels = 4;
213  break;
214  case 4:
215  channels = 6;
216  break;
217  default:
218  break;
219  }
220 
221  SDL_AudioSpec desired;
222  SDL_AudioSpec actual;
223 
224  desired.freq = config.getIntValue("audioFrequency");
225  desired.format = MIX_DEFAULT_FORMAT;
226  desired.channels = CAST_U8(channels);
227  desired.samples = audioBuffer;
228  desired.callback = nullptr;
229  desired.userdata = nullptr;
230 
231  if (SDL_OpenAudio(&desired, &actual) < 0)
232  {
233  logger->log("SoundManager::testAudio error: %s",
234  SDL_GetError());
235  return;
236  }
237  if (desired.freq != actual.freq)
238  {
239  logger->log("SoundManager::testAudio frequence: %d -> %d",
240  actual.freq, desired.freq);
241  }
242  if (desired.format != actual.format)
243  {
244  logger->log("SoundManager::testAudio format: %d -> %d",
245  actual.format, desired.format);
246  }
247  if (desired.channels != actual.channels)
248  {
249  logger->log("SoundManager::testAudio channels: %d -> %d",
250  actual.channels, desired.channels);
251  }
252  if (desired.samples != actual.samples)
253  {
254  logger->log("SoundManager::testAudio samples: %d -> %d",
255  actual.samples, desired.samples);
256  }
257  SDL_CloseAudio();
258 }
#define CAST_U8
Definition: cast.h:27

References CAST_U8, config, Configuration::getBoolValue(), Configuration::getIntValue(), Logger::log(), logger, mCacheSounds, mFadeoutMusic, mMusicVolume, mPlayBattle, mPlayGui, mPlayMusic, and mSfxVolume.

◆ volumeOff()

void SoundManager::volumeOff ( ) const

Definition at line 569 of file soundmanager.cpp.

570 {
571  if (mInstalled)
572  {
573  Mix_VolumeMusic(0);
574  Mix_Volume(-1, 0);
575  }
576 }

References mInstalled.

Referenced by GameModifiers::changeAwayMode().

◆ volumeRestore()

void SoundManager::volumeRestore ( ) const

Definition at line 578 of file soundmanager.cpp.

579 {
580  if (mInstalled)
581  {
582  Mix_VolumeMusic(mMusicVolume);
583  Mix_Volume(-1, mSfxVolume);
584  }
585 }

References mInstalled, mMusicVolume, and mSfxVolume.

Referenced by GameModifiers::changeAwayMode(), and LocalPlayer::~LocalPlayer().

Field Documentation

◆ mCacheSounds

bool SoundManager::mCacheSounds
private

Definition at line 174 of file soundmanager.h.

Referenced by init(), optionChanged(), playGuiSfx(), playSfx(), and testAudio().

◆ mCurrentMusicFile

std::string SoundManager::mCurrentMusicFile
private

Definition at line 167 of file soundmanager.h.

Referenced by close(), fadeOutMusic(), getCurrentMusicFile(), haltMusic(), init(), and playMusic().

◆ mFadeoutMusic

bool SoundManager::mFadeoutMusic
private

Definition at line 173 of file soundmanager.h.

Referenced by fadeOutMusic(), init(), optionChanged(), and testAudio().

◆ mGuiChannel

int SoundManager::mGuiChannel
private

Definition at line 169 of file soundmanager.h.

Referenced by playGuiSfx().

◆ mInstalled

bool SoundManager::mInstalled
private

◆ mMusic

SDLMusic* SoundManager::mMusic
private

Definition at line 168 of file soundmanager.h.

Referenced by close(), fadeOutMusic(), haltMusic(), logic(), and playMusic().

◆ mMusicVolume

int SoundManager::mMusicVolume
private

Definition at line 165 of file soundmanager.h.

Referenced by init(), setMusicVolume(), testAudio(), and volumeRestore().

◆ mNextMusicFile

std::string SoundManager::mNextMusicFile
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().

◆ mPlayBattle

bool SoundManager::mPlayBattle
private

Definition at line 170 of file soundmanager.h.

Referenced by init(), optionChanged(), playSfx(), and testAudio().

◆ mPlayGui

bool SoundManager::mPlayGui
private

Definition at line 171 of file soundmanager.h.

Referenced by init(), optionChanged(), playGuiSfx(), and testAudio().

◆ mPlayMusic

bool SoundManager::mPlayMusic
private

◆ mSfxVolume

int SoundManager::mSfxVolume
private

Definition at line 164 of file soundmanager.h.

Referenced by init(), setSfxVolume(), testAudio(), and volumeRestore().


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