raylib-cpp
C++ object-oriented wrapper library for raylib.
AudioDevice.hpp
1 /*
2 * LICENSE: zlib/libpng
3 *
4 * raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
5 * BSD-like license that allows static linking with closed source software:
6 *
7 * Copyright (c) 2020 Rob Loach (@RobLoach)
8 *
9 * This software is provided "as-is", without any express or implied warranty. In no event
10 * will the authors be held liable for any damages arising from the use of this software.
11 *
12 * Permission is granted to anyone to use this software for any purpose, including commercial
13 * applications, and to alter it and redistribute it freely, subject to the following restrictions:
14 *
15 * 1. The origin of this software must not be misrepresented; you must not claim that you
16 * wrote the original software. If you use this software in a product, an acknowledgment
17 * in the product documentation would be appreciated but is not required.
18 *
19 * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
20 * as being the original software.
21 *
22 * 3. This notice may not be removed or altered from any source distribution.
23 */
24 
25 #ifndef RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
26 #define RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
27 
28 #include "./raylib.hpp"
29 #include "./raylib-cpp-utils.hpp"
30 
31 namespace raylib {
35 class AudioDevice {
36  public:
42  AudioDevice(bool lateInit = false) {
43  if (!lateInit) {
44  Init();
45  }
46  }
47 
52  Close();
53  }
54 
58  inline AudioDevice& Init() {
59  ::InitAudioDevice();
60  return *this;
61  }
62 
66  inline AudioDevice& Close() {
67  ::CloseAudioDevice();
68  return *this;
69  }
70 
74  inline bool IsReady() const {
75  return ::IsAudioDeviceReady();
76  }
77 
81  inline AudioDevice& SetVolume(float volume) {
82  ::SetMasterVolume(volume);
83  return *this;
84  }
85 };
86 } // namespace raylib
87 
88 #endif // RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:31
raylib::AudioDevice::Close
AudioDevice & Close()
Close the audio device and context.
Definition: AudioDevice.hpp:66
raylib::AudioDevice::SetVolume
AudioDevice & SetVolume(float volume)
Set master volume (listener).
Definition: AudioDevice.hpp:81
raylib::AudioDevice::Init
AudioDevice & Init()
Initialize audio device and context.
Definition: AudioDevice.hpp:58
raylib::AudioDevice::~AudioDevice
~AudioDevice()
Close the audio device and context.
Definition: AudioDevice.hpp:51
raylib::AudioDevice::AudioDevice
AudioDevice(bool lateInit=false)
Initialize audio device and context.
Definition: AudioDevice.hpp:42
raylib::AudioDevice
Audio device management functions.
Definition: AudioDevice.hpp:35
raylib::AudioDevice::IsReady
bool IsReady() const
Check if audio device has been initialized successfully.
Definition: AudioDevice.hpp:74