ManaPlus
soundmanager.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2018 The ManaPlus Developers
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef SOUNDMANAGER_H
24 #define SOUNDMANAGER_H
25 
27 
29 
30 #include "localconsts.h"
31 
32 PRAGMA48(GCC diagnostic push)
33 PRAGMA48(GCC diagnostic ignored "-Wshadow")
34 #include <SDL_mixer.h>
35 PRAGMA48(GCC diagnostic pop)
36 
37 class SDLMusic;
38 
44 {
45  public:
46  SoundManager();
47 
49 
50  ~SoundManager() override final;
51 
52  void optionChanged(const std::string &value) override final;
53 
57  void init();
58 
59  void testAudio();
60 
64  void close();
65 
71  void playMusic(const std::string &fileName,
72  const SkipError skipError);
73 
77  void stopMusic();
78 
85 // void fadeInMusic(const std::string &fileName, const int ms = 1000);
86 
92  void fadeOutMusic(const int ms);
93 
100  void fadeOutAndPlayMusic(const std::string &fileName,
101  const int ms);
102 
104  { return MIX_MAX_VOLUME; }
105 
106  void setMusicVolume(const int volume);
107 
108  void setSfxVolume(const int volume);
109 
115  void playSfx(const std::string &path,
116  const int x,
117  const int y) const;
118 
124  void playGuiSfx(const std::string &path);
125 
126  void playGuiSound(const std::string &name);
127 
128  void changeAudio();
129 
130  void volumeOff() const;
131 
132  void volumeRestore() const;
133 
135  { return mCurrentMusicFile; }
136 
142  void logic();
143 
144  void shutdown();
145 
146  void setChannels(const int channels) const;
147 
148  private:
150  static void info();
151 
153  void haltMusic();
154 
159  std::string mNextMusicFile;
160 
162 
165 
166  std::string mCurrentMusicFile;
170  bool mPlayGui;
174 };
175 
177 
178 #endif // SOUNDMANAGER_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
SDLMusic * mMusic
Definition: soundmanager.h:167
std::string fileName
Definition: testmain.cpp:38
void playGuiSfx(const std::string &path)
void setChannels(const int channels) const
std::string mNextMusicFile
Definition: soundmanager.h:159
void volumeOff() const
#define A_WARN_UNUSED
Definition: localconsts.h:152
#define final
Definition: localconsts.h:45
#define constexpr
Definition: localconsts.h:47
void fadeOutMusic(const int ms)
std::string getCurrentMusicFile() const
Definition: soundmanager.h:134
void changeAudio()
static int getMaxVolume()
Definition: soundmanager.h:103
bool mFadeoutMusic
Definition: soundmanager.h:172
SoundManager soundManager
void setSfxVolume(const int volume)
#define PRAGMA48(str)
Definition: localconsts.h:190
void setMusicVolume(const int volume)
void playMusic(const std::string &fileName, const SkipError skipError)
static void info()
void optionChanged(const std::string &value)
std::string mCurrentMusicFile
Definition: soundmanager.h:166
void fadeOutAndPlayMusic(const std::string &fileName, const int ms)
void playSfx(const std::string &path, const int x, const int y) const
#define noexcept2
Definition: localconsts.h:49
void playGuiSound(const std::string &name)
void volumeRestore() const