SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
Sound.h
1#pragma once
2
3#include "spark/audio/Export.h"
4
5#include "SFML/Audio/Sound.hpp"
6#include "SFML/Audio/SoundBuffer.hpp"
7
8#include <filesystem>
9
10namespace spark::audio
11{
15 class SPARK_AUDIO_EXPORT Sound final
16 {
17 public:
18 static const std::vector<std::string_view> supportedExtensions;
19
20 public:
21 explicit Sound();
22
27 explicit Sound(const std::filesystem::path& file);
28 ~Sound();
29
30 Sound(const Sound& other);
31 Sound(Sound&& other) noexcept;
32 Sound& operator=(const Sound& other);
33 Sound& operator=(Sound&& other) noexcept;
34
38 void play();
39
43 void pause();
44
48 void stop();
49
53 void restart();
54
59 [[nodiscard]] bool loop() const;
60
65 [[nodiscard]] float volume() const;
66
71 [[nodiscard]] float pitch() const;
72
77 [[nodiscard]] bool isPlaying() const;
78
83 void setLoop(bool loop);
84
89 void setVolume(float volume);
90
95 void setPitch(float pitch);
96
97 private:
98 sf::SoundBuffer m_buffer;
99 sf::Sound m_sound;
100 };
101}
A class representing a sound that can be played.
Definition Sound.h:16