blob: fee871fcc0f82a9fa340056dd24ae6bd84328bf0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// Copyright (c) 2013-2020 Vittorio Romeo
// License: Academic Free License ("AFL") v. 3.0
// AFL License page: https://opensource.org/licenses/AFL-3.0
#pragma once
#include "SSVOpenHexagon/Utils/UniquePtr.hpp"
#include <string>
#include <functional>
namespace sf {
class SoundBuffer;
}
namespace hg {
class Audio
{
public:
using SoundBufferGetter =
std::function<sf::SoundBuffer*(const std::string&)>;
using MusicPathGetter =
std::function<const std::string*(const std::string&)>;
private:
class AudioImpl;
Utils::UniquePtr<AudioImpl> _impl;
[[nodiscard]] const AudioImpl& impl() const noexcept;
[[nodiscard]] AudioImpl& impl() noexcept;
public:
explicit Audio(const SoundBufferGetter& soundBufferGetter,
const MusicPathGetter& musicPathGetter);
~Audio();
void setSoundVolume(const float volume);
void setMusicVolume(const float volume);
void resumeMusic();
void pauseMusic();
void stopMusic();
void stopSounds();
void playSoundOverride(const std::string& id);
void playPackSoundOverride(
const std::string& packId, const std::string& id);
void playSoundAbort(const std::string& id);
void playPackSoundAbort(const std::string& packId, const std::string& id);
[[nodiscard]] bool loadAndPlayMusic(const std::string& packId,
const std::string& id, const float playingOffsetSeconds);
void setCurrentMusicPitch(const float pitch);
};
} // namespace hg
|