Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 7968: Added keybinds for increasing, decreasing, and muting audio. #1782

Merged
merged 2 commits into from
Jan 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 33 additions & 1 deletion Source/Core/AudioCommon/AudioCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

int& currentVolume = SConfig::GetInstance().m_Volume;
currentVolume -= offset;
if (currentVolume < AUDIO_VOLUME_MIN)
currentVolume = AUDIO_VOLUME_MIN;

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

UpdateSoundStream();
}

void ToggleMuteVolume()
{
bool& isMuted = SConfig::GetInstance().m_IsMuted;
isMuted = !isMuted;
UpdateSoundStream();
}
}
3 changes: 3 additions & 0 deletions Source/Core/AudioCommon/AudioCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
7 changes: 7 additions & 0 deletions Source/Core/Core/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */ },

This comment was marked as off-topic.

This comment was marked as off-topic.


{ "ToggleIR", 0, 0 /* wxMOD_NONE */ },
{ "ToggleAspectRatio", 0, 0 /* wxMOD_NONE */ },
{ "ToggleEFBCopies", 0, 0 /* wxMOD_NONE */ },
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions Source/Core/Core/CoreParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions Source/Core/DolphinWX/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include <wx/aui/auibook.h>
#include <wx/aui/framemanager.h>

#include "AudioCommon/AudioCommon.h"

#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Thread.h"
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/DolphinWX/HotkeyDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ void HotkeyConfigDialog::CreateHotkeyGUIControls()
_("Connect Wiimote 4"),
_("Connect Balance Board"),

_("Volume Up"),
_("Volume Down"),
_("Volume Toggle Mute"),

This comment was marked as off-topic.

_("Toggle IR"),
_("Toggle Aspect Ratio"),
_("Toggle EFB Copies"),
Expand Down