2016-05-03 01:16:26 +00:00
|
|
|
#include "amuse/BooBackend.hpp"
|
|
|
|
#include "amuse/Voice.hpp"
|
2016-05-07 22:10:57 +00:00
|
|
|
#include "amuse/Submix.hpp"
|
2016-05-03 01:16:26 +00:00
|
|
|
|
|
|
|
namespace amuse
|
|
|
|
{
|
|
|
|
|
|
|
|
size_t BooBackendVoice::VoiceCallback::supplyAudio(boo::IAudioVoice&,
|
|
|
|
size_t frames, int16_t* data)
|
|
|
|
{
|
|
|
|
return m_parent.m_clientVox.supplyAudio(frames, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
BooBackendVoice::BooBackendVoice(boo::IAudioVoiceEngine& engine, Voice& clientVox,
|
|
|
|
double sampleRate, bool dynamicPitch)
|
|
|
|
: m_clientVox(clientVox), m_cb(*this),
|
|
|
|
m_booVoice(engine.allocateNewMonoVoice(sampleRate, &m_cb, dynamicPitch))
|
|
|
|
{}
|
|
|
|
|
2016-05-07 22:10:57 +00:00
|
|
|
BooBackendVoice::BooBackendVoice(boo::IAudioSubmix& submix, Voice& clientVox,
|
|
|
|
double sampleRate, bool dynamicPitch)
|
|
|
|
: m_clientVox(clientVox), m_cb(*this),
|
|
|
|
m_booVoice(submix.allocateNewMonoVoice(sampleRate, &m_cb, dynamicPitch))
|
|
|
|
{}
|
|
|
|
|
2016-05-11 04:48:08 +00:00
|
|
|
void BooBackendVoice::resetSampleRate(double sampleRate)
|
|
|
|
{
|
|
|
|
m_booVoice->resetSampleRate(sampleRate);
|
|
|
|
}
|
|
|
|
|
2016-05-03 01:16:26 +00:00
|
|
|
void BooBackendVoice::setMatrixCoefficients(const float coefs[8])
|
|
|
|
{
|
|
|
|
m_booVoice->setMonoMatrixCoefficients(coefs);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BooBackendVoice::setPitchRatio(double ratio)
|
|
|
|
{
|
|
|
|
m_booVoice->setPitchRatio(ratio);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BooBackendVoice::start()
|
|
|
|
{
|
|
|
|
m_booVoice->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BooBackendVoice::stop()
|
|
|
|
{
|
|
|
|
m_booVoice->stop();
|
|
|
|
}
|
|
|
|
|
2016-05-07 22:10:57 +00:00
|
|
|
bool BooBackendSubmix::SubmixCallback::canApplyEffect() const
|
|
|
|
{
|
|
|
|
return m_parent.m_clientSmx.canApplyEffect();
|
|
|
|
}
|
|
|
|
|
2016-05-08 05:19:27 +00:00
|
|
|
void BooBackendSubmix::SubmixCallback::applyEffect(int16_t* audio, size_t frameCount,
|
2016-05-14 04:46:39 +00:00
|
|
|
const boo::ChannelMap& chanMap, double) const
|
2016-05-07 22:10:57 +00:00
|
|
|
{
|
2016-05-14 04:46:39 +00:00
|
|
|
return m_parent.m_clientSmx.applyEffect(audio, frameCount, reinterpret_cast<const ChannelMap&>(chanMap));
|
2016-05-07 22:10:57 +00:00
|
|
|
}
|
|
|
|
|
2016-05-08 05:19:27 +00:00
|
|
|
void BooBackendSubmix::SubmixCallback::applyEffect(int32_t* audio, size_t frameCount,
|
2016-05-14 04:46:39 +00:00
|
|
|
const boo::ChannelMap& chanMap, double) const
|
2016-05-07 22:10:57 +00:00
|
|
|
{
|
2016-05-14 04:46:39 +00:00
|
|
|
return m_parent.m_clientSmx.applyEffect(audio, frameCount, reinterpret_cast<const ChannelMap&>(chanMap));
|
2016-05-07 22:10:57 +00:00
|
|
|
}
|
|
|
|
|
2016-05-08 05:19:27 +00:00
|
|
|
void BooBackendSubmix::SubmixCallback::applyEffect(float* audio, size_t frameCount,
|
2016-05-14 04:46:39 +00:00
|
|
|
const boo::ChannelMap& chanMap, double) const
|
2016-05-07 22:10:57 +00:00
|
|
|
{
|
2016-05-14 04:46:39 +00:00
|
|
|
return m_parent.m_clientSmx.applyEffect(audio, frameCount, reinterpret_cast<const ChannelMap&>(chanMap));
|
2016-05-07 22:10:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BooBackendSubmix::BooBackendSubmix(boo::IAudioVoiceEngine& engine, Submix& clientSmx)
|
|
|
|
: m_clientSmx(clientSmx), m_cb(*this), m_booSubmix(engine.allocateNewSubmix(&m_cb))
|
|
|
|
{}
|
|
|
|
|
|
|
|
BooBackendSubmix::BooBackendSubmix(boo::IAudioSubmix& parent, Submix& clientSmx)
|
|
|
|
: m_clientSmx(clientSmx), m_cb(*this), m_booSubmix(parent.allocateNewSubmix(&m_cb))
|
|
|
|
{}
|
|
|
|
|
|
|
|
void BooBackendSubmix::setChannelGains(const float gains[8])
|
|
|
|
{
|
|
|
|
m_booSubmix->setChannelGains(gains);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<IBackendVoice>
|
|
|
|
BooBackendSubmix::allocateVoice(Voice& clientVox, double sampleRate, bool dynamicPitch)
|
|
|
|
{
|
|
|
|
return std::make_unique<BooBackendVoice>(*m_booSubmix, clientVox, sampleRate, dynamicPitch);
|
|
|
|
}
|
|
|
|
|
2016-05-14 04:46:39 +00:00
|
|
|
double BooBackendSubmix::getSampleRate() const
|
|
|
|
{
|
|
|
|
return m_booSubmix->getSampleRate();
|
|
|
|
}
|
|
|
|
|
|
|
|
SubmixFormat BooBackendSubmix::getSampleFormat() const
|
|
|
|
{
|
|
|
|
return SubmixFormat(m_booSubmix->getSampleFormat());
|
|
|
|
}
|
|
|
|
|
2016-05-03 01:16:26 +00:00
|
|
|
BooBackendVoiceAllocator::BooBackendVoiceAllocator(boo::IAudioVoiceEngine& booEngine)
|
|
|
|
: m_booEngine(booEngine)
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::unique_ptr<IBackendVoice>
|
|
|
|
BooBackendVoiceAllocator::allocateVoice(Voice& clientVox, double sampleRate, bool dynamicPitch)
|
|
|
|
{
|
|
|
|
return std::make_unique<BooBackendVoice>(m_booEngine, clientVox, sampleRate, dynamicPitch);
|
|
|
|
}
|
|
|
|
|
2016-05-07 22:10:57 +00:00
|
|
|
std::unique_ptr<IBackendSubmix> BooBackendVoiceAllocator::allocateSubmix(Submix& clientSmx)
|
|
|
|
{
|
|
|
|
return std::make_unique<BooBackendSubmix>(m_booEngine, clientSmx);
|
|
|
|
}
|
|
|
|
|
2016-05-11 04:48:08 +00:00
|
|
|
AudioChannelSet BooBackendVoiceAllocator::getAvailableSet()
|
|
|
|
{
|
|
|
|
return AudioChannelSet(m_booEngine.getAvailableSet());
|
|
|
|
}
|
|
|
|
|
2016-05-14 04:46:39 +00:00
|
|
|
void BooBackendVoiceAllocator::pumpAndMixVoices()
|
|
|
|
{
|
|
|
|
m_booEngine.pumpAndMixVoices();
|
|
|
|
}
|
|
|
|
|
2016-05-03 01:16:26 +00:00
|
|
|
}
|