raylib-cpp
C++ object-oriented wrapper library for raylib.
Loading...
Searching...
No Matches
AudioDevice.hpp
1#ifndef RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
2#define RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
3
4#include "./RaylibException.hpp"
5#include "./raylib-cpp-utils.hpp"
6#include "./raylib.hpp"
7
8namespace raylib {
13public:
21 explicit AudioDevice(bool lateInit = false) {
22 if (!lateInit) {
23 Init();
24 }
25 }
26
31
37 static void Init() {
38 ::InitAudioDevice();
39 if (!IsReady()) {
40 throw RaylibException("Failed to initialize AudioDevice");
41 }
42 }
43
47 static void Close() { ::CloseAudioDevice(); }
48
52 static bool IsReady() { return ::IsAudioDeviceReady(); }
53
59 AudioDevice& SetVolume(float volume) {
60 ::SetMasterVolume(volume);
61 return *this;
62 }
63};
64} // namespace raylib
65
67
68#endif // RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
Audio device management functions.
Definition: AudioDevice.hpp:12
static void Close()
Close the audio device and context.
Definition: AudioDevice.hpp:47
AudioDevice & SetVolume(float volume)
Set master volume (listener).
Definition: AudioDevice.hpp:59
~AudioDevice()
Close the audio device and context.
Definition: AudioDevice.hpp:30
static bool IsReady()
Check if audio device has been initialized successfully.
Definition: AudioDevice.hpp:52
AudioDevice(bool lateInit=false)
Initialize audio device and context.
Definition: AudioDevice.hpp:21
static void Init()
Initialize audio device and context.
Definition: AudioDevice.hpp:37
Exception used for most raylib-related exceptions.
All raylib-cpp classes and functions appear in the raylib namespace.
Definition: AudioDevice.hpp:8