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

Wave type, defines audio wave data. More...

#include <Wave.hpp>

Public Member Functions

 Wave (const ::Wave &wave)
 
 Wave (const std::string_view fileName)
 Load wave data from file. More...
 
 Wave (const std::string_view fileType, const unsigned char *fileData, int dataSize)
 Load wave from memory buffer, fileType refers to extension: i.e. More...
 
 Wave (const std::string_view fileType, std::span< const unsigned char > fileData)
 Load wave from memory buffer, fileType refers to extension: i.e. More...
 
 Wave (const Wave &other)
 
 Wave (unsigned int frameCount=0, unsigned int sampleRate=0, unsigned int sampleSize=0, unsigned int channels=0, void *data=nullptr)
 
 Wave (Wave &&other) noexcept
 
 ~Wave ()
 Unload wave data. More...
 
::Wave Copy () const
 Copy a wave to a new wave. More...
 
WaveCrop (int initSample, int finalSample)
 Crop a wave to defined samples range. More...
 
bool Export (const std::string_view fileName)
 Export wave data to file, returns true on success. More...
 
bool ExportAsCode (const std::string_view fileName)
 Export wave sample data to code (.h), returns true on success. More...
 
WaveFormat (int SampleRate, int SampleSize, int Channels=2)
 Convert wave data to desired format. More...
 
unsigned int GetChannels () const
 Retrieves the channels value for the object. More...
 
void * GetData () const
 Retrieves the data value for the object. More...
 
unsigned int GetFrameCount () const
 Retrieves the frameCount value for the object. More...
 
unsigned int GetSampleRate () const
 Retrieves the sampleRate value for the object. More...
 
unsigned int GetSampleSize () const
 Retrieves the sampleSize value for the object. More...
 
bool IsValid () const
 Retrieve whether or not the Wave data has been loaded. More...
 
void Load (const std::string_view fileName)
 Load wave data from file. More...
 
void Load (const std::string_view fileType, const unsigned char *fileData, int dataSize)
 Load wave from memory buffer, fileType refers to extension: i.e. More...
 
void Load (const std::string_view fileType, std::span< const unsigned char > fileData)
 Load wave from memory buffer, fileType refers to extension: i.e. More...
 
float * LoadSamples ()
 Load samples data from wave as a floats array. More...
 
::Sound LoadSound ()
 Load sound from wave data. More...
 
 operator::Sound ()
 Load sound from wave data. More...
 
Waveoperator= (const ::Wave &wave)
 
Waveoperator= (const Wave &other)
 
Waveoperator= (Wave &&other) noexcept
 
void Unload ()
 Unload wave data. More...
 

Static Public Member Functions

static void UnloadSamples (float *samples)
 Unload samples data loaded with LoadWaveSamples() More...
 

Protected Member Functions

void set (const ::Wave &wave)
 

Detailed Description

Wave type, defines audio wave data.

Definition at line 16 of file Wave.hpp.

Constructor & Destructor Documentation

◆ Wave() [1/7]

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

Definition at line 18 of file Wave.hpp.

◆ Wave() [2/7]

raylib::Wave::Wave ( unsigned int  frameCount = 0,
unsigned int  sampleRate = 0,
unsigned int  sampleSize = 0,
unsigned int  channels = 0,
void *  data = nullptr 
)
inline

Definition at line 20 of file Wave.hpp.

◆ Wave() [3/7]

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

Load wave data from file.

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

Definition at line 35 of file Wave.hpp.

References Load().

◆ Wave() [4/7]

raylib::Wave::Wave ( const std::string_view  fileType,
const unsigned char *  fileData,
int  dataSize 
)
inline

Load wave from memory buffer, fileType refers to extension: i.e.

"wav"

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

Definition at line 44 of file Wave.hpp.

References Load().

◆ Wave() [5/7]

raylib::Wave::Wave ( const std::string_view  fileType,
std::span< const unsigned char >  fileData 
)
inline

Load wave from memory buffer, fileType refers to extension: i.e.

"wav"

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

Definition at line 53 of file Wave.hpp.

References Load().

◆ Wave() [6/7]

raylib::Wave::Wave ( const Wave other)
inline

Definition at line 57 of file Wave.hpp.

◆ Wave() [7/7]

raylib::Wave::Wave ( Wave &&  other)
inlinenoexcept

Definition at line 61 of file Wave.hpp.

◆ ~Wave()

raylib::Wave::~Wave ( )
inline

Unload wave data.

Definition at line 74 of file Wave.hpp.

References Unload().

Member Function Documentation

◆ Copy()

::Wave raylib::Wave::Copy ( ) const
inline

Copy a wave to a new wave.

Definition at line 118 of file Wave.hpp.

◆ Crop()

Wave & raylib::Wave::Crop ( int  initSample,
int  finalSample 
)
inline

Crop a wave to defined samples range.

Definition at line 123 of file Wave.hpp.

◆ Export()

bool raylib::Wave::Export ( const std::string_view  fileName)
inline

Export wave data to file, returns true on success.

Definition at line 149 of file Wave.hpp.

◆ ExportAsCode()

bool raylib::Wave::ExportAsCode ( const std::string_view  fileName)
inline

Export wave sample data to code (.h), returns true on success.

Definition at line 157 of file Wave.hpp.

◆ Format()

Wave & raylib::Wave::Format ( int  SampleRate,
int  SampleSize,
int  Channels = 2 
)
inline

Convert wave data to desired format.

Definition at line 131 of file Wave.hpp.

◆ GetChannels()

unsigned int raylib::Wave::GetChannels ( ) const
inline

Retrieves the channels value for the object.

Returns
The channels value of the object.

Definition at line 79 of file Wave.hpp.

◆ GetData()

void * raylib::Wave::GetData ( ) const
inline

Retrieves the data value for the object.

Returns
The data value of the object.

Definition at line 80 of file Wave.hpp.

◆ GetFrameCount()

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

Retrieves the frameCount value for the object.

Returns
The frameCount value of the object.

Definition at line 76 of file Wave.hpp.

◆ GetSampleRate()

unsigned int raylib::Wave::GetSampleRate ( ) const
inline

Retrieves the sampleRate value for the object.

Returns
The sampleRate value of the object.

Definition at line 77 of file Wave.hpp.

◆ GetSampleSize()

unsigned int raylib::Wave::GetSampleSize ( ) const
inline

Retrieves the sampleSize value for the object.

Returns
The sampleSize value of the object.

Definition at line 78 of file Wave.hpp.

◆ IsValid()

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

Retrieve whether or not the Wave data has been loaded.

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

Definition at line 224 of file Wave.hpp.

Referenced by Load().

◆ Load() [1/3]

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

Load wave data from file.

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

Definition at line 188 of file Wave.hpp.

References IsValid().

Referenced by Wave().

◆ Load() [2/3]

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

Load wave from memory buffer, fileType refers to extension: i.e.

"wav"

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

Definition at line 200 of file Wave.hpp.

References IsValid().

◆ Load() [3/3]

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

Load wave from memory buffer, fileType refers to extension: i.e.

"wav"

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

Definition at line 212 of file Wave.hpp.

References IsValid().

◆ LoadSamples()

float * raylib::Wave::LoadSamples ( )
inline

Load samples data from wave as a floats array.

Definition at line 139 of file Wave.hpp.

◆ LoadSound()

::Sound raylib::Wave::LoadSound ( )
inline

Load sound from wave data.

Definition at line 176 of file Wave.hpp.

Referenced by operator::Sound().

◆ operator::Sound()

raylib::Wave::operator::Sound ( )
inline

Load sound from wave data.

Definition at line 181 of file Wave.hpp.

References LoadSound().

◆ operator=() [1/3]

Wave & raylib::Wave::operator= ( const ::Wave &  wave)
inline

Definition at line 82 of file Wave.hpp.

◆ operator=() [2/3]

Wave & raylib::Wave::operator= ( const Wave other)
inline

Definition at line 87 of file Wave.hpp.

◆ operator=() [3/3]

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

Definition at line 98 of file Wave.hpp.

◆ set()

void raylib::Wave::set ( const ::Wave &  wave)
inlineprotected

Definition at line 226 of file Wave.hpp.

◆ Unload()

void raylib::Wave::Unload ( )
inline

Unload wave data.

Definition at line 165 of file Wave.hpp.

Referenced by ~Wave().

◆ UnloadSamples()

static void raylib::Wave::UnloadSamples ( float *  samples)
inlinestatic

Unload samples data loaded with LoadWaveSamples()

Definition at line 144 of file Wave.hpp.