mirror of
https://github.com/allankoechke/raylib-cpp.git
synced 2026-12-04 09:32:34 +00:00
Merge branch 'RobLoach:sound-constr' into sound-constr
This commit is contained in:
@@ -17,9 +17,15 @@ namespace raylib {
|
||||
*/
|
||||
class Sound : public ::Sound {
|
||||
public:
|
||||
Sound(const ::Sound& vec) {
|
||||
set(vec);
|
||||
}
|
||||
Sound(const Sound&) = delete;
|
||||
Sound& operator=(const Sound&) = delete;
|
||||
|
||||
Sound(Sound&& other) {
|
||||
set(other);
|
||||
|
||||
other.sampleCount = 0;
|
||||
other.stream = { 0, 0, 0, 0 };
|
||||
};
|
||||
|
||||
Sound(const std::string& fileName) {
|
||||
set(LoadSound(fileName.c_str()));
|
||||
@@ -36,10 +42,18 @@ class Sound : public ::Sound {
|
||||
GETTERSETTER(unsigned int, SampleCount, sampleCount)
|
||||
GETTERSETTER(::AudioStream, Stream, stream)
|
||||
|
||||
Sound& operator=(const ::Sound& sound) {
|
||||
set(sound);
|
||||
Sound& operator=(Sound&& other) {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Unload();
|
||||
set(other);
|
||||
other.sampleCount = 0;
|
||||
other.stream = { 0, 0, 0, 0 };
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Update sound buffer with new data
|
||||
|
||||
@@ -20,8 +20,9 @@ class Wave : public ::Wave {
|
||||
unsigned int sampleCount = 0,
|
||||
unsigned int sampleRate = 0,
|
||||
unsigned int sampleSize = 0,
|
||||
unsigned int channels = 0
|
||||
) : ::Wave{sampleCount, sampleRate, sampleSize, channels} { }
|
||||
unsigned int channels = 0,
|
||||
void *data = NULL
|
||||
) : ::Wave{sampleCount, sampleRate, sampleSize, channels, data} { }
|
||||
|
||||
/**
|
||||
* Load wave data from file
|
||||
@@ -132,13 +133,6 @@ class Wave : public ::Wave {
|
||||
return LoadSound();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load sound from wave data
|
||||
*/
|
||||
inline operator Sound() {
|
||||
return LoadSound();
|
||||
}
|
||||
|
||||
private:
|
||||
inline void set(const ::Wave& wave) {
|
||||
sampleCount = wave.sampleCount;
|
||||
|
||||
@@ -32,6 +32,12 @@ int main() {
|
||||
std::vector<std::string> files = raylib::GetDirectoryFiles(::GetWorkingDirectory());
|
||||
assert(files.size() > 3);
|
||||
|
||||
// Sound
|
||||
{
|
||||
raylib::Sound sound("resources/weird.wav");
|
||||
sound.Play();
|
||||
}
|
||||
|
||||
std::cout << "Tests complete" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
BIN
tests/resources/weird.wav
Normal file
BIN
tests/resources/weird.wav
Normal file
Binary file not shown.
Reference in New Issue
Block a user