From f35ccbaad526da1d152b48b151a6684296ecf567 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 13 Jul 2016 20:16:40 -1000 Subject: [PATCH] Add voice allocator master volume --- include/boo/audiodev/IAudioVoiceEngine.hpp | 3 +++ lib/audiodev/AudioVoiceEngine.cpp | 23 +++++++++++++++++++--- lib/audiodev/AudioVoiceEngine.hpp | 2 ++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/boo/audiodev/IAudioVoiceEngine.hpp b/include/boo/audiodev/IAudioVoiceEngine.hpp index c98d9f0..d539626 100644 --- a/include/boo/audiodev/IAudioVoiceEngine.hpp +++ b/include/boo/audiodev/IAudioVoiceEngine.hpp @@ -44,6 +44,9 @@ struct IAudioVoiceEngine /** Ensure backing platform buffer is filled as much as possible with mixed samples */ virtual void pumpAndMixVoices()=0; + /** Set total volume of engine */ + virtual void setVolume(float vol)=0; + /** Get list of MIDI devices found on system */ virtual std::vector> enumerateMIDIDevices() const=0; diff --git a/lib/audiodev/AudioVoiceEngine.cpp b/lib/audiodev/AudioVoiceEngine.cpp index bcb7d33..8b8c96e 100644 --- a/lib/audiodev/AudioVoiceEngine.cpp +++ b/lib/audiodev/AudioVoiceEngine.cpp @@ -50,8 +50,12 @@ void BaseAudioVoiceEngine::_pumpAndMixVoices(size_t frames, int16_t* dataOut) for (auto it = m_linearizedSubmixes.rbegin() ; it != m_linearizedSubmixes.rend() ; ++it) (*it)->_pumpAndMix16(thisFrames); + size_t sampleCount = thisFrames * m_mixInfo.m_channelMap.m_channelCount; + for (size_t i=0 ; i_pumpAndMix32(thisFrames); + size_t sampleCount = thisFrames * m_mixInfo.m_channelMap.m_channelCount; + for (size_t i=0 ; i_pumpAndMixFlt(thisFrames); + size_t sampleCount = thisFrames * m_mixInfo.m_channelMap.m_channelCount; + for (size_t i=0 ; i&& m_5msCallback = std::move(callback); } +void BaseAudioVoiceEngine::setVolume(float vol) +{ + m_totalVol = vol; +} + const AudioVoiceEngineMixInfo& BaseAudioVoiceEngine::mixInfo() const { return m_mixInfo; diff --git a/lib/audiodev/AudioVoiceEngine.hpp b/lib/audiodev/AudioVoiceEngine.hpp index 3b736ca..55ee3de 100644 --- a/lib/audiodev/AudioVoiceEngine.hpp +++ b/lib/audiodev/AudioVoiceEngine.hpp @@ -28,6 +28,7 @@ protected: friend class AudioSubmix; friend class AudioVoiceMono; friend class AudioVoiceStereo; + float m_totalVol = 1.f; AudioVoiceEngineMixInfo m_mixInfo; std::list m_activeVoices; std::list m_activeSubmixes; @@ -69,6 +70,7 @@ public: void register5MsCallback(std::function&& callback); + void setVolume(float vol); const AudioVoiceEngineMixInfo& mixInfo() const; AudioChannelSet getAvailableSet() {return m_mixInfo.m_channels;} void pumpAndMixVoices() {}