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-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef SOUNDMANAGER_H
25 #define SOUNDMANAGER_H
26 
28 
30 
31 #include "localconsts.h"
32 
33 PRAGMA48(GCC diagnostic push)
34 PRAGMA48(GCC diagnostic ignored "-Wshadow")
35 #include <SDL_mixer.h>
36 PRAGMA48(GCC diagnostic pop)
37 
38 class SDLMusic;
39 
45 {
46  public:
47  SoundManager();
48 
50 
51  ~SoundManager() override final;
52 
53  void optionChanged(const std::string &value) override final;
54 
58  void init();
59 
60  void testAudio();
61 
65  void close();
66 
72  void playMusic(const std::string &fileName,
73  const SkipError skipError);
74 
78  void stopMusic();
79 
86 // void fadeInMusic(const std::string &fileName, const int ms = 1000);
87 
93  void fadeOutMusic(const int ms);
94 
101  void fadeOutAndPlayMusic(const std::string &fileName,
102  const int ms);
103 
105  { return MIX_MAX_VOLUME; }
106 
107  void setMusicVolume(const int volume);
108 
109  void setSfxVolume(const int volume);
110 
116  void playSfx(const std::string &path,
117  const int x,
118  const int y) const;
119 
125  void playGuiSfx(const std::string &path);
126 
127  void playGuiSound(const std::string &name);
128 
129  void changeAudio();
130 
131  void volumeOff() const;
132 
133  void volumeRestore() const;
134 
136  { return mCurrentMusicFile; }
137 
143  void logic();
144 
145  void shutdown();
146 
147  void setChannels(const int channels) const;
148 
149  private:
151  static void info();
152 
154  void haltMusic();
155 
160  std::string mNextMusicFile;
161 
163 
166 
167  std::string mCurrentMusicFile;
171  bool mPlayGui;
175 };
176 
178 
179 #endif // SOUNDMANAGER_H
static int getMaxVolume()
Definition: soundmanager.h:104
std::string getCurrentMusicFile() const
Definition: soundmanager.h:135
SDLMusic * mMusic
Definition: soundmanager.h:168
bool mFadeoutMusic
Definition: soundmanager.h:173
std::string mCurrentMusicFile
Definition: soundmanager.h:167
void optionChanged(const std::string &value)
void fadeOutAndPlayMusic(const std::string &fileName, const int ms)
void playGuiSound(const std::string &name)
void playGuiSfx(const std::string &path)
void setChannels(const int channels) const
void volumeOff() const
void playSfx(const std::string &path, const int x, const int y) const
void playMusic(const std::string &fileName, const SkipError skipError)
void volumeRestore() const
void changeAudio()
std::string mNextMusicFile
Definition: soundmanager.h:160
static void info()
void fadeOutMusic(const int ms)
void setSfxVolume(const int volume)
void setMusicVolume(const int volume)
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define constexpr
Definition: localconsts.h:48
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define PRAGMA48(str)
Definition: localconsts.h:199
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
bool SkipError
Definition: skiperror.h:30
SoundManager soundManager
std::string fileName
Definition: testmain.cpp:39