2009-12-28 16:15:52 +00:00
|
|
|
#ifndef MANGLE_SOUND_AUDIERE_SOURCE_H
|
|
|
|
#define MANGLE_SOUND_AUDIERE_SOURCE_H
|
|
|
|
|
2010-08-16 12:13:13 +00:00
|
|
|
#include "sample_reader.hpp"
|
2009-12-28 16:15:52 +00:00
|
|
|
|
|
|
|
#include <audiere.h>
|
|
|
|
|
|
|
|
namespace Mangle {
|
|
|
|
namespace Sound {
|
|
|
|
|
|
|
|
/// A sample source that decodes files using Audiere
|
2010-08-16 12:13:13 +00:00
|
|
|
class AudiereSource : public SampleReader
|
2009-12-28 16:15:52 +00:00
|
|
|
{
|
|
|
|
audiere::SampleSourcePtr sample;
|
|
|
|
|
2010-08-16 12:13:13 +00:00
|
|
|
size_t readSamples(void *data, size_t length)
|
|
|
|
{ return sample->read(length, data); }
|
2009-12-28 16:15:52 +00:00
|
|
|
|
2010-08-16 12:13:13 +00:00
|
|
|
void doSetup();
|
2009-12-28 16:15:52 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/// Decode the given sound file
|
|
|
|
AudiereSource(const std::string &file);
|
|
|
|
|
|
|
|
/// Decode the given sound stream
|
2010-01-01 17:42:35 +00:00
|
|
|
AudiereSource(Mangle::Stream::StreamPtr src);
|
2009-12-28 16:15:52 +00:00
|
|
|
|
|
|
|
/// Read directly from an existing audiere::SampleSource
|
|
|
|
AudiereSource(audiere::SampleSourcePtr src);
|
|
|
|
|
|
|
|
void getInfo(int32_t *rate, int32_t *channels, int32_t *bits);
|
2009-12-30 11:36:35 +00:00
|
|
|
|
2010-01-01 17:42:35 +00:00
|
|
|
void seek(size_t pos) { sample->setPosition(pos/frameSize); }
|
|
|
|
size_t tell() const { return sample->getPosition()*frameSize; }
|
|
|
|
size_t size() const { return sample->getLength()*frameSize; }
|
2009-12-28 16:15:52 +00:00
|
|
|
};
|
|
|
|
|
2010-06-03 18:13:27 +00:00
|
|
|
#include "loadertemplate.hpp"
|
2009-12-28 16:15:52 +00:00
|
|
|
|
|
|
|
/// A factory that loads AudiereSources from file and stream
|
|
|
|
typedef SSL_Template<AudiereSource,true,true> AudiereLoader;
|
|
|
|
|
|
|
|
}} // Namespace
|
|
|
|
#endif
|