* Wave/Sound management functions. * * The sound will be unloaded on object destruction. Use raylib::SoundUnmanaged if you're looking to not unload. * * @code * raylib::Sound boom("boom.wav"); * boom.Play(); * @endcode * * @see raylib::SoundUnmanaged */
| 17 | * @see raylib::SoundUnmanaged |
| 18 | */ |
| 19 | class Sound : public SoundUnmanaged { |
| 20 | public: |
| 21 | using SoundUnmanaged::SoundUnmanaged; |
| 22 | |
| 23 | Sound(const Sound&) = delete; |
| 24 | Sound& operator=(const Sound&) = delete; |
| 25 | |
| 26 | Sound(Sound&& other) noexcept { |
| 27 | set(other); |
| 28 | other.stream = {nullptr, nullptr, 0, 0, 0}; |
| 29 | other.frameCount = 0; |
| 30 | } |
| 31 | |
| 32 | Sound& operator=(Sound&& other) noexcept { |
| 33 | if (this == &other) { |
| 34 | return *this; |
| 35 | } |
| 36 | Unload(); |
| 37 | set(other); |
| 38 | other.frameCount = 0; |
| 39 | other.stream = {nullptr, nullptr, 0, 0, 0}; |
| 40 | return *this; |
| 41 | } |
| 42 | |
| 43 | ~Sound() { Unload(); } |
| 44 | |
| 45 | void Load(const std::string& fileName) { |
| 46 | Unload(); |
| 47 | SoundUnmanaged::Load(fileName); |
| 48 | } |
| 49 | |
| 50 | void Load(const ::Wave& wave) { |
| 51 | Unload(); |
| 52 | SoundUnmanaged::Load(wave); |
| 53 | } |
| 54 | }; |
| 55 | } // namespace raylib |
| 56 | |
| 57 | using RSound = raylib::Sound; |
nothing calls this directly
no outgoing calls
no test coverage detected