* Wave type, defines audio wave data. * * The wave will be unloaded on object destruction. Use raylib::WaveUnmanaged if you're looking to not unload. * Unlike other resource types, Wave supports value-copy semantics via WaveCopy(). * * @see raylib::WaveUnmanaged */
| 13 | * @see raylib::WaveUnmanaged |
| 14 | */ |
| 15 | class Wave : public WaveUnmanaged { |
| 16 | public: |
| 17 | using WaveUnmanaged::WaveUnmanaged; |
| 18 | |
| 19 | Wave(const Wave& other) : WaveUnmanaged(other.Copy()) {} |
| 20 | |
| 21 | Wave(Wave&& other) noexcept : WaveUnmanaged(other) { |
| 22 | other.frameCount = 0; |
| 23 | other.sampleRate = 0; |
| 24 | other.sampleSize = 0; |
| 25 | other.channels = 0; |
| 26 | other.data = nullptr; |
| 27 | } |
| 28 | |
| 29 | Wave& operator=(const ::Wave& wave) { |
| 30 | Unload(); |
| 31 | set(wave); |
| 32 | return *this; |
| 33 | } |
| 34 | |
| 35 | Wave& operator=(const Wave& other) { |
| 36 | if (this == &other) { |
| 37 | return *this; |
| 38 | } |
| 39 | Unload(); |
| 40 | set(other.Copy()); |
| 41 | return *this; |
| 42 | } |
| 43 | |
| 44 | Wave& operator=(Wave&& other) noexcept { |
| 45 | if (this == &other) { |
| 46 | return *this; |
| 47 | } |
| 48 | Unload(); |
| 49 | set(other); |
| 50 | other.frameCount = 0; |
| 51 | other.sampleRate = 0; |
| 52 | other.sampleSize = 0; |
| 53 | other.channels = 0; |
| 54 | other.data = nullptr; |
| 55 | return *this; |
| 56 | } |
| 57 | |
| 58 | ~Wave() { Unload(); } |
| 59 | |
| 60 | void Load(const std::string& fileName) { |
| 61 | Unload(); |
| 62 | WaveUnmanaged::Load(fileName); |
| 63 | } |
| 64 | |
| 65 | void Load(const std::string& fileType, const unsigned char* fileData, int dataSize) { |
| 66 | Unload(); |
| 67 | WaveUnmanaged::Load(fileType, fileData, dataSize); |
| 68 | } |
| 69 | }; |
| 70 | } // namespace raylib |
| 71 | |
| 72 | using RWave = raylib::Wave; |