Capture: Introduce audio toggle setting

Allows a user to toggle recording an audio .wav file alongside the video .avi file before capturing.
This commit is contained in:
sonicfind 2020-12-22 16:31:27 -06:00 committed by refractionpcsx2
parent c60cdbba07
commit df446510da
7 changed files with 78 additions and 30 deletions

View File

@ -193,6 +193,7 @@ enum MenuIdentifiers
MenuId_Capture_Video,
MenuId_Capture_Video_Record,
MenuId_Capture_Video_Stop,
MenuId_Capture_Video_IncludeAudio,
MenuId_Capture_Screenshot,
MenuId_Capture_Screenshot_Screenshot,
MenuId_Capture_Screenshot_Screenshot_As,

View File

@ -680,8 +680,9 @@ void AppConfig::LoadSave( IniInterface& ini )
GSWindow .LoadSave( ini );
Framerate .LoadSave( ini );
#ifndef DISABLE_RECORDING
inputRecording.loadSave(ini);
inputRecording .loadSave( ini );
#endif
AudioCapture .LoadSave( ini );
Templates .LoadSave( ini );
ini.Flush();
@ -955,6 +956,18 @@ void AppConfig::FramerateOptions::LoadSave( IniInterface& ini )
IniEntry( SkipOnTurbo );
}
AppConfig::CaptureOptions::CaptureOptions()
{
EnableAudio = true;
}
void AppConfig::CaptureOptions::LoadSave(IniInterface& ini)
{
ScopedIniGroup path(ini, L"Capture");
IniEntry( EnableAudio );
}
AppConfig::UiTemplateOptions::UiTemplateOptions()
{
LimiterUnlimited = L"Max";

View File

@ -285,6 +285,15 @@ public:
#endif
};
struct CaptureOptions
{
bool EnableAudio;
CaptureOptions();
void LoadSave(IniInterface& conf);
};
public:
wxPoint MainGuiPosition;
@ -361,6 +370,7 @@ public:
InputRecordingOptions inputRecording;
#endif
UiTemplateOptions Templates;
CaptureOptions AudioCapture;
// PCSX2-core emulation options, which are passed to the emu core prior to initiating
// an emulation session. Note these are the options saved into the GUI ini file and

View File

@ -476,15 +476,19 @@ namespace Implementations
// GSsetupRecording can be aborted/canceled by the user. Don't go on to record the audio if that happens.
std::string filename;
if (GSsetupRecording(filename))
// Note: Add a dialog box here (or in the function) that prompts the user to answer whether a failed
// SPU2 recording setup should still lead to the visuals being recorded.
SPU2setupRecording(&filename);
{
if (g_Conf->AudioCapture.EnableAudio && !SPU2setupRecording(&filename))
{
GSendRecording();
g_Pcsx2Recording = false;
}
}
else // recording dialog canceled by the user. align our state
g_Pcsx2Recording = false;
}
// the GS doesn't support recording
else
g_Pcsx2Recording = SPU2setupRecording(nullptr);
else if (!g_Conf->AudioCapture.EnableAudio || !SPU2setupRecording(nullptr))
g_Pcsx2Recording = false;
if (GetMainFramePtr() && needsMainFrameEnable)
GetMainFramePtr()->Enable();
@ -494,7 +498,8 @@ namespace Implementations
// stop recording
if (GSendRecording)
GSendRecording();
SPU2endRecording();
if (g_Conf->AudioCapture.EnableAudio)
SPU2endRecording();
}
}

View File

@ -291,6 +291,7 @@ void MainEmuFrame::ConnectMenus()
// Capture
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Capture_Video_ToggleCapture_Click, this, MenuId_Capture_Video_Record);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Capture_Video_ToggleCapture_Click, this, MenuId_Capture_Video_Stop);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Capture_Video_IncludeAudio_Click, this, MenuId_Capture_Video_IncludeAudio);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Capture_Screenshot_Screenshot_Click, this, MenuId_Capture_Screenshot_Screenshot);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Capture_Screenshot_Screenshot_As_Click, this, MenuId_Capture_Screenshot_Screenshot_As);
@ -492,9 +493,14 @@ void MainEmuFrame::CreateCaptureMenu()
{
m_menuCapture.Append(MenuId_Capture_Video, _("Video"), &m_submenuVideoCapture);
// Implement custom hotkeys (F12) with translatable string intact + not blank in GUI.
wxMenuItem* sysVideoCaptureItem = m_submenuVideoCapture.Append(MenuId_Capture_Video_Record, _("Start Screenrecorder"));
wxMenuItem* sysVideoCaptureItem = m_submenuVideoCapture.Append(MenuId_Capture_Video_Record, _("Start Video Capture"));
AppendShortcutToMenuOption(*sysVideoCaptureItem, wxGetApp().GlobalAccels->findKeycodeWithCommandId("Sys_RecordingToggle").toTitleizedString());
m_submenuVideoCapture.Append(MenuId_Capture_Video_Stop, _("Stop Screenrecorder"))->Enable(false);
sysVideoCaptureItem = m_submenuVideoCapture.Append(MenuId_Capture_Video_Stop, _("Stop Video Capture"));
sysVideoCaptureItem->Enable(false);
AppendShortcutToMenuOption(*sysVideoCaptureItem, wxGetApp().GlobalAccels->findKeycodeWithCommandId("Sys_RecordingToggle").toTitleizedString());
m_submenuVideoCapture.AppendSeparator();
m_submenuVideoCapture.Append(MenuId_Capture_Video_IncludeAudio, _("Include Audio"),
_("Enables/disables the creation of a synchronized wav audio file when capturing video footage."), wxITEM_CHECK);
// Implement custom hotkeys (F8) + (Shift + F8) + (Ctrl + Shift + F8) with translatable string intact + not blank in GUI.
// Fixme: GlobalCommands.cpp L1029-L1031 is having issues because FrameForGS already maps the hotkey first.
// Fixme: When you uncomment L1029-L1031 on that file; Linux says that Ctrl is already used for something else and will append (Shift + F8) while Windows will (Ctrl + Shift + F8)
@ -809,6 +815,7 @@ void MainEmuFrame::ApplyConfigToGui(AppConfig& configToApply, int flags)
menubar.Check(MenuId_EnableCheats, configToApply.EmuOptions.EnableCheats);
menubar.Check(MenuId_IPC_Enable, configToApply.EmuOptions.EnableIPC);
menubar.Check(MenuId_EnableWideScreenPatches, configToApply.EmuOptions.EnableWideScreenPatches);
menubar.Check(MenuId_Capture_Video_IncludeAudio, configToApply.AudioCapture.EnableAudio);
#ifndef DISABLE_RECORDING
menubar.Check(MenuId_EnableInputRecording, configToApply.EmuOptions.EnableRecordingTools);
#endif

View File

@ -254,6 +254,7 @@ protected:
void Menu_ShowAboutBox(wxCommandEvent& event);
void Menu_Capture_Video_ToggleCapture_Click(wxCommandEvent& event);
void Menu_Capture_Video_IncludeAudio_Click(wxCommandEvent& event);
void Menu_Capture_Screenshot_Screenshot_Click(wxCommandEvent& event);
void Menu_Capture_Screenshot_Screenshot_As_Click(wxCommandEvent& event);

View File

@ -758,6 +758,8 @@ void MainEmuFrame::Menu_SuspendResume_Click(wxCommandEvent& event)
void MainEmuFrame::Menu_SysShutdown_Click(wxCommandEvent& event)
{
if (m_capturingVideo)
VideoCaptureToggle();
UI_DisableSysShutdown();
Console.SetTitle("PCSX2 Program Log");
CoreThread.Reset();
@ -855,6 +857,12 @@ void MainEmuFrame::Menu_Capture_Video_ToggleCapture_Click(wxCommandEvent& event)
VideoCaptureToggle();
}
void MainEmuFrame::Menu_Capture_Video_IncludeAudio_Click(wxCommandEvent& event)
{
g_Conf->AudioCapture.EnableAudio = GetMenuBar()->IsChecked(MenuId_Capture_Video_IncludeAudio);
ApplySettings();
}
void MainEmuFrame::VideoCaptureToggle()
{
GetMTGS().WaitGS(); // make sure GS is in sync with the audio stream when we start.
@ -878,30 +886,31 @@ void MainEmuFrame::VideoCaptureToggle()
std::string filename;
if (GSsetupRecording(filename))
{
// Note: Add a dialog box here (or in the function) that prompts the user to answer whether a failed
// SPU2 recording setup should still lead to the visuals being recorded.
SPU2setupRecording(&filename);
m_submenuVideoCapture.Enable(MenuId_Capture_Video_Record, false);
m_submenuVideoCapture.Enable(MenuId_Capture_Video_Stop, true);
if (!g_Conf->AudioCapture.EnableAudio || SPU2setupRecording(&filename))
{
m_submenuVideoCapture.Enable(MenuId_Capture_Video_Record, false);
m_submenuVideoCapture.Enable(MenuId_Capture_Video_Stop, true);
m_submenuVideoCapture.Enable(MenuId_Capture_Video_IncludeAudio, false);
}
else
{
GSendRecording();
m_capturingVideo = false;
}
}
else
{
// recording dialog canceled by the user. align our state
else // recording dialog canceled by the user. align our state
m_capturingVideo = false;
}
}
// the GS doesn't support recording
else if (g_Conf->AudioCapture.EnableAudio && SPU2setupRecording(nullptr))
{
m_submenuVideoCapture.Enable(MenuId_Capture_Video_Record, false);
m_submenuVideoCapture.Enable(MenuId_Capture_Video_Stop, true);
m_submenuVideoCapture.Enable(MenuId_Capture_Video_IncludeAudio, false);
}
else
{
// the GS doesn't support recording.
if (SPU2setupRecording(nullptr))
{
m_submenuVideoCapture.Enable(MenuId_Capture_Video_Record, false);
m_submenuVideoCapture.Enable(MenuId_Capture_Video_Stop, true);
}
else
m_capturingVideo = false;
}
m_capturingVideo = false;
if (needsMainFrameEnable)
Enable();
}
@ -910,9 +919,11 @@ void MainEmuFrame::VideoCaptureToggle()
// stop recording
if (GSendRecording)
GSendRecording();
SPU2endRecording();
if (g_Conf->AudioCapture.EnableAudio)
SPU2endRecording();
m_submenuVideoCapture.Enable(MenuId_Capture_Video_Record, true);
m_submenuVideoCapture.Enable(MenuId_Capture_Video_Stop, false);
m_submenuVideoCapture.Enable(MenuId_Capture_Video_IncludeAudio, true);
}
}