1 #ifndef RAYLIB_CPP_INCLUDE_WAVE_HPP_
2 #define RAYLIB_CPP_INCLUDE_WAVE_HPP_
6 #include "./raylib.hpp"
7 #include "./raylib-cpp-utils.hpp"
8 #include "./RaylibException.hpp"
16 Wave(const ::Wave& wave) {
21 unsigned int frameCount = 0,
22 unsigned int sampleRate = 0,
23 unsigned int sampleSize = 0,
24 unsigned int channels = 0,
25 void *data =
nullptr) :
::Wave{frameCount, sampleRate, sampleSize, channels, data} {
32 Wave(
const std::string& fileName) {
33 if (!
Load(fileName)) {
34 throw RaylibException(TextFormat(
"Failed to load Wave from file: %s", fileName.c_str()));
41 Wave(
const std::string& fileType,
const unsigned char *fileData,
int dataSize) {
42 if (!
Load(fileType, fileData, dataSize)) {
68 GETTERSETTER(
unsigned int, FrameCount, frameCount)
69 GETTERSETTER(
unsigned int, SampleRate, sampleRate)
70 GETTERSETTER(
unsigned int, SampleSize, sampleSize)
71 GETTERSETTER(
unsigned int, Channels, channels)
72 GETTERSETTER(
void *, Data, data)
74 Wave& operator=(const ::
Wave& wave) {
90 Wave& operator=(Wave&& other) {
100 other.sampleSize = 0;
102 other.data =
nullptr;
110 inline Wave&
Format(
int SampleRate,
int SampleSize,
int Channels = 2) {
111 ::WaveFormat(
this, SampleRate, SampleSize, Channels);
119 return ::WaveCopy(*
this);
125 inline Wave&
Crop(
int initSample,
int finalSample) {
126 ::WaveCrop(
this, initSample, finalSample);
134 return ::LoadWaveSamples(*
this);
141 ::UnloadWaveSamples(samples);
147 inline bool Export(
const std::string& fileName) {
149 return ::ExportWave(*
this, fileName.c_str());
157 return ::ExportWaveAsCode(*
this, fileName.c_str());
164 if (data !=
nullptr) {
174 return ::LoadSoundFromWave(*
this);
180 inline operator ::Sound() {
189 bool Load(
const std::string& fileName) {
190 set(::LoadWave(fileName.c_str()));
199 bool Load(
const std::string& fileType,
const unsigned char *fileData,
int dataSize) {
200 set(::LoadWaveFromMemory(fileType.c_str(), fileData, dataSize));
210 return data !=
nullptr;
214 inline void set(const ::Wave& wave) {
215 frameCount = wave.frameCount;
216 sampleRate = wave.sampleRate;
217 sampleSize = wave.sampleSize;
218 channels = wave.channels;
225 #endif // RAYLIB_CPP_INCLUDE_WAVE_HPP_