raylib-cpp
C++ object-oriented wrapper library for raylib.
Sound.hpp
1 #ifndef RAYLIB_CPP_SOUND_HPP_
2 #define RAYLIB_CPP_SOUND_HPP_
3 
4 #include <string>
5 
6 #ifdef __cplusplus
7 extern "C"{
8 #endif
9 #include "raylib.h"
10 #ifdef __cplusplus
11 }
12 #endif
13 
14 #include "./raylib-cpp-utils.hpp"
15 
16 namespace raylib {
17  class Sound : public ::Sound {
18  public:
19  Sound(::Sound vec) {
20  set(vec);
21  };
22 
23  Sound(const std::string& fileName) {
24  set(LoadSound(fileName.c_str()));
25  };
26 
27  Sound(::Wave wave) {
28  set(LoadSoundFromWave(wave));
29  };
30 
31  ~Sound() {
32  Unload();
33  }
34 
35  inline void set(::Sound sound) {
36  sampleCount = sound.sampleCount;
37  stream = sound.stream;
38  }
39 
40  GETTERSETTER(unsigned int,SampleCount,sampleCount)
41  GETTERSETTER(::AudioStream,Stream,stream)
42 
43  Sound& operator=(const ::Sound& sound) {
44  set(sound);
45  return *this;
46  }
47 
48  Sound& operator=(const Sound& sound) {
49  set(sound);
50  return *this;
51  }
52 
53  inline Sound& Update(const void *data, int sampleCount) {
54  ::UpdateSound(*this, data, sampleCount);
55  return *this;
56  }
57 
58  inline void Unload() {
59  ::UnloadSound(*this);
60  }
61 
62  inline Sound& Play() {
63  ::PlaySound(*this);
64  return *this;
65  }
66 
67  inline Sound& Stop() {
68  ::StopSound(*this);
69  return *this;
70  }
71  inline Sound& Pause() {
72  ::PauseSound(*this);
73  return *this;
74  }
75  inline Sound& Resume() {
76  ::ResumeSound(*this);
77  return *this;
78  }
79 
80  inline Sound& PlayMulti() {
81  ::PlaySoundMulti(*this);
82  return *this;
83  }
84 
85  inline Sound& StopMulti() {
86  ::StopSoundMulti();
87  return *this;
88  }
89 
90  inline bool IsPlaying() {
91  return ::IsSoundPlaying(*this);
92  }
93  inline Sound& SetVolume(float volume) {
94  ::SetSoundVolume(*this, volume);
95  return *this;
96  }
97  inline Sound& SetPitch(float pitch) {
98  ::SetSoundPitch(*this, pitch);
99  return *this;
100  }
101 
102  };
103 }
104 
105 #endif
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:14
raylib::Sound::IsPlaying
bool IsPlaying()
Definition: Sound.hpp:90
raylib::Wave
Definition: Wave.hpp:15
raylib::Sound::~Sound
~Sound()
Definition: Sound.hpp:31
raylib::Sound::Update
Sound & Update(const void *data, int sampleCount)
Definition: Sound.hpp:53
raylib::Sound::Sound
Sound(::Sound vec)
Definition: Sound.hpp:19
raylib::Sound::StopMulti
Sound & StopMulti()
Definition: Sound.hpp:85
raylib::Sound::SetVolume
Sound & SetVolume(float volume)
Definition: Sound.hpp:93
raylib::Sound
Definition: Sound.hpp:17
raylib::Sound::Pause
Sound & Pause()
Definition: Sound.hpp:71
raylib::Sound::Sound
Sound(::Wave wave)
Definition: Sound.hpp:27
raylib::Sound::operator=
Sound & operator=(const Sound &sound)
Definition: Sound.hpp:48
raylib::Sound::set
void set(::Sound sound)
Definition: Sound.hpp:35
raylib::Sound::Resume
Sound & Resume()
Definition: Sound.hpp:75
raylib::Sound::Stop
Sound & Stop()
Definition: Sound.hpp:67
raylib::Sound::Unload
void Unload()
Definition: Sound.hpp:58
raylib::AudioStream
AudioStream management functions.
Definition: AudioStream.hpp:18
raylib::Sound::SetPitch
Sound & SetPitch(float pitch)
Definition: Sound.hpp:97
raylib::Sound::Play
Sound & Play()
Definition: Sound.hpp:62
raylib::Sound::PlayMulti
Sound & PlayMulti()
Definition: Sound.hpp:80
raylib::Sound::Sound
Sound(const std::string &fileName)
Definition: Sound.hpp:23