Overhauled audio system, now with internal mixing and sample-rate-conversion

This commit is contained in:
Jack Andersen
2016-03-23 14:01:57 -10:00
parent 5b275866a7
commit 1eb46301c0
13 changed files with 924 additions and 341 deletions

View File

@@ -0,0 +1,51 @@
#ifndef BOO_AUDIOVOICEENGINE_HPP
#define BOO_AUDIOVOICEENGINE_HPP
#include "boo/audiodev/IAudioVoiceEngine.hpp"
#include "AudioVoice.hpp"
namespace boo
{
/** Pertinent information from audio backend about optimal mixed-audio representation */
struct AudioVoiceEngineMixInfo
{
double m_sampleRate;
soxr_datatype_t m_sampleFormat;
unsigned m_bitsPerSample;
AudioChannelSet m_channels;
ChannelMap m_channelMap;
size_t m_periodFrames;
};
/** Base class for managing mixing and sample-rate-conversion amongst active voices */
class BaseAudioVoiceEngine : public IAudioVoiceEngine
{
protected:
friend class AudioVoice;
AudioVoiceEngineMixInfo m_mixInfo;
std::list<AudioVoice*> m_activeVoices;
void _pumpAndMixVoices(size_t frames, int16_t* dataOut);
void _pumpAndMixVoices(size_t frames, int32_t* dataOut);
void _pumpAndMixVoices(size_t frames, float* dataOut);
public:
BaseAudioVoiceEngine(const std::function<AudioVoiceEngineMixInfo()>& getEngineMixInfo);
std::unique_ptr<IAudioVoice> allocateNewMonoVoice(double sampleRate,
IAudioVoiceCallback* cb,
bool dynamicPitch=false);
std::unique_ptr<IAudioVoice> allocateNewStereoVoice(double sampleRate,
IAudioVoiceCallback* cb,
bool dynamicPitch=false);
const AudioVoiceEngineMixInfo& mixInfo() const {return m_mixInfo;}
AudioChannelSet getAvailableSet() {return m_mixInfo.m_channels;}
void pumpAndMixVoices() {}
};
}
#endif // BOO_AUDIOVOICEENGINE_HPP