Bomberman
Sound.hpp
Go to the documentation of this file.
1 /*
2 ** EPITECH PROJECT, 2021
3 ** Bomberman
4 ** File description:
5 ** Sound
6 */
7 
8 #ifndef SOUND_HPP_
9 #define SOUND_HPP_
10 
11 #include "Audio/IAudio.hpp"
12 #include "Utils/Cache.hpp"
13 #include <raylib.h>
14 
15 
16 namespace RAY::Audio
17 {
19  class Sound: public IAudio {
20  public:
21 
24  Sound(const std::string &path, bool lonely = false);
25 
27  ~Sound() = default;
28 
30  Sound(const Sound &sound) = default;
31 
33  Sound &operator=(const Sound &sound) = default;
34 
36  bool isPlaying(void) override;
37 
39  Sound &play(void) override;
40 
42  Sound &stop(void) override;
43 
45  Sound &pause(void) override;
46 
48  Sound &resume(void) override;
49 
51  Sound &setVolume(float volume) override;
52 
53  // Set pitch for a Sound (1.0 is base level)
54  Sound &setPitch(float pitch) override;
55 
56  private:
57  std::shared_ptr<::Sound> _sound;
58 
60  };
61 }
62 
63 #endif /* !Sound_HPP_ */
RAY::Audio::Sound::operator=
Sound & operator=(const Sound &sound)=default
A Sound is assignable.
Cache.hpp
RAY::Audio::IAudio
Interface for Audio ressources.
Definition: IAudio.hpp:15
RAY::Audio::Sound::~Sound
~Sound()=default
Default destructor.
RAY::Audio::Sound::setVolume
Sound & setVolume(float volume) override
Set volume for Sound (1.0 is max level)
Definition: Sound.cpp:47
RAY::Audio::Sound::pause
Sound & pause(void) override
Pause Sound playing.
Definition: Sound.cpp:35
RAY::Audio::Sound::_soundsCache
static RAY::Cache<::Sound > _soundsCache
Definition: Sound.hpp:59
RAY::Audio::Sound
A manager for sound stream.
Definition: Sound.hpp:19
RAY::Audio::Sound::Sound
Sound(const std::string &path, bool lonely=false)
Load Sound stream from file.
Definition: Sound.cpp:12
RAY::Audio::Sound::stop
Sound & stop(void) override
Stop Sound playing.
Definition: Sound.cpp:29
RAY::Audio::Sound::resume
Sound & resume(void) override
Resume playing paused Sound.
Definition: Sound.cpp:41
RAY::Audio::Sound::play
Sound & play(void) override
Start Sound.
Definition: Sound.cpp:23
RAY::Audio::Sound::isPlaying
bool isPlaying(void) override
Check if Sound is playing.
Definition: Sound.cpp:18
RAY::Audio::Sound::setPitch
Sound & setPitch(float pitch) override
Definition: Sound.cpp:53
RAY::Audio
Definition: IAudio.hpp:12
RAY::Cache
A templated class used to cache ressources, indexed with a string.
Definition: Cache.hpp:23
IAudio.hpp
RAY::Audio::Sound::_sound
std::shared_ptr<::Sound > _sound
Definition: Sound.hpp:57