MCPcopy Create free account
hub / github.com/RobLoach/raylib-cpp / WaveUnmanaged

Class WaveUnmanaged

include/WaveUnmanaged.hpp:18–173  ·  view source on GitHub ↗

* A Wave that is not managed by C++ RAII. * * Make sure to Unload() this if needed, otherwise use raylib::Wave. * * @see raylib::Wave */

Source from the content-addressed store, hash-verified

16 * @see raylib::Wave
17 */
18class WaveUnmanaged : public ::Wave {
19public:
20 /**
21 * Creates a WaveUnmanaged from an existing Wave struct.
22 */
23 WaveUnmanaged(const ::Wave& wave) : ::Wave(wave) {}
24
25 /**
26 * Creates a WaveUnmanaged from its components.
27 */
28 WaveUnmanaged(
29 unsigned int frameCount = 0,
30 unsigned int sampleRate = 0,
31 unsigned int sampleSize = 0,
32 unsigned int channels = 0,
33 void* data = nullptr)
34 : ::Wave{frameCount, sampleRate, sampleSize, channels, data} {}
35
36 /**
37 * Load wave data from file.
38 *
39 * @throws raylib::RaylibException Throws if the Wave failed to load.
40 */
41 WaveUnmanaged(const std::string& fileName) { Load(fileName); }
42
43 /**
44 * Load wave from memory buffer; fileType refers to extension: i.e. "wav".
45 *
46 * @throws raylib::RaylibException Throws if the Wave failed to load.
47 */
48 WaveUnmanaged(const std::string& fileType, const unsigned char* fileData, int dataSize) {
49 Load(fileType, fileData, dataSize);
50 }
51
52 GETTER(unsigned int, FrameCount, frameCount)
53 GETTER(unsigned int, SampleRate, sampleRate)
54 GETTER(unsigned int, SampleSize, sampleSize)
55 GETTER(unsigned int, Channels, channels)
56 GETTER(void*, Data, data)
57
58 WaveUnmanaged& operator=(const ::Wave& wave) {
59 set(wave);
60 return *this;
61 }
62
63 [[nodiscard]] std::string ToString() const {
64 return TextFormat(
65 "Wave(frameCount=%u, sampleRate=%u, sampleSize=%u, channels=%u, data=%p)",
66 frameCount, sampleRate, sampleSize, channels, data
67 );
68 }
69
70 operator std::string() const { return ToString(); }
71
72 /**
73 * Load wave data from file.
74 *
75 * @throws raylib::RaylibException Throws if the Wave failed to load.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected