raylib-cpp
C++ object-oriented wrapper library for raylib.
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
raylib::Sound Class Reference

Wave/Sound management functions. More...

#include <Sound.hpp>

Public Member Functions

 Sound (::AudioStream stream, unsigned int frameCount)
 
 Sound (const ::Wave &wave)
 Loads a sound from the given Wave. More...
 
 Sound (const Sound &)=delete
 
 Sound (const std::string_view fileName)
 Loads a sound from the given file. More...
 
 Sound (Sound &&other)
 
unsigned int GetFrameCount () const
 Retrieves the frameCount value for the object. More...
 
::AudioStream GetStream () const
 Retrieves the stream value for the object. More...
 
bool IsPlaying () const
 Check if a sound is currently playing. More...
 
bool IsReady () const
 Retrieve whether or not the Sound buffer is loaded. More...
 
void Load (const ::Wave &wave)
 Loads the given Wave object into the Sound. More...
 
void Load (const std::string_view fileName)
 Load a sound from the given file. More...
 
Soundoperator= (const Sound &)=delete
 
Soundoperator= (Sound &&other) noexcept
 
SoundPause ()
 Pause a sound. More...
 
SoundPlay ()
 Play a sound. More...
 
SoundResume ()
 Resume a paused sound. More...
 
SoundSetPan (float pan=0.5f)
 Set pan for a sound (0.5 is center) More...
 
SoundSetPitch (float pitch)
 Set pitch for a sound (1.0 is base level) More...
 
SoundSetVolume (float volume)
 Set volume for a sound (1.0 is max level) More...
 
SoundStop ()
 Stop playing a sound. More...
 
void Unload ()
 Unload sound. More...
 
SoundUpdate (const std::span< std::byte > data)
 Update sound buffer with new data. More...
 
SoundUpdate (const void *data)
 Update sound buffer with new data, assuming it's the same sample count. More...
 
SoundUpdate (const void *data, int samplesCount)
 Update sound buffer with new data. More...
 

Protected Member Functions

void set (const ::Sound &sound)
 

Detailed Description

Wave/Sound management functions.

raylib::Sound boom("boom.wav");
boom.Play();
Wave/Sound management functions.
Definition: Sound.hpp:21

Definition at line 21 of file Sound.hpp.

Constructor & Destructor Documentation

◆ Sound() [1/5]

raylib::Sound::Sound ( )
inline

Definition at line 26 of file Sound.hpp.

◆ Sound() [2/5]

raylib::Sound::Sound ( ::AudioStream  stream,
unsigned int  frameCount 
)
inline

Definition at line 31 of file Sound.hpp.

◆ Sound() [3/5]

raylib::Sound::Sound ( Sound &&  other)
inline

Definition at line 35 of file Sound.hpp.

◆ Sound() [4/5]

raylib::Sound::Sound ( const std::string_view  fileName)
inline

Loads a sound from the given file.

Exceptions
raylib::RaylibExceptionThrows if the Sound failed to load.

Definition at line 47 of file Sound.hpp.

References Load().

◆ Sound() [5/5]

raylib::Sound::Sound ( const ::Wave &  wave)
inline

Loads a sound from the given Wave.

Exceptions
raylib::RaylibExceptionThrows if the Sound failed to load.

Definition at line 56 of file Sound.hpp.

References Load().

◆ ~Sound()

raylib::Sound::~Sound ( )
inline

Definition at line 60 of file Sound.hpp.

Member Function Documentation

◆ GetFrameCount()

unsigned int raylib::Sound::GetFrameCount ( ) const
inline

Retrieves the frameCount value for the object.

Returns
The frameCount value of the object.

Definition at line 64 of file Sound.hpp.

◆ GetStream()

::AudioStream raylib::Sound::GetStream ( ) const
inline

Retrieves the stream value for the object.

Returns
The stream value of the object.

Definition at line 65 of file Sound.hpp.

References Unload().

◆ IsPlaying()

bool raylib::Sound::IsPlaying ( ) const
inline

Check if a sound is currently playing.

Definition at line 150 of file Sound.hpp.

◆ IsReady()

bool raylib::Sound::IsReady ( ) const
inline

Retrieve whether or not the Sound buffer is loaded.

Returns
True or false depending on whether the Sound buffer is loaded.

Definition at line 207 of file Sound.hpp.

Referenced by Load().

◆ Load() [1/2]

void raylib::Sound::Load ( const ::Wave &  wave)
inline

Loads the given Wave object into the Sound.

Exceptions
raylib::RaylibExceptionThrows if the Sound failed to load.

Definition at line 195 of file Sound.hpp.

References IsReady().

◆ Load() [2/2]

void raylib::Sound::Load ( const std::string_view  fileName)
inline

Load a sound from the given file.

Exceptions
raylib::RaylibExceptionThrows if the Sound failed to load.

Definition at line 183 of file Sound.hpp.

References IsReady().

Referenced by Sound().

◆ operator=()

Sound & raylib::Sound::operator= ( Sound &&  other)
inlinenoexcept

Definition at line 67 of file Sound.hpp.

◆ Pause()

Sound & raylib::Sound::Pause ( )
inline

Pause a sound.

Definition at line 134 of file Sound.hpp.

◆ Play()

Sound & raylib::Sound::Play ( )
inline

Play a sound.

Definition at line 118 of file Sound.hpp.

◆ Resume()

Sound & raylib::Sound::Resume ( )
inline

Resume a paused sound.

Definition at line 142 of file Sound.hpp.

◆ set()

void raylib::Sound::set ( const ::Sound &  sound)
inlineprotected

Definition at line 212 of file Sound.hpp.

◆ SetPan()

Sound & raylib::Sound::SetPan ( float  pan = 0.5f)
inline

Set pan for a sound (0.5 is center)

Definition at line 173 of file Sound.hpp.

◆ SetPitch()

Sound & raylib::Sound::SetPitch ( float  pitch)
inline

Set pitch for a sound (1.0 is base level)

Definition at line 165 of file Sound.hpp.

◆ SetVolume()

Sound & raylib::Sound::SetVolume ( float  volume)
inline

Set volume for a sound (1.0 is max level)

Definition at line 157 of file Sound.hpp.

◆ Stop()

Sound & raylib::Sound::Stop ( )
inline

Stop playing a sound.

Definition at line 126 of file Sound.hpp.

◆ Unload()

void raylib::Sound::Unload ( )
inline

Unload sound.

Definition at line 107 of file Sound.hpp.

Referenced by GetStream().

◆ Update() [1/3]

Sound & raylib::Sound::Update ( const std::span< std::byte >  data)
inline

Update sound buffer with new data.

Definition at line 91 of file Sound.hpp.

◆ Update() [2/3]

Sound & raylib::Sound::Update ( const void *  data)
inline

Update sound buffer with new data, assuming it's the same sample count.

Definition at line 99 of file Sound.hpp.

◆ Update() [3/3]

Sound & raylib::Sound::Update ( const void *  data,
int  samplesCount 
)
inline

Update sound buffer with new data.

Definition at line 83 of file Sound.hpp.