diff --git a/sound/filters/pure_filter.hpp b/sound/filters/pure_filter.hpp new file mode 100644 index 0000000000..5238d788a7 --- /dev/null +++ b/sound/filters/pure_filter.hpp @@ -0,0 +1,67 @@ +#ifndef MANGLE_SOUND_OUTPUT_PUREFILTER_H +#define MANGLE_SOUND_OUTPUT_PUREFILTER_H + +#include "../output.hpp" + +namespace Mangle +{ + namespace Sound + { + // For use in writing other filters + class SoundFilter : public Sound + { + SoundPtr client; + + public: + SoundFilter(SoundPtr c) : client(c) {} + void play() { client->play(); } + void stop() { client->stop(); } + void pause() { client->pause(); } + bool isPlaying() const { return client->isPlaying(); } + void setVolume(float f) { client->setVolume(f); } + void setPan(float f) { client->setPan(f); } + void setPos(float x, float y, float z) + { client->setPos(x,y,z); } + void setRepeat(bool b) { client->setRepeat(b); } + void setStreaming(bool b) { client->setStreaming(b); } + + // The clone() function is not implemented here, as you will + // almost certainly want to override it yourself + }; + + class FactoryFilter : public SoundFactory + { + SoundFactoryPtr client; + + public: + FactoryFilter(SoundFactoryPtr c) : client(c) + { + needsUpdate = client->needsUpdate; + has3D = client->has3D; + canLoadFile = client->canLoadFile; + canLoadStream = client->canLoadStream; + canLoadSource = client->canLoadSource; + } + + SoundPtr loadRaw(SampleSourcePtr input) + { return client->loadRaw(input); } + + SoundPtr load(Stream::StreamPtr input) + { return client->load(input); } + + SoundPtr load(const std::string &file) + { return client->load(file); } + + void update() + { client->update(); } + + void setListenerPos(float x, float y, float z, + float fx, float fy, float fz, + float ux, float uy, float uz) + { + client->setListenerPos(x,y,z,fx,fy,fz,ux,uy,uz); + } + }; + } +} +#endif diff --git a/sound/output.hpp b/sound/output.hpp index 2ead277bcc..404dcf4f8d 100644 --- a/sound/output.hpp +++ b/sound/output.hpp @@ -2,8 +2,9 @@ #define MANGLE_SOUND_OUTPUT_H #include -#include "source.hpp" +#include +#include "source.hpp" #include "../stream/stream.hpp" namespace Mangle { @@ -149,7 +150,7 @@ class SoundFactory buffers and similar tasks. Implementations that do not need this should set needsUpdate to false. */ - virtual void update() = 0; + virtual void update() { assert(0); } /// Set listener position (coordinates, front and up vectors) /**