# Amuse: include/amuse/BooBackend.hpp Source File

BooBackend.hpp
#ifndef __AMUSE_BOO_BACKEND_HPP__
#define __AMUSE_BOO_BACKEND_HPP__
#include <boo/audiodev/IAudioVoiceEngine.hpp>
#include <boo/audiodev/IAudioSubmix.hpp>
#include "IBackendVoice.hpp"
#include "IBackendSubmix.hpp"
#include "IBackendVoiceAllocator.hpp"
namespace amuse
{
class BooBackendVoice : public IBackendVoice
{
friend class BooBackendVoiceAllocator;
Voice& m_clientVox;
struct VoiceCallback : boo::IAudioVoiceCallback
{
BooBackendVoice& m_parent;
size_t supplyAudio(boo::IAudioVoice& voice, size_t frames, int16_t* data);
VoiceCallback(BooBackendVoice& parent) : m_parent(parent) {}
} m_cb;
std::unique_ptr<boo::IAudioVoice> m_booVoice;
public:
BooBackendVoice(boo::IAudioVoiceEngine& engine, Voice& clientVox,
double sampleRate, bool dynamicPitch);
BooBackendVoice(boo::IAudioSubmix& submix, Voice& clientVox,
double sampleRate, bool dynamicPitch);
void resetSampleRate(double sampleRate);
void setMatrixCoefficients(const float coefs[8]);
void setPitchRatio(double ratio, bool slew);
void start();
void stop();
};
class BooBackendSubmix : public IBackendSubmix
{
friend class BooBackendVoiceAllocator;
Submix& m_clientSmx;
struct SubmixCallback : boo::IAudioSubmixCallback
{
BooBackendSubmix& m_parent;
bool canApplyEffect() const;
void applyEffect(int16_t* audio, size_t frameCount,
const boo::ChannelMap& chanMap, double sampleRate) const;
void applyEffect(int32_t* audio, size_t frameCount,
const boo::ChannelMap& chanMap, double sampleRate) const;
void applyEffect(float* audio, size_t frameCount,
const boo::ChannelMap& chanMap, double sampleRate) const;
SubmixCallback(BooBackendSubmix& parent) : m_parent(parent) {}
} m_cb;
std::unique_ptr<boo::IAudioSubmix> m_booSubmix;
public:
BooBackendSubmix(boo::IAudioVoiceEngine& engine, Submix& clientSmx);
BooBackendSubmix(boo::IAudioSubmix& parent, Submix& clientSmx);
void setChannelGains(const float gains[8]);
std::unique_ptr<IBackendVoice> allocateVoice(Voice& clientVox, double sampleRate, bool dynamicPitch);
double getSampleRate() const;
SubmixFormat getSampleFormat() const;
};
class BooBackendVoiceAllocator : public IBackendVoiceAllocator
{
boo::IAudioVoiceEngine& m_booEngine;
public:
BooBackendVoiceAllocator(boo::IAudioVoiceEngine& booEngine);
std::unique_ptr<IBackendVoice> allocateVoice(Voice& clientVox, double sampleRate, bool dynamicPitch);
std::unique_ptr<IBackendSubmix> allocateSubmix(Submix& clientSmx);
AudioChannelSet getAvailableSet();
void pumpAndMixVoices();
};
}
#endif // __AMUSE_BOO_BACKEND_HPP__
amuse::BooBackendVoice::resetSampleRate
void resetSampleRate(double sampleRate)
amuse::BooBackendVoice::start
void start()
amuse::BooBackendVoiceAllocator
Definition: BooBackend.hpp:65
amuse::IBackendVoice
Definition: IBackendVoice.hpp:29
amuse::BooBackendSubmix
Definition: BooBackend.hpp:38
amuse
Definition: AudioGroup.hpp:8
amuse::BooBackendVoice::stop
void stop()
amuse::BooBackendVoice::setMatrixCoefficients
void setMatrixCoefficients(const float coefs[8])
amuse::Voice
Definition: Voice.hpp:30
amuse::Submix
Definition: Submix.hpp:20
amuse::BooBackendVoice::setPitchRatio
void setPitchRatio(double ratio, bool slew)
amuse::IBackendSubmix
Definition: IBackendSubmix.hpp:19
amuse::IBackendVoiceAllocator
Definition: IBackendVoiceAllocator.hpp:24
amuse::BooBackendVoice
Definition: BooBackend.hpp:14