mirror of https://github.com/AxioDL/boo.git
Add voice allocator master volume
This commit is contained in:
parent
85fa541f6a
commit
f35ccbaad5
|
@ -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<std::pair<std::string, std::string>> enumerateMIDIDevices() const=0;
|
||||
|
||||
|
|
|
@ -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<sampleCount ; ++i)
|
||||
dataOut[i] *= m_totalVol;
|
||||
|
||||
remFrames -= thisFrames;
|
||||
dataOut += thisFrames * m_mixInfo.m_channelMap.m_channelCount;
|
||||
dataOut += sampleCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,8 +97,12 @@ void BaseAudioVoiceEngine::_pumpAndMixVoices(size_t frames, int32_t* dataOut)
|
|||
for (auto it = m_linearizedSubmixes.rbegin() ; it != m_linearizedSubmixes.rend() ; ++it)
|
||||
(*it)->_pumpAndMix32(thisFrames);
|
||||
|
||||
size_t sampleCount = thisFrames * m_mixInfo.m_channelMap.m_channelCount;
|
||||
for (size_t i=0 ; i<sampleCount ; ++i)
|
||||
dataOut[i] *= m_totalVol;
|
||||
|
||||
remFrames -= thisFrames;
|
||||
dataOut += thisFrames * m_mixInfo.m_channelMap.m_channelCount;
|
||||
dataOut += sampleCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,8 +144,12 @@ void BaseAudioVoiceEngine::_pumpAndMixVoices(size_t frames, float* dataOut)
|
|||
for (auto it = m_linearizedSubmixes.rbegin() ; it != m_linearizedSubmixes.rend() ; ++it)
|
||||
(*it)->_pumpAndMixFlt(thisFrames);
|
||||
|
||||
size_t sampleCount = thisFrames * m_mixInfo.m_channelMap.m_channelCount;
|
||||
for (size_t i=0 ; i<sampleCount ; ++i)
|
||||
dataOut[i] *= m_totalVol;
|
||||
|
||||
remFrames -= thisFrames;
|
||||
dataOut += thisFrames * m_mixInfo.m_channelMap.m_channelCount;
|
||||
dataOut += sampleCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,6 +205,11 @@ void BaseAudioVoiceEngine::register5MsCallback(std::function<void(double dt)>&&
|
|||
m_5msCallback = std::move(callback);
|
||||
}
|
||||
|
||||
void BaseAudioVoiceEngine::setVolume(float vol)
|
||||
{
|
||||
m_totalVol = vol;
|
||||
}
|
||||
|
||||
const AudioVoiceEngineMixInfo& BaseAudioVoiceEngine::mixInfo() const
|
||||
{
|
||||
return m_mixInfo;
|
||||
|
|
|
@ -28,6 +28,7 @@ protected:
|
|||
friend class AudioSubmix;
|
||||
friend class AudioVoiceMono;
|
||||
friend class AudioVoiceStereo;
|
||||
float m_totalVol = 1.f;
|
||||
AudioVoiceEngineMixInfo m_mixInfo;
|
||||
std::list<AudioVoice*> m_activeVoices;
|
||||
std::list<AudioSubmix*> m_activeSubmixes;
|
||||
|
@ -69,6 +70,7 @@ public:
|
|||
|
||||
void register5MsCallback(std::function<void(double dt)>&& callback);
|
||||
|
||||
void setVolume(float vol);
|
||||
const AudioVoiceEngineMixInfo& mixInfo() const;
|
||||
AudioChannelSet getAvailableSet() {return m_mixInfo.m_channels;}
|
||||
void pumpAndMixVoices() {}
|
||||
|
|
Loading…
Reference in New Issue