 |
raylib-cpp
C++ object-oriented wrapper library for raylib.
|
1 #ifndef RAYLIB_CPP_INCLUDE_SOUND_HPP_
2 #define RAYLIB_CPP_INCLUDE_SOUND_HPP_
6 #include "./raylib.hpp"
7 #include "./raylib-cpp-utils.hpp"
8 #include "./RaylibException.hpp"
26 stream.buffer =
nullptr;
37 other.stream = { 0, 0, 0, 0 };
45 Sound(
const std::string& fileName) {
46 if (!
Load(fileName)) {
47 throw RaylibException(TextFormat(
"Failed to load Sound from file: %s", fileName.c_str()));
66 GETTERSETTER(
unsigned int, FrameCount, frameCount)
77 other.stream = { 0, 0, 0, 0 };
86 ::UpdateSound(*
this, data, samplesCount);
94 ::UpdateSound(*
this, data,
static_cast<int>(frameCount));
102 ::UnloadSound(*
this);
133 ::ResumeSound(*
this);
141 ::PlaySoundMulti(*
this);
157 return ::IsSoundPlaying(*
this);
164 ::SetSoundVolume(*
this, volume);
172 ::SetSoundPitch(*
this, pitch);
181 bool Load(
const std::string& fileName) {
182 set(::LoadSound(fileName.c_str()));
189 bool Load(const ::Wave& wave) {
190 set(::LoadSoundFromWave(wave));
201 return stream.buffer !=
nullptr;
205 inline void set(const ::Sound& sound) {
206 frameCount = sound.frameCount;
207 stream = sound.stream;
212 #endif // RAYLIB_CPP_INCLUDE_SOUND_HPP_
All raylib-cpp classes and functions appear in the raylib namespace.
bool Load(const ::Wave &wave)
Loads the given Wave object into the Sound.
Sound & StopMulti()
Stop any sound playing (using multichannel buffer pool)
Sound & SetVolume(float volume)
Set volume for a sound (1.0 is max level)
Sound & Update(const void *data, int samplesCount)
Update sound buffer with new data.
Wave/Sound management functions.
Sound & Pause()
Pause a sound.
bool IsReady() const
Retrieve whether or not the Sound buffer is loaded.
Sound & Resume()
Resume a paused sound.
Sound & Stop()
Stop playing a sound.
bool Load(const std::string &fileName)
Load a sound from the given file.
bool IsPlaying() const
Check if a sound is currently playing.
void Unload()
Unload sound.
AudioStream management functions.
Sound(const ::Wave &wave)
Loads a sound from the given Wave.
Sound & Update(const void *data)
Update sound buffer with new data, assuming it's the same sample count.
Sound & SetPitch(float pitch)
Set pitch for a sound (1.0 is base level)
Exception used for most raylib-related exceptions.
Sound & Play()
Play a sound.
Sound & PlayMulti()
Play a sound (using multichannel buffer pool)
Sound(const std::string &fileName)
Loads a sound from the given file.