raylib-cpp
C++ object-oriented wrapper library for raylib.
Wave.hpp
1 #ifndef RAYLIB_CPP_WAVE_HPP_
2 #define RAYLIB_CPP_WAVE_HPP_
3 
4 #ifdef __cplusplus
5 extern "C"{
6 #endif
7 #include "raylib.h"
8 #ifdef __cplusplus
9 }
10 #endif
11 
12 #include "./raylib-cpp-utils.hpp"
13 
14 namespace raylib {
15  class Wave : public ::Wave {
16  public:
17  Wave(::Wave wave) {
18  set(wave);
19  };
20 
21  Wave(unsigned int SampleCount = 0, unsigned int SampleRate = 0, unsigned int SampleSize = 0, unsigned int Channels = 0) {
22  sampleCount = SampleCount;
23  sampleRate = SampleRate;
24  sampleSize = SampleSize;
25  channels = Channels;
26  };
27 
28  Wave(const std::string& fileName) {
29  set(LoadWave(fileName.c_str()));
30  }
31 
32  ~Wave() {
33  Unload();
34  }
35 
36  GETTERSETTER(unsigned int, SampleCount, sampleCount)
37  GETTERSETTER(unsigned int, SampleRate, sampleRate)
38  GETTERSETTER(unsigned int, SampleSize, sampleSize)
39  GETTERSETTER(unsigned int, Channels, channels)
40  GETTERSETTER(void *, Data, data)
41 
42  Wave& operator=(const ::Wave& wave) {
43  set(wave);
44  return *this;
45  }
46 
47  Wave& operator=(const Wave& wave) {
48  set(wave);
49  return *this;
50  }
51 
52  inline Wave& Format(int SampleRate = 0, int SampleSize = 0, int Channels = 2) {
53  ::WaveFormat(this, SampleRate, SampleSize, Channels);
54  return *this;
55  }
56 
57  inline Wave Copy() {
58  return ::WaveCopy(*this);
59  }
60 
61  inline Wave& Crop(int initSample, int finalSample) {
62  ::WaveCrop(this, initSample, finalSample);
63  return *this;
64  }
65 
66  inline Wave& Export(const std::string& fileName) {
67  ::ExportWave(*this, fileName.c_str());
68  return *this;
69  }
70  inline Wave& ExportAsCode(const std::string& fileName) {
71  ::ExportWaveAsCode(*this, fileName.c_str());
72  return *this;
73  }
74 
75  void Unload() {
76  if (data != NULL) {
77  ::UnloadWave(*this);
78  data = NULL;
79  }
80  }
81 
82  inline Sound LoadSound() {
83  return ::LoadSoundFromWave(*this);
84  }
85 
86  inline float* GetWaveData() {
87  return ::GetWaveData(*this);
88  }
89 
90  protected:
91  inline void set(::Wave wave) {
92  sampleCount = wave.sampleCount;
93  sampleRate = wave.sampleRate;
94  sampleSize = wave.sampleSize;
95  channels = wave.channels;
96  data = wave.data;
97  }
98  };
99 }
100 
101 #endif
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:14
raylib::Wave
Definition: Wave.hpp:15
raylib::Wave::Crop
Wave & Crop(int initSample, int finalSample)
Definition: Wave.hpp:61
raylib::Wave::operator=
Wave & operator=(const Wave &wave)
Definition: Wave.hpp:47
raylib::Wave::Unload
void Unload()
Definition: Wave.hpp:75
raylib::Sound
Definition: Sound.hpp:17
raylib::Wave::Copy
Wave Copy()
Definition: Wave.hpp:57
raylib::Wave::Export
Wave & Export(const std::string &fileName)
Definition: Wave.hpp:66
raylib::Wave::Wave
Wave(unsigned int SampleCount=0, unsigned int SampleRate=0, unsigned int SampleSize=0, unsigned int Channels=0)
Definition: Wave.hpp:21
raylib::Wave::~Wave
~Wave()
Definition: Wave.hpp:32
raylib::Wave::GetWaveData
float * GetWaveData()
Definition: Wave.hpp:86
raylib::Wave::LoadSound
Sound LoadSound()
Definition: Wave.hpp:82
raylib::Wave::Wave
Wave(::Wave wave)
Definition: Wave.hpp:17
raylib::Wave::Wave
Wave(const std::string &fileName)
Definition: Wave.hpp:28
raylib::Wave::set
void set(::Wave wave)
Definition: Wave.hpp:91
raylib::Wave::ExportAsCode
Wave & ExportAsCode(const std::string &fileName)
Definition: Wave.hpp:70
raylib::Wave::Format
Wave & Format(int SampleRate=0, int SampleSize=0, int Channels=2)
Definition: Wave.hpp:52