diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp index cfd2b9e278..5ea79319de 100644 --- a/Source/Core/AudioCommon/AudioCommon.cpp +++ b/Source/Core/AudioCommon/AudioCommon.cpp @@ -27,6 +27,9 @@ static bool s_audio_dump_start = false; namespace AudioCommon { + static const int AUDIO_VOLUME_MIN = 0; + static const int AUDIO_VOLUME_MAX = 100; + SoundStream* InitSoundStream() { CMixer *mixer = new CMixer(48000); @@ -140,11 +143,13 @@ namespace AudioCommon } } } + void UpdateSoundStream() { if (g_sound_stream) { - g_sound_stream->SetVolume(SConfig::GetInstance().m_Volume); + int volume = SConfig::GetInstance().m_IsMuted ? 0 : SConfig::GetInstance().m_Volume; + g_sound_stream->SetVolume(volume); } } @@ -191,4 +196,31 @@ namespace AudioCommon g_sound_stream->GetMixer()->StopLogDSPAudio(); s_audio_dump_start = false; } + + void IncreaseVolume(unsigned short offset) + { + SConfig::GetInstance().m_IsMuted = false; + int& currentVolume = SConfig::GetInstance().m_Volume; + currentVolume += offset; + if (currentVolume > AUDIO_VOLUME_MAX) + currentVolume = AUDIO_VOLUME_MAX; + UpdateSoundStream(); + } + + void DecreaseVolume(unsigned short offset) + { + SConfig::GetInstance().m_IsMuted = false; + int& currentVolume = SConfig::GetInstance().m_Volume; + currentVolume -= offset; + if (currentVolume < AUDIO_VOLUME_MIN) + currentVolume = AUDIO_VOLUME_MIN; + UpdateSoundStream(); + } + + void ToggleMuteVolume() + { + bool& isMuted = SConfig::GetInstance().m_IsMuted; + isMuted = !isMuted; + UpdateSoundStream(); + } } diff --git a/Source/Core/AudioCommon/AudioCommon.h b/Source/Core/AudioCommon/AudioCommon.h index 6042562790..a56c116e2f 100644 --- a/Source/Core/AudioCommon/AudioCommon.h +++ b/Source/Core/AudioCommon/AudioCommon.h @@ -23,4 +23,7 @@ namespace AudioCommon void SendAIBuffer(short* samples, unsigned int num_samples); void StartAudioDump(); void StopAudioDump(); + void IncreaseVolume(unsigned short offset); + void DecreaseVolume(unsigned short offset); + void ToggleMuteVolume(); } diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 7e673047ca..5b241570a2 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -62,6 +62,11 @@ static const struct { "Wiimote4Connect", 347 /* WXK_F8 */, 1 /* wxMOD_ALT */ }, { "BalanceBoardConnect",348 /* WXK_F9 */, 1 /* wxMOD_ALT */ }, #endif + + { "VolumeUp", 0, 0 /* wxMOD_NONE */ }, + { "VolumeDown", 0, 0 /* wxMOD_NONE */ }, + { "VolumeToggleMute", 0, 0 /* wxMOD_NONE */ }, + { "ToggleIR", 0, 0 /* wxMOD_NONE */ }, { "ToggleAspectRatio", 0, 0 /* wxMOD_NONE */ }, { "ToggleEFBCopies", 0, 0 /* wxMOD_NONE */ }, @@ -609,6 +614,8 @@ void SConfig::LoadDSPSettings(IniFile& ini) #endif dsp->Get("Volume", &m_Volume, 100); dsp->Get("CaptureLog", &m_DSPCaptureLog, false); + + m_IsMuted = false; } void SConfig::LoadInputSettings(IniFile& ini) diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index badf3fe04b..bd8aaaed06 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -102,6 +102,7 @@ struct SConfig : NonCopyable bool m_DSPEnableJIT; bool m_DSPCaptureLog; bool m_DumpAudio; + bool m_IsMuted; int m_Volume; std::string sBackend; diff --git a/Source/Core/Core/CoreParameter.h b/Source/Core/Core/CoreParameter.h index 16dbac969d..3e96c7543f 100644 --- a/Source/Core/Core/CoreParameter.h +++ b/Source/Core/Core/CoreParameter.h @@ -34,6 +34,10 @@ enum Hotkey HK_WIIMOTE4_CONNECT, HK_BALANCEBOARD_CONNECT, + HK_VOLUME_UP, + HK_VOLUME_DOWN, + HK_VOLUME_TOGGLE_MUTE, + HK_TOGGLE_IR, HK_TOGGLE_AR, HK_TOGGLE_EFBCOPIES, diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 8c5b2c247d..cc205ecbf8 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -64,6 +64,8 @@ #include "VideoCommon/VertexShaderManager.h" #include "VideoCommon/VideoConfig.h" +#include "AudioCommon/AudioCommon.h" + // Resources extern "C" { @@ -1059,6 +1061,12 @@ void CFrame::OnKeyDown(wxKeyEvent& event) Core::SaveScreenShot(); else if (IsHotkey(event, HK_EXIT)) wxPostEvent(this, wxCommandEvent(wxID_EXIT)); + else if (IsHotkey(event, HK_VOLUME_UP)) + AudioCommon::IncreaseVolume(3); + else if (IsHotkey(event, HK_VOLUME_DOWN)) + AudioCommon::DecreaseVolume(3); + else if (IsHotkey(event, HK_VOLUME_TOGGLE_MUTE)) + AudioCommon::ToggleMuteVolume(); // Wiimote connect and disconnect hotkeys else if (IsHotkey(event, HK_WIIMOTE1_CONNECT)) WiimoteId = 0; diff --git a/Source/Core/DolphinWX/HotkeyDlg.cpp b/Source/Core/DolphinWX/HotkeyDlg.cpp index f346991a55..dbc4ba5630 100644 --- a/Source/Core/DolphinWX/HotkeyDlg.cpp +++ b/Source/Core/DolphinWX/HotkeyDlg.cpp @@ -219,6 +219,10 @@ void HotkeyConfigDialog::CreateHotkeyGUIControls() _("Connect Wiimote 4"), _("Connect Balance Board"), + _("Volume up"), + _("Volume down"), + _("Volume toggle mute"), + _("Toggle IR"), _("Toggle Aspect Ratio"), _("Toggle EFB Copies"),