summary refs log tree commit diff stats
path: root/src/mixer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mixer.cpp')
-rw-r--r--src/mixer.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mixer.cpp b/src/mixer.cpp new file mode 100644 index 0000000..bfbedcd --- /dev/null +++ b/src/mixer.cpp
@@ -0,0 +1,16 @@
1#include "mixer.h"
2
3void Mixer::playSound(std::string filename) {
4 if (!sounds_.count(filename)) {
5 Mix_Chunk* sample = Mix_LoadWAV(filename.c_str());
6 if (!sample) {
7 throw mix_error();
8 }
9
10 sounds_[filename] = chunk_ptr(sample);
11 }
12
13 if (Mix_PlayChannel(-1, sounds_[filename].get(), 0) == -1) {
14 throw mix_error();
15 }
16}