mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 14:08:19 +00:00
Fix incorrect channel panning value after changing volume
Fix incorrect panning value (`1.0f`) being set for GUI and Global sound channels after sound volume is changed, whereas the panning value is initialized to `0.0f`. Now the panning value is set to `0.0f` consistently. This should not have had any effect, as GUI and Global sounds do not have a position which would be affected by the panning value.
This commit is contained in:
parent
6c6fd86d1d
commit
e0e1ef8001
|
@ -43,6 +43,38 @@ void CSoundLoading::Run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSounds::UpdateChannels()
|
||||||
|
{
|
||||||
|
const float NewGuiSoundVolume = g_Config.m_SndChatSoundVolume / 100.0f;
|
||||||
|
if(NewGuiSoundVolume != m_GuiSoundVolume)
|
||||||
|
{
|
||||||
|
m_GuiSoundVolume = NewGuiSoundVolume;
|
||||||
|
Sound()->SetChannel(CSounds::CHN_GUI, m_GuiSoundVolume, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float NewGameSoundVolume = g_Config.m_SndGameSoundVolume / 100.0f;
|
||||||
|
if(NewGameSoundVolume != m_GameSoundVolume)
|
||||||
|
{
|
||||||
|
m_GameSoundVolume = NewGameSoundVolume;
|
||||||
|
Sound()->SetChannel(CSounds::CHN_WORLD, 0.9f * m_GameSoundVolume, 1.0f);
|
||||||
|
Sound()->SetChannel(CSounds::CHN_GLOBAL, m_GameSoundVolume, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float NewMapSoundVolume = g_Config.m_SndMapSoundVolume / 100.0f;
|
||||||
|
if(NewMapSoundVolume != m_MapSoundVolume)
|
||||||
|
{
|
||||||
|
m_MapSoundVolume = NewMapSoundVolume;
|
||||||
|
Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
const float NewBackgroundMusicVolume = g_Config.m_SndBackgroundMusicVolume / 100.0f;
|
||||||
|
if(NewBackgroundMusicVolume != m_BackgroundMusicVolume)
|
||||||
|
{
|
||||||
|
m_BackgroundMusicVolume = NewBackgroundMusicVolume;
|
||||||
|
Sound()->SetChannel(CSounds::CHN_MUSIC, m_BackgroundMusicVolume, 1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int CSounds::GetSampleId(int SetId)
|
int CSounds::GetSampleId(int SetId)
|
||||||
{
|
{
|
||||||
if(!g_Config.m_SndEnable || !Sound()->IsSoundEnabled() || m_WaitForSoundJob || SetId < 0 || SetId >= g_pData->m_NumSounds)
|
if(!g_Config.m_SndEnable || !Sound()->IsSoundEnabled() || m_WaitForSoundJob || SetId < 0 || SetId >= g_pData->m_NumSounds)
|
||||||
|
@ -67,18 +99,7 @@ int CSounds::GetSampleId(int SetId)
|
||||||
|
|
||||||
void CSounds::OnInit()
|
void CSounds::OnInit()
|
||||||
{
|
{
|
||||||
// setup sound channels
|
UpdateChannels();
|
||||||
m_GuiSoundVolume = g_Config.m_SndChatSoundVolume / 100.0f;
|
|
||||||
m_GameSoundVolume = g_Config.m_SndGameSoundVolume / 100.0f;
|
|
||||||
m_MapSoundVolume = g_Config.m_SndMapSoundVolume / 100.0f;
|
|
||||||
m_BackgroundMusicVolume = g_Config.m_SndBackgroundMusicVolume / 100.0f;
|
|
||||||
|
|
||||||
Sound()->SetChannel(CSounds::CHN_GUI, m_GuiSoundVolume, 0.0f);
|
|
||||||
Sound()->SetChannel(CSounds::CHN_MUSIC, m_BackgroundMusicVolume, 1.0f);
|
|
||||||
Sound()->SetChannel(CSounds::CHN_WORLD, 0.9f * m_GameSoundVolume, 1.0f);
|
|
||||||
Sound()->SetChannel(CSounds::CHN_GLOBAL, m_GameSoundVolume, 0.0f);
|
|
||||||
Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.0f);
|
|
||||||
|
|
||||||
ClearQueue();
|
ClearQueue();
|
||||||
|
|
||||||
// load sounds
|
// load sounds
|
||||||
|
@ -125,35 +146,7 @@ void CSounds::OnRender()
|
||||||
// set listener pos
|
// set listener pos
|
||||||
Sound()->SetListenerPos(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y);
|
Sound()->SetListenerPos(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y);
|
||||||
|
|
||||||
// update volume
|
UpdateChannels();
|
||||||
float NewGuiSoundVol = g_Config.m_SndChatSoundVolume / 100.0f;
|
|
||||||
if(NewGuiSoundVol != m_GuiSoundVolume)
|
|
||||||
{
|
|
||||||
m_GuiSoundVolume = NewGuiSoundVol;
|
|
||||||
Sound()->SetChannel(CSounds::CHN_GUI, m_GuiSoundVolume, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
float NewGameSoundVol = g_Config.m_SndGameSoundVolume / 100.0f;
|
|
||||||
if(NewGameSoundVol != m_GameSoundVolume)
|
|
||||||
{
|
|
||||||
m_GameSoundVolume = NewGameSoundVol;
|
|
||||||
Sound()->SetChannel(CSounds::CHN_WORLD, 0.9f * m_GameSoundVolume, 1.0f);
|
|
||||||
Sound()->SetChannel(CSounds::CHN_GLOBAL, m_GameSoundVolume, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
float NewMapSoundVol = g_Config.m_SndMapSoundVolume / 100.0f;
|
|
||||||
if(NewMapSoundVol != m_MapSoundVolume)
|
|
||||||
{
|
|
||||||
m_MapSoundVolume = NewMapSoundVol;
|
|
||||||
Sound()->SetChannel(CSounds::CHN_MAPSOUND, m_MapSoundVolume, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
float NewBackgroundMusicVol = g_Config.m_SndBackgroundMusicVolume / 100.0f;
|
|
||||||
if(NewBackgroundMusicVol != m_BackgroundMusicVolume)
|
|
||||||
{
|
|
||||||
m_BackgroundMusicVolume = NewBackgroundMusicVol;
|
|
||||||
Sound()->SetChannel(CSounds::CHN_MUSIC, m_BackgroundMusicVolume, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
// play sound from queue
|
// play sound from queue
|
||||||
if(m_QueuePos > 0)
|
if(m_QueuePos > 0)
|
||||||
|
|
|
@ -34,12 +34,13 @@ class CSounds : public CComponent
|
||||||
std::shared_ptr<CSoundLoading> m_pSoundJob;
|
std::shared_ptr<CSoundLoading> m_pSoundJob;
|
||||||
bool m_WaitForSoundJob;
|
bool m_WaitForSoundJob;
|
||||||
|
|
||||||
|
void UpdateChannels();
|
||||||
int GetSampleId(int SetId);
|
int GetSampleId(int SetId);
|
||||||
|
|
||||||
float m_GuiSoundVolume;
|
float m_GuiSoundVolume = -1.0f;
|
||||||
float m_GameSoundVolume;
|
float m_GameSoundVolume = -1.0f;
|
||||||
float m_MapSoundVolume;
|
float m_MapSoundVolume = -1.0f;
|
||||||
float m_BackgroundMusicVolume;
|
float m_BackgroundMusicVolume = -1.0f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// sound channels
|
// sound channels
|
||||||
|
|
Loading…
Reference in a new issue