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  inline void set(::Wave wave) {
37  sampleCount = wave.sampleCount;
38  sampleRate = wave.sampleRate;
39  sampleSize = wave.sampleSize;
40  channels = wave.channels;
41  data = wave.data;
42  }
43 
44  GETTERSETTER(unsigned int,X,sampleCount)
45  GETTERSETTER(unsigned int,Y,sampleRate)
46  GETTERSETTER(unsigned int,Z,sampleSize)
47  GETTERSETTER(unsigned int,W,channels)
48  GETTERSETTER(void*,Data,data)
49 
50  Wave& operator=(const ::Wave& wave) {
51  set(wave);
52  return *this;
53  }
54 
55  Wave& operator=(const Wave& wave) {
56  set(wave);
57  return *this;
58  }
59 
60  inline Wave& Format(int SampleRate = 0, int SampleSize = 0, int Channels = 2) {
61  ::WaveFormat(this, SampleRate, SampleSize, Channels);
62  return *this;
63  }
64 
65  inline Wave Copy() {
66  return ::WaveCopy(*this);
67  }
68 
69  inline Wave& Crop(int initSample, int finalSample) {
70  ::WaveCrop(this, initSample, finalSample);
71  return *this;
72  }
73 
74  inline Wave& Export(const std::string& fileName) {
75  ::ExportWave(*this, fileName.c_str());
76  return *this;
77  }
78  inline Wave& ExportAsCode(const std::string& fileName) {
79  ::ExportWaveAsCode(*this, fileName.c_str());
80  return *this;
81  }
82 
83  void Unload() {
84  if (data != NULL) {
85  ::UnloadWave(*this);
86  data = NULL;
87  }
88  }
89 
90  inline Sound LoadSound() {
91  return ::LoadSoundFromWave(*this);
92  }
93 
94  inline float* GetWaveData() {
95  return ::GetWaveData(*this);
96  }
97  };
98 }
99 
100 #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:69
raylib::Wave::operator=
Wave & operator=(const Wave &wave)
Definition: Wave.hpp:55
raylib::Wave::Unload
void Unload()
Definition: Wave.hpp:83
raylib::Sound
Definition: Sound.hpp:17
raylib::Wave::Copy
Wave Copy()
Definition: Wave.hpp:65
raylib::Wave::Export
Wave & Export(const std::string &fileName)
Definition: Wave.hpp:74
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:94
raylib::Wave::LoadSound
Sound LoadSound()
Definition: Wave.hpp:90
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:36
raylib::Wave::ExportAsCode
Wave & ExportAsCode(const std::string &fileName)
Definition: Wave.hpp:78
raylib::Wave::Format
Wave & Format(int SampleRate=0, int SampleSize=0, int Channels=2)
Definition: Wave.hpp:60