raylib-cpp
C++ object-oriented wrapper library for raylib.
AudioDevice.hpp
1 #ifndef RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
2 #define RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
3 
4 #include "./raylib.hpp"
5 #include "./raylib-cpp-utils.hpp"
6 #include "./RaylibException.hpp"
7 
8 namespace raylib {
12 class AudioDevice {
13  public:
21  AudioDevice(bool lateInit = false) {
22  if (!lateInit) {
23  Init();
24  }
25  }
26 
31  Close();
32  }
33 
39  inline void Init() {
40  ::InitAudioDevice();
41  if (!IsReady()) {
42  throw RaylibException("Failed to initialize AudioDevice");
43  }
44  }
45 
49  inline void Close() {
50  ::CloseAudioDevice();
51  }
52 
56  inline bool IsReady() const {
57  return ::IsAudioDeviceReady();
58  }
59 
65  inline AudioDevice& SetVolume(float volume) {
66  ::SetMasterVolume(volume);
67  return *this;
68  }
69 };
70 } // namespace raylib
71 
73 
74 #endif // RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
Audio device management functions.
Definition: AudioDevice.hpp:12
void Close()
Close the audio device and context.
Definition: AudioDevice.hpp:49
bool IsReady() const
Check if audio device has been initialized successfully.
Definition: AudioDevice.hpp:56
void Init()
Initialize audio device and context.
Definition: AudioDevice.hpp:39
~AudioDevice()
Close the audio device and context.
Definition: AudioDevice.hpp:30
AudioDevice(bool lateInit=false)
Initialize audio device and context.
Definition: AudioDevice.hpp:21
AudioDevice & SetVolume(float volume)
Set master volume (listener).
Definition: AudioDevice.hpp:65
Exception used for most raylib-related exceptions.
All raylib-cpp classes and functions appear in the raylib namespace.
Definition: AudioDevice.hpp:8