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

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

#include <Music.hpp>

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_view fileName)
 Load music stream from file. More...
 
 Music (const std::string_view fileType, std::span< unsigned char > data)
 Load music stream from memory. More...
 
 Music (const std::string_view fileType, unsigned char *data, int dataSize)
 Load music stream from memory. More...
 
 Music (Music &&other)
 
 ~Music ()
 Unload music stream. More...
 
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) More...
 
float GetTimePlayed () const
 Get current music time played (in seconds) More...
 
bool IsPlaying () const
 Check if music is playing. More...
 
bool IsReady () const
 Retrieve whether or not the Music has been loaded. More...
 
void Load (const std::string_view fileName)
 Load music stream from file. More...
 
void Load (const std::string_view fileType, std::span< unsigned char > data)
 Load music stream from memory. More...
 
void Load (const std::string_view 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. More...
 
MusicPlay ()
 Start music playing. More...
 
MusicResume ()
 Resume music playing. More...
 
MusicSeek (float position)
 Seek music to a position (in seconds) More...
 
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) More...
 
MusicSetPitch (float pitch)
 Set pitch for music. More...
 
MusicSetVolume (float volume)
 Set volume for music. More...
 
MusicStop ()
 Stop music playing. More...
 
void Unload ()
 Unload music stream. More...
 
MusicUpdate ()
 Updates buffers for music streaming. More...
 

Protected Member Functions

void set (const ::Music &music)
 

Detailed Description

Music stream type (audio file streaming from memory)

Definition at line 16 of file Music.hpp.

Constructor & Destructor Documentation

◆ Music() [1/6]

raylib::Music::Music ( ::AudioStream  stream = {nullptr, nullptr, 0, 0, 0},
unsigned int  frameCount = 0,
bool  looping = false,
int  ctxType = 0,
void *  ctxData = nullptr 
)
inline

Definition at line 18 of file Music.hpp.

◆ Music() [2/6]

raylib::Music::Music ( const ::Music &  music)
inline

Definition at line 24 of file Music.hpp.

◆ Music() [3/6]

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

Load music stream from file.

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

Definition at line 33 of file Music.hpp.

References Load().

◆ Music() [4/6]

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

Load music stream from memory.

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

Definition at line 42 of file Music.hpp.

References Load().

◆ Music() [5/6]

raylib::Music::Music ( const std::string_view  fileType,
std::span< unsigned char >  data 
)
inline

Load music stream from memory.

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

Definition at line 51 of file Music.hpp.

References Load().

◆ Music() [6/6]

raylib::Music::Music ( Music &&  other)
inline

Definition at line 57 of file Music.hpp.

◆ ~Music()

raylib::Music::~Music ( )
inline

Unload music stream.

Definition at line 70 of file Music.hpp.

References Unload().

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 78 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 77 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 75 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 76 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 74 of file Music.hpp.

◆ GetTimeLength()

float raylib::Music::GetTimeLength ( ) const
inline

Get music time length (in seconds)

Definition at line 193 of file Music.hpp.

◆ GetTimePlayed()

float raylib::Music::GetTimePlayed ( ) const
inline

Get current music time played (in seconds)

Definition at line 200 of file Music.hpp.

◆ IsPlaying()

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

Check if music is playing.

Definition at line 162 of file Music.hpp.

◆ IsReady()

bool raylib::Music::IsReady ( ) 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 245 of file Music.hpp.

Referenced by Load().

◆ Load() [1/3]

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

Load music stream from file.

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

Definition at line 209 of file Music.hpp.

References IsReady().

Referenced by Music().

◆ Load() [2/3]

void raylib::Music::Load ( const std::string_view  fileType,
std::span< unsigned char >  data 
)
inline

Load music stream from memory.

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

Definition at line 233 of file Music.hpp.

References IsReady().

◆ Load() [3/3]

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

Load music stream from memory.

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

Definition at line 221 of file Music.hpp.

References IsReady().

◆ operator=() [1/2]

Music & raylib::Music::operator= ( const ::Music &  music)
inline

Definition at line 80 of file Music.hpp.

◆ operator=() [2/2]

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

Definition at line 87 of file Music.hpp.

◆ Pause()

Music & raylib::Music::Pause ( )
inline

Pause music playing.

Definition at line 138 of file Music.hpp.

◆ Play()

Music & raylib::Music::Play ( )
inline

Start music playing.

Definition at line 114 of file Music.hpp.

◆ Resume()

Music & raylib::Music::Resume ( )
inline

Resume music playing.

Definition at line 146 of file Music.hpp.

◆ Seek()

Music & raylib::Music::Seek ( float  position)
inline

Seek music to a position (in seconds)

Definition at line 154 of file Music.hpp.

◆ set()

void raylib::Music::set ( const ::Music &  music)
inlineprotected

Definition at line 250 of file Music.hpp.

◆ 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 76 of file Music.hpp.

◆ SetPan()

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

Set pan for a music (0.5 is center)

Definition at line 185 of file Music.hpp.

◆ SetPitch()

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

Set pitch for music.

Definition at line 177 of file Music.hpp.

◆ SetVolume()

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

Set volume for music.

Definition at line 169 of file Music.hpp.

◆ Stop()

Music & raylib::Music::Stop ( )
inline

Stop music playing.

Definition at line 130 of file Music.hpp.

◆ Unload()

void raylib::Music::Unload ( )
inline

Unload music stream.

Definition at line 107 of file Music.hpp.

Referenced by ~Music().

◆ Update()

Music & raylib::Music::Update ( )
inline

Updates buffers for music streaming.

Definition at line 122 of file Music.hpp.