1#ifndef RAYLIB_CPP_INCLUDE_SOUND_HPP_
2#define RAYLIB_CPP_INCLUDE_SOUND_HPP_
9#include "./raylib-cpp-utils.hpp"
10#include "./RaylibException.hpp"
27 stream = {
nullptr,
nullptr, 0, 0, 0 };
31 Sound(::AudioStream stream,
unsigned int frameCount) : ::Sound{stream, frameCount} {
38 other.stream = {
nullptr,
nullptr, 0, 0, 0 };
47 Sound(
const std::string_view fileName) {
64 GETTER(
unsigned int, FrameCount, frameCount)
75 other.stream = {
nullptr,
nullptr, 0, 0, 0 };
84 ::UpdateSound(*
this, data, samplesCount);
92 ::UpdateSound(*
this, data.data(),
static_cast<int>(data.size()));
100 ::UpdateSound(*
this, data,
static_cast<int>(frameCount));
109 if (frameCount != 0) {
110 ::UnloadSound(*
this);
143 ::ResumeSound(*
this);
151 return ::IsSoundPlaying(*
this);
158 ::SetSoundVolume(*
this, volume);
166 ::SetSoundPitch(*
this, pitch);
174 ::SetSoundPan(*
this, pan);
183 void Load(
const std::string_view fileName) {
184 set(::LoadSound(fileName.data()));
195 void Load(const ::Wave& wave) {
196 set(::LoadSoundFromWave(wave));
208 return ::IsSoundReady(*
this);
212 void set(const ::Sound& sound) {
213 frameCount = sound.frameCount;
214 stream = sound.stream;
AudioStream management functions.
Exception used for most raylib-related exceptions.
Wave/Sound management functions.
void Unload()
Unload sound.
void Load(const ::Wave &wave)
Loads the given Wave object into the Sound.
Sound & Stop()
Stop playing a sound.
Sound & SetVolume(float volume)
Set volume for a sound (1.0 is max level)
Sound(const std::string_view fileName)
Loads a sound from the given file.
Sound & Pause()
Pause a sound.
bool IsReady() const
Retrieve whether or not the Sound buffer is loaded.
Sound & Update(const void *data)
Update sound buffer with new data, assuming it's the same sample count.
Sound & Update(const std::span< std::byte > data)
Update sound buffer with new data.
Sound & Resume()
Resume a paused sound.
Sound & Update(const void *data, int samplesCount)
Update sound buffer with new data.
Sound & SetPan(float pan=0.5f)
Set pan for a sound (0.5 is center)
Sound & Play()
Play a sound.
bool IsPlaying() const
Check if a sound is currently playing.
Sound(const ::Wave &wave)
Loads a sound from the given Wave.
void Load(const std::string_view fileName)
Load a sound from the given file.
Sound & SetPitch(float pitch)
Set pitch for a sound (1.0 is base level)