summaryrefslogtreecommitdiff
path: root/src/sound.h
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-23 20:23:03 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-03-24 04:24:26 +0200
commit6c14025b2d416105915440e114de927c26e925ac (patch)
tree64396513416935f2c0eaf50115a61856bbc0f7f2 /src/sound.h
parente53794868eaa33199a1f1011b2d5f517b6f68057 (diff)
downloadminetest-6c14025b2d416105915440e114de927c26e925ac.tar.gz
minetest-6c14025b2d416105915440e114de927c26e925ac.tar.bz2
minetest-6c14025b2d416105915440e114de927c26e925ac.zip
Add event manager and use it to trigger sounds
Diffstat (limited to 'src/sound.h')
-rw-r--r--src/sound.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/sound.h b/src/sound.h
index 72764345e..6363d614e 100644
--- a/src/sound.h
+++ b/src/sound.h
@@ -33,6 +33,18 @@ public:
std::set<std::vector<char> > &dst_datas) = 0;
};
+struct SimpleSoundSpec
+{
+ std::string name;
+ float gain;
+ SimpleSoundSpec(std::string name="", float gain=1.0):
+ name(name),
+ gain(gain)
+ {}
+ bool exists() {return name != "";}
+ // Serialization intentionally left out
+};
+
class ISoundManager
{
public:
@@ -47,6 +59,7 @@ public:
const std::vector<char> &filedata) = 0;
virtual void updateListener(v3f pos, v3f vel, v3f at, v3f up) = 0;
+
// playSound functions return -1 on failure, otherwise a handle to the
// sound
virtual int playSound(const std::string &name, bool loop,
@@ -54,6 +67,11 @@ public:
virtual int playSoundAt(const std::string &name, bool loop,
float volume, v3f pos) = 0;
virtual void stopSound(int sound) = 0;
+
+ int playSound(const SimpleSoundSpec &spec, bool loop)
+ { return playSound(spec.name, loop, spec.gain); }
+ int playSoundAt(const SimpleSoundSpec &spec, bool loop, v3f pos)
+ { return playSoundAt(spec.name, loop, spec.gain, pos); }
};
class DummySoundManager: public ISoundManager