Max channel gain

This commit is contained in:
Iliyas Jorio 2022-06-02 18:59:48 +02:00
parent caa3414833
commit 88a3e4625b

View File

@ -2,6 +2,10 @@
#include "SoundMixer/ChannelImpl.h" #include "SoundMixer/ChannelImpl.h"
#include <cassert> #include <cassert>
#ifndef POMME_MAX_CHANNEL_GAIN
#define POMME_MAX_CHANNEL_GAIN 2.5
#endif
namespace Pomme::Sound namespace Pomme::Sound
{ {
extern ChannelImpl* gHeadChan; extern ChannelImpl* gHeadChan;
@ -61,6 +65,14 @@ void ChannelImpl::ApplyParametersToSource(int mask)
// Pan and gain // Pan and gain
if (mask & kApplyParameters_PanAndGain) if (mask & kApplyParameters_PanAndGain)
{ {
if (gain > POMME_MAX_CHANNEL_GAIN)
{
#if _DEBUG
printf("Capping extreme channel gain (%f)\n", gain);
#endif
gain = POMME_MAX_CHANNEL_GAIN;
}
source.SetPan(pan); source.SetPan(pan);
source.SetGain(gain); source.SetGain(gain);
} }