raylib-cpp
C++ object-oriented wrapper library for raylib.
Public Member Functions | Protected Member Functions | List of all members
raylib::Music Class Reference

Music stream type (audio file streaming from memory) More...

Public Member Functions

 Music (::AudioStream stream={nullptr, nullptr, 0, 0, 0}, unsigned int frameCount=0, bool looping=false, int ctxType=0, void *ctxData=nullptr)
 
 Music (const ::Music &music)
 
 Music (const Music &)=delete
 
 Music (const std::string &fileName)
 Load music stream from file. More...
 
 Music (const std::string &fileType, unsigned char *data, int dataSize)
 Load music stream from memory. More...
 
 Music (Music &&other)
 
 ~Music ()
 Unload music stream.
 
void * GetCtxData () const
 Retrieves the ctxData value for the object. More...
 
int GetCtxType () const
 Retrieves the ctxType value for the object. More...
 
unsigned int GetFrameCount () const
 Retrieves the frameCount value for the object. More...
 
bool GetLooping () const
 Retrieves the looping value for the object. More...
 
::AudioStream GetStream () const
 Retrieves the stream value for the object. More...
 
float GetTimeLength () const
 Get music time length (in seconds)
 
float GetTimePlayed () const
 Get current music time played (in seconds)
 
bool IsPlaying () const
 Check if music is playing.
 
bool IsValid () const
 Retrieve whether or not the Music has been loaded. More...
 
void Load (const std::string &fileName)
 Load music stream from file. More...
 
void Load (const std::string &fileType, unsigned char *data, int dataSize)
 Load music stream from memory. More...
 
Musicoperator= (const ::Music &music)
 
Musicoperator= (const Music &)=delete
 
Musicoperator= (Music &&other) noexcept
 
MusicPause ()
 Pause music playing.
 
MusicPlay ()
 Start music playing.
 
MusicResume ()
 Resume music playing.
 
MusicSeek (float position)
 Seek music to a position (in seconds)
 
void SetLooping (bool value)
 Sets the looping value for the object. More...
 
MusicSetPan (float pan=0.5f)
 Set pan for a music (0.5 is center)
 
MusicSetPitch (float pitch)
 Set pitch for music.
 
MusicSetVolume (float volume)
 Set volume for music.
 
MusicStop ()
 Stop music playing.
 
void Unload ()
 Unload music stream.
 
MusicUpdate ()
 Updates buffers for music streaming.
 

Protected Member Functions

void set (const ::Music &music)
 

Detailed Description

Music stream type (audio file streaming from memory)

Definition at line 14 of file Music.hpp.

Constructor & Destructor Documentation

◆ Music() [1/2]

raylib::Music::Music ( const std::string &  fileName)
inline

Load music stream from file.

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

Definition at line 31 of file Music.hpp.

References Load().

◆ Music() [2/2]

raylib::Music::Music ( const std::string &  fileType,
unsigned char *  data,
int  dataSize 
)
inline

Load music stream from memory.

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

Definition at line 38 of file Music.hpp.

References Load().

Member Function Documentation

◆ GetCtxData()

void* raylib::Music::GetCtxData ( ) const
inline

Retrieves the ctxData value for the object.

Returns
The ctxData value of the object.

Definition at line 61 of file Music.hpp.

◆ GetCtxType()

int raylib::Music::GetCtxType ( ) const
inline

Retrieves the ctxType value for the object.

Returns
The ctxType value of the object.

Definition at line 60 of file Music.hpp.

◆ GetFrameCount()

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

Retrieves the frameCount value for the object.

Returns
The frameCount value of the object.

Definition at line 58 of file Music.hpp.

◆ GetLooping()

bool raylib::Music::GetLooping ( ) const
inline

Retrieves the looping value for the object.

Returns
The looping value of the object.

Definition at line 59 of file Music.hpp.

◆ GetStream()

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

Retrieves the stream value for the object.

Returns
The stream value of the object.

Definition at line 57 of file Music.hpp.

◆ IsValid()

bool raylib::Music::IsValid ( ) const
inline

Retrieve whether or not the Music has been loaded.

Returns
True or false depending on whether the Music has been loaded.

Definition at line 208 of file Music.hpp.

Referenced by Load().

◆ Load() [1/2]

void raylib::Music::Load ( const std::string &  fileName)
inline

Load music stream from file.

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

Definition at line 184 of file Music.hpp.

References IsValid().

Referenced by Music().

◆ Load() [2/2]

void raylib::Music::Load ( const std::string &  fileType,
unsigned char *  data,
int  dataSize 
)
inline

Load music stream from memory.

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

Definition at line 196 of file Music.hpp.

References IsValid().

◆ SetLooping()

void raylib::Music::SetLooping ( bool  value)
inline

Sets the looping value for the object.

Parameters
valueThe value of which to set looping to.

Definition at line 59 of file Music.hpp.