Added pure sound filters

This commit is contained in:
Nicolay Korslund 2010-08-05 12:35:17 +02:00
parent e181b71cc9
commit 3a6912b04c
2 changed files with 70 additions and 2 deletions

View file

@ -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

View file

@ -2,8 +2,9 @@
#define MANGLE_SOUND_OUTPUT_H
#include <string>
#include "source.hpp"
#include <assert.h>
#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)
/**