Implement AudioSubmix

This commit is contained in:
Jack Andersen
2016-05-06 18:28:32 -10:00
parent 4ecea8ac3f
commit 4b969fd475
12 changed files with 396 additions and 43 deletions

View File

@@ -0,0 +1,46 @@
#ifndef BOO_IAUDIOSUBMIX_HPP
#define BOO_IAUDIOSUBMIX_HPP
#include <stddef.h>
#include <stdint.h>
#include <memory>
namespace boo
{
class IAudioVoice;
class IAudioVoiceCallback;
struct ChannelMap;
struct IAudioSubmixCallback;
struct IAudioSubmix
{
virtual ~IAudioSubmix() = default;
/** Same as the IAudioVoice allocator, but produces audio within the submix */
virtual std::unique_ptr<IAudioVoice> allocateNewMonoVoice(double sampleRate,
IAudioVoiceCallback* cb,
bool dynamicPitch=false)=0;
/** Same as allocateNewMonoVoice, but source audio is stereo-interleaved */
virtual std::unique_ptr<IAudioVoice> allocateNewStereoVoice(double sampleRate,
IAudioVoiceCallback* cb,
bool dynamicPitch=false)=0;
/** Same as the IAudioVoice allocator, but produces audio recursively within the submix */
virtual std::unique_ptr<IAudioSubmix> allocateNewSubmix(IAudioSubmixCallback* cb=nullptr)=0;
};
struct IAudioSubmixCallback
{
/** Client-provided claim to implement / is ready to call applyEffect() */
virtual bool canApplyEffect() const=0;
/** Client-provided effect solution for interleaved, master sample-rate audio */
virtual void applyEffect(int16_t* audio, const ChannelMap& chanMap, double sampleRate) const=0;
virtual void applyEffect(int32_t* audio, const ChannelMap& chanMap, double sampleRate) const=0;
virtual void applyEffect(float* audio, const ChannelMap& chanMap, double sampleRate) const=0;
};
}
#endif // BOO_IAUDIOVOICE_HPP

View File

@@ -2,6 +2,7 @@
#define BOO_IAUDIOVOICEENGINE_HPP
#include "IAudioVoice.hpp"
#include "IAudioSubmix.hpp"
#include <memory>
namespace boo
@@ -18,7 +19,8 @@ struct IAudioVoiceEngine
* ChannelLayout automatically reduces to maximum-supported layout by HW.
*
* Client must be prepared to supply audio frames via the callback when this is called;
* the backing audio-buffers are primed with initial data for low-latency playback start */
* the backing audio-buffers are primed with initial data for low-latency playback start
*/
virtual std::unique_ptr<IAudioVoice> allocateNewMonoVoice(double sampleRate,
IAudioVoiceCallback* cb,
bool dynamicPitch=false)=0;
@@ -28,6 +30,9 @@ struct IAudioVoiceEngine
IAudioVoiceCallback* cb,
bool dynamicPitch=false)=0;
/** Client calls this to allocate a Submix for gathering audio together for effects processing */
virtual std::unique_ptr<IAudioSubmix> allocateNewSubmix(IAudioSubmixCallback* cb=nullptr)=0;
/** Client may use this to determine current speaker-setup */
virtual AudioChannelSet getAvailableSet()=0;