 |
raylib-cpp
C++ object-oriented wrapper library for raylib.
|
25 #ifndef RAYLIB_CPP_INCLUDE_WAVE_HPP_
26 #define RAYLIB_CPP_INCLUDE_WAVE_HPP_
30 #include "./raylib.hpp"
31 #include "./raylib-cpp-utils.hpp"
41 unsigned int SampleCount = 0,
42 unsigned int SampleRate = 0,
43 unsigned int SampleSize = 0,
44 unsigned int Channels = 0) {
45 sampleCount = SampleCount;
46 sampleRate = SampleRate;
47 sampleSize = SampleSize;
54 Wave(
const std::string& fileName) {
55 set(::LoadWave(fileName.c_str()));
61 Wave(
const std::string& fileType,
const unsigned char *fileData,
int dataSize) {
62 set(::LoadWaveFromMemory(fileType.c_str(), fileData, dataSize));
69 GETTERSETTER(
unsigned int, SampleCount, sampleCount)
70 GETTERSETTER(
unsigned int, SampleRate, sampleRate)
71 GETTERSETTER(
unsigned int, SampleSize, sampleSize)
72 GETTERSETTER(
unsigned int, Channels, channels)
73 GETTERSETTER(
void *, Data, data)
88 inline Wave&
Format(
int SampleRate,
int SampleSize,
int Channels = 2) {
89 ::WaveFormat(
this, SampleRate, SampleSize, Channels);
97 return ::WaveCopy(*
this);
103 inline Wave&
Crop(
int initSample,
int finalSample) {
104 ::WaveCrop(
this, initSample, finalSample);
112 return ::LoadWaveSamples(*
this);
119 ::UnloadWaveSamples(samples);
125 inline bool Export(
const std::string& fileName) {
127 return ::ExportWave(*
this, fileName.c_str());
135 return ::ExportWaveAsCode(*
this, fileName.c_str());
152 return ::LoadSoundFromWave(*
this);
158 inline operator ::Sound() {
170 inline void set(const ::Wave& wave) {
171 sampleCount = wave.sampleCount;
172 sampleRate = wave.sampleRate;
173 sampleSize = wave.sampleSize;
174 channels = wave.channels;
180 #endif // RAYLIB_CPP_INCLUDE_WAVE_HPP_
inline ::Wave Copy()
Copy a wave to a new wave.
Provides all the classes associated with raylib-cpp.
Wave & Crop(int initSample, int finalSample)
Crop a wave to defined samples range.
Wave & operator=(const Wave &wave)
void Unload()
Unload wave data.
float * LoadSamples()
Load samples data from wave as a floats array.
Wave/Sound management functions.
Wave(unsigned int SampleCount=0, unsigned int SampleRate=0, unsigned int SampleSize=0, unsigned int Channels=0)
bool Export(const std::string &fileName)
Export wave data to file, returns true on success.
void set(const ::Wave &wave)
Wave(const std::string &fileType, const unsigned char *fileData, int dataSize)
Load wave from memory buffer, fileType refers to extension: i.e.
Wave(const std::string &fileName)
Load wave data from file.
bool ExportAsCode(const std::string &fileName)
Export wave sample data to code (.h), returns true on success.
void UnloadSamples(float *samples)
Unload samples data loaded with LoadWaveSamples()
Wave & Format(int SampleRate, int SampleSize, int Channels=2)
Convert wave data to desired format.
inline ::Sound LoadSound()
Load sound from wave data.