mirror of https://github.com/AxioDL/amuse.git
Better volume handling
This commit is contained in:
parent
2e7345f11d
commit
aff8880595
|
@ -49,6 +49,7 @@ class Engine
|
|||
std::unordered_map<uint16_t, std::tuple<AudioGroup*, int, const SFXGroupIndex::SFXEntry*>> m_sfxLookup;
|
||||
std::linear_congruential_engine<uint32_t, 0x41c64e6d, 0x3039, UINT32_MAX> m_random;
|
||||
int m_nextVid = 0;
|
||||
float m_masterVolume = 1.f;
|
||||
|
||||
AudioGroup* _addAudioGroup(const AudioGroupData& data, std::unique_ptr<AudioGroup>&& grp);
|
||||
std::pair<AudioGroup*, const SongGroupIndex*> _findSongGroup(int groupId) const;
|
||||
|
|
|
@ -388,7 +388,7 @@ std::shared_ptr<Sequencer> Engine::seqPlay(int groupId, int songId, const unsign
|
|||
/** Set total volume of engine */
|
||||
void Engine::setVolume(float vol)
|
||||
{
|
||||
m_backend.setVolume(vol);
|
||||
m_masterVolume = vol;
|
||||
}
|
||||
|
||||
/** Find voice from VoiceId */
|
||||
|
|
|
@ -192,7 +192,7 @@ std::list<std::shared_ptr<Voice>>::iterator Voice::_destroyVoice(std::list<std::
|
|||
template <typename T>
|
||||
static T ApplyVolume(float vol, T samp)
|
||||
{
|
||||
return samp * 0.5f * vol;
|
||||
return samp * 0.7f * vol;
|
||||
}
|
||||
|
||||
void Voice::_procSamplePre(int16_t& samp)
|
||||
|
@ -219,7 +219,7 @@ void Voice::_procSamplePre(int16_t& samp)
|
|||
float l = clamp(0.f, m_lastLevel * (1.f - t) + m_nextLevel * t, 1.f);
|
||||
|
||||
/* Apply total volume to sample using decibel scale */
|
||||
samp = ApplyVolume(l, samp);
|
||||
samp = ApplyVolume(l * m_engine.m_masterVolume, samp);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ void Voice::_procSamplePre(int16_t& samp)
|
|||
m_nextLevel = clamp(0.f, m_nextLevel, 1.f);
|
||||
|
||||
/* Apply total volume to sample using decibel scale */
|
||||
samp = ApplyVolume(m_nextLevel, samp);
|
||||
samp = ApplyVolume(m_nextLevel * m_engine.m_masterVolume, samp);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
Loading…
Reference in New Issue