diff --git a/plugins/spu2-x/src/Config.h b/plugins/spu2-x/src/Config.h index f08ba64265..05287e5389 100644 --- a/plugins/spu2-x/src/Config.h +++ b/plugins/spu2-x/src/Config.h @@ -68,8 +68,7 @@ extern bool EffectsDisabled; extern u32 OutputModule; extern int SndOutLatencyMS; -extern bool timeStretchEnabled; -extern bool asyncMixingEnabled; +extern int SynchMode; #ifndef __LINUX__ extern wchar_t dspPlugin[]; diff --git a/plugins/spu2-x/src/Linux/Config.cpp b/plugins/spu2-x/src/Linux/Config.cpp index 5d54988304..f205857b1a 100644 --- a/plugins/spu2-x/src/Linux/Config.cpp +++ b/plugins/spu2-x/src/Linux/Config.cpp @@ -46,9 +46,8 @@ int ReverbBoost = 0; // OUTPUT u32 OutputModule = 0; -int SndOutLatencyMS = 160; -bool timeStretchEnabled = true; -bool asyncMixingEnabled = false; +int SndOutLatencyMS = 150; +int SynchMode = 0; // Time Stretch, Async or Disabled /*****************************************************************************/ @@ -71,8 +70,7 @@ void ReadSettings() OutputModule = FindOutputModuleById( temp.c_str() );// find the driver index of this module SndOutLatencyMS = CfgReadInt(L"OUTPUT",L"Latency", 150); - timeStretchEnabled = CfgReadBool( L"OUTPUT", L"Enable_Timestretch", true ); - asyncMixingEnabled = CfgReadBool( L"OUTPUT", L"Enable_AsyncMixing", false ); + SynchMode = CfgReadInt( L"OUTPUT", L"Synch_Mode", 0); PortaudioOut->ReadSettings(); SoundtouchCfg::ReadSettings(); @@ -103,8 +101,7 @@ void WriteSettings() CfgWriteStr(L"OUTPUT",L"Output_Module", mods[OutputModule]->GetIdent() ); CfgWriteInt(L"OUTPUT",L"Latency", SndOutLatencyMS); - CfgWriteBool(L"OUTPUT",L"Enable_Timestretch", timeStretchEnabled); - CfgWriteBool(L"OUTPUT",L"Enable_AsyncMixing", asyncMixingEnabled); + CfgWriteInt(L"OUTPUT",L"Synch_Mode", SynchMode); PortaudioOut->WriteSettings(); SoundtouchCfg::WriteSettings(); @@ -221,7 +218,8 @@ void DisplayDialog() gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(effects_check), EffectsDisabled); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(debug_check), DebugEnabled); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(time_check), timeStretchEnabled); + // Fixme + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(time_check), /*timeStretchEnabled*/ 1); gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), main_frame); gtk_widget_show_all (dialog); @@ -248,7 +246,8 @@ void DisplayDialog() OutputModule = FindOutputModuleById( PortaudioOut->GetIdent() ); SndOutLatencyMS = gtk_range_get_value(GTK_RANGE(latency_slide)); - timeStretchEnabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(time_check)); + // Fixme + //timeStretchEnabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(time_check)); } gtk_widget_destroy (dialog); diff --git a/plugins/spu2-x/src/Linux/Config.h b/plugins/spu2-x/src/Linux/Config.h index 73406a3c36..01e226eb6c 100644 --- a/plugins/spu2-x/src/Linux/Config.h +++ b/plugins/spu2-x/src/Linux/Config.h @@ -79,8 +79,7 @@ extern wchar_t dspPlugin[]; extern int dspPluginModule; extern bool dspPluginEnabled; -extern bool timeStretchEnabled; -extern bool asyncMixingEnabled; +extern int SynchMode; namespace SoundtouchCfg { diff --git a/plugins/spu2-x/src/SndOut.cpp b/plugins/spu2-x/src/SndOut.cpp index 6d17c770d9..7c8e9cd6b0 100644 --- a/plugins/spu2-x/src/SndOut.cpp +++ b/plugins/spu2-x/src/SndOut.cpp @@ -127,7 +127,7 @@ bool SndBuffer::CheckUnderrunStatus( int& nSamples, int& quietSampleCount ) quietSampleCount = 0; if( m_underrun_freeze ) { - int toFill = m_size / (!timeStretchEnabled && !asyncMixingEnabled ? 32 : 400); + int toFill = m_size / ( (SynchMode == 2) ? 32 : 400); // TimeStretch and Async off? toFill = GetAlignedBufferSize( toFill ); // toFill is now aligned to a SndOutPacket @@ -149,7 +149,7 @@ bool SndBuffer::CheckUnderrunStatus( int& nSamples, int& quietSampleCount ) quietSampleCount = SndOutPacketSize - m_data; m_underrun_freeze = true; - if( timeStretchEnabled && !asyncMixingEnabled ) + if( SynchMode == 0 ) // TimeStrech on timeStretchUnderrun(); return nSamples != 0; @@ -192,7 +192,7 @@ void SndBuffer::_WriteSamples(StereoOut32 *bData, int nSamples) s32 comp; - if( timeStretchEnabled && !asyncMixingEnabled ) + if( SynchMode == 0 ) // TimeStrech on { comp = timeStretchOverrun(); } @@ -350,7 +350,7 @@ void SndBuffer::Write( const StereoOut32& Sample ) { for( int i=0; iGetIdent() ); CfgWriteInt(L"OUTPUT",L"Latency", SndOutLatencyMS); - CfgWriteBool(L"OUTPUT",L"Enable_Timestretch", timeStretchEnabled); - CfgWriteBool(L"OUTPUT",L"Enable_AsyncMixing", asyncMixingEnabled); + CfgWriteInt(L"OUTPUT",L"Synch_Mode", SynchMode); CfgWriteInt(L"OUTPUT",L"XAudio2_SpeakerConfiguration", numSpeakers); if( Config_WaveOut.Device.empty() ) Config_WaveOut.Device = L"default"; @@ -157,6 +154,12 @@ BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) SendDialogMsg( hWnd, IDC_REVERB_BOOST, CB_ADDSTRING,0,(LPARAM) L"4X - Reverb Volume * 4" ); SendDialogMsg( hWnd, IDC_REVERB_BOOST, CB_ADDSTRING,0,(LPARAM) L"8X - Reverb Volume * 8" ); SendDialogMsg( hWnd, IDC_REVERB_BOOST, CB_SETCURSEL,ReverbBoost,0 ); + + SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_RESETCONTENT,0,0 ); + SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_ADDSTRING,0,(LPARAM) L"TimeStretch (Recommended)" ); + SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_ADDSTRING,0,(LPARAM) L"Async Mix (Breaks some games!)" ); + SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_ADDSTRING,0,(LPARAM) L"None (Audio can skip.)" ); + SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_SETCURSEL,SynchMode,0 ); SendDialogMsg( hWnd, IDC_SPEAKERS, CB_RESETCONTENT,0,0 ); SendDialogMsg( hWnd, IDC_SPEAKERS, CB_ADDSTRING,0,(LPARAM) L"Stereo (none, default)" ); @@ -184,11 +187,10 @@ BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) swprintf_s(temp,L"%d ms (avg)",SndOutLatencyMS); SetWindowText(GetDlgItem(hWnd,IDC_LATENCY_LABEL),temp); - EnableWindow( GetDlgItem( hWnd, IDC_OPEN_CONFIG_SOUNDTOUCH ), timeStretchEnabled ); + EnableWindow( GetDlgItem( hWnd, IDC_OPEN_CONFIG_SOUNDTOUCH ), (SynchMode == 0) ); EnableWindow( GetDlgItem( hWnd, IDC_OPEN_CONFIG_DEBUG ), DebugEnabled ); SET_CHECK(IDC_EFFECTS_DISABLE, EffectsDisabled); - SET_CHECK(IDC_TS_ENABLE, timeStretchEnabled); SET_CHECK(IDC_DEBUG_ENABLE, DebugEnabled); SET_CHECK(IDC_DSP_ENABLE, dspPluginEnabled); } @@ -209,6 +211,7 @@ BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) Interpolation = (int)SendDialogMsg( hWnd, IDC_INTERPOLATE, CB_GETCURSEL,0,0 ); ReverbBoost = (int)SendDialogMsg( hWnd, IDC_REVERB_BOOST, CB_GETCURSEL,0,0 ); OutputModule = (int)SendDialogMsg( hWnd, IDC_OUTPUT, CB_GETCURSEL,0,0 ); + SynchMode = (int)SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_GETCURSEL,0,0 ); numSpeakers = (int)SendDialogMsg( hWnd, IDC_SPEAKERS, CB_GETCURSEL,0,0 ); WriteSettings(); @@ -245,8 +248,12 @@ BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) HANDLE_CHECK(IDC_EFFECTS_DISABLE,EffectsDisabled); HANDLE_CHECK(IDC_DSP_ENABLE,dspPluginEnabled); - HANDLE_CHECKNB(IDC_TS_ENABLE,timeStretchEnabled); - EnableWindow( GetDlgItem( hWnd, IDC_OPEN_CONFIG_SOUNDTOUCH ), timeStretchEnabled ); + + // Fixme : Eh, how to update this based on drop list selections? :p + // IDC_TS_ENABLE already deleted! + + //HANDLE_CHECKNB(IDC_TS_ENABLE,timeStretchEnabled); + // EnableWindow( GetDlgItem( hWnd, IDC_OPEN_CONFIG_SOUNDTOUCH ), timeStretchEnabled ); break; HANDLE_CHECKNB(IDC_DEBUG_ENABLE,DebugEnabled); diff --git a/plugins/spu2-x/src/Windows/Spu2-X.rc b/plugins/spu2-x/src/Windows/Spu2-X.rc index 681cdd8e65..e3afd6f003 100644 --- a/plugins/spu2-x/src/Windows/Spu2-X.rc +++ b/plugins/spu2-x/src/Windows/Spu2-X.rc @@ -45,39 +45,39 @@ BEGIN CTEXT "Brought to you by the collaborative efforts of the Pcsx2 Development Team.",IDC_STATIC,9,141,273,10 END -IDD_CONFIG DIALOGEX 0, 0, 319, 276 +IDD_CONFIG DIALOGEX 0, 0, 319, 290 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "SPU2-X Settings" FONT 8, "MS Shell Dlg", 400, 0, 0x0 BEGIN - PUSHBUTTON "OK",IDOK,200,256,54,15,NOT WS_TABSTOP - PUSHBUTTON "Cancel",IDCANCEL,259,256,54,15,NOT WS_TABSTOP + PUSHBUTTON "OK",IDOK,200,264,54,15,NOT WS_TABSTOP + PUSHBUTTON "Cancel",IDCANCEL,259,264,54,15,NOT WS_TABSTOP GROUPBOX "Mixing Settings",IDC_STATIC,6,5,130,115 - GROUPBOX "Output Settings",IDC_STATIC,142,5,172,247 - COMBOBOX IDC_OUTPUT,164,26,126,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Output Settings",IDC_STATIC,142,0,172,256 + COMBOBOX IDC_OUTPUT,154,26,126,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Configure...",IDC_OUTCONF,236,40,54,12 COMBOBOX IDC_INTERPOLATE,14,26,114,84,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Slider2",IDC_LATENCY_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | WS_TABSTOP,167,73,116,10 - CONTROL "Enable Time-stretching",IDC_TS_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,150,96,121,11 - CONTROL "Use a Winamp DSP plugin",IDC_DSP_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,149,216,126,11 + CONTROL "Use a Winamp DSP plugin",IDC_DSP_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,149,201,126,11 CHECKBOX "Disable Effects Processing",IDC_EFFECTS_DISABLE,14,47,112,10,NOT WS_TABSTOP LTEXT "Latency:",IDC_STATIC,181,62,33,9,NOT WS_GROUP LTEXT "Interpolation:",IDC_STATIC,12,16,55,10,NOT WS_GROUP LTEXT "Module:",IDC_STATIC,161,16,50,9,NOT WS_GROUP LTEXT "(speedup!) Skips reverb effects processing, but won't sound as good in most games.",IDC_STATIC,26,60,104,36 - LTEXT "(currently requires manual configuration via the ini file)",IDC_STATIC,162,229,146,20 + LTEXT "(currently requires manual configuration via the ini file)",IDC_STATIC,162,214,146,20 CTEXT "100 ms (avg)",IDC_LATENCY_LABEL,215,62,58,9 - LTEXT "Timestretching helps reduce latency and usually eliminates audio skips.",IDC_STATIC,162,109,146,20 - CONTROL 116,IDC_STATIC,"Static",SS_BITMAP,7,196,117,52,WS_EX_CLIENTEDGE - PUSHBUTTON "Advanced...",IDC_OPEN_CONFIG_SOUNDTOUCH,219,130,84,12 + CONTROL 116,IDC_STATIC,"Static",SS_BITMAP,6,202,119,55,WS_EX_CLIENTEDGE + PUSHBUTTON "Advanced...",IDC_OPEN_CONFIG_SOUNDTOUCH,219,127,84,12 PUSHBUTTON "Configure Debug Options...",IDC_OPEN_CONFIG_DEBUG,14,167,108,14 CHECKBOX "Enable Debug Options",IDC_DEBUG_ENABLE,14,153,104,10,NOT WS_TABSTOP GROUPBOX "",IDC_STATIC,6,143,129,46 - LTEXT "Audio Expansion Mode:",IDC_STATIC,161,152,135,9,NOT WS_GROUP - COMBOBOX IDC_SPEAKERS,163,161,135,84,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "WIP - XAudio2 Only",IDC_STATIC,161,180,135,9,NOT WS_GROUP + LTEXT "Audio Expansion Mode:",IDC_STATIC,161,154,135,9,NOT WS_GROUP + COMBOBOX IDC_SPEAKERS,163,163,135,84,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "WIP - XAudio2 Only",IDC_STATIC,161,182,135,9,NOT WS_GROUP COMBOBOX IDC_REVERB_BOOST,14,99,114,84,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Reverb Boost Factor",IDC_STATIC,12,88,75,10,NOT WS_GROUP + CONTROL "Synchronizing Mode:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,161,94,131,8 + COMBOBOX IDC_SYNCHMODE,163,103,134,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END IDD_DEBUG DIALOGEX 0, 0, 326, 525 @@ -204,7 +204,6 @@ BEGIN BEGIN LEFTMARGIN, 6 RIGHTMARGIN, 314 - BOTTOMMARGIN, 271 END IDD_DEBUG, DIALOG diff --git a/plugins/spu2-x/src/Windows/resource.h b/plugins/spu2-x/src/Windows/resource.h index 7df81ea03a..5d0cbde8c2 100644 --- a/plugins/spu2-x/src/Windows/resource.h +++ b/plugins/spu2-x/src/Windows/resource.h @@ -19,13 +19,13 @@ #define IDC_LOGWAVE 1006 #define IDC_LOGDMA 1007 #define IDC_LOGREGS 1008 -#define IDC_DEBUG 1010 +#define IDC_DEBUG 1009 #define IDC_DEBUG_ENABLE 1010 #define IDC_INTERPOLATE 1011 #define IDC_REVERB_BOOST 1012 #define IDC_OUTPUT 1013 #define IDC_BUFFERS_SLIDER 1014 -#define IDC_SPEAKERS 1015 +#define IDC_SPEAKERS 1015 #define IDC_MSGKEY 1020 #define IDC_MSGDMA 1021 #define IDC_MSGADMA 1022 @@ -33,12 +33,11 @@ #define IDC_MSGSHOW 1024 #define IDC_OUTCONF 1028 #define IDC_DSP_ENABLE 1029 -#define IDC_TS_ENABLE 1030 #define IDC_DS_DEVICE 1032 #define IDC_DBG_OVERRUNS 1038 #define IDC_DBG_CACHE 1039 -#define IDC_LATENCY_SLIDER 1041 -#define IDC_LATENCY_LABEL 1042 +#define IDC_LATENCY_SLIDER 1040 +#define IDC_LATENCY_LABEL 1041 #define ICD_LR_CENTER_SLIDER 1042 #define IDC_SEQLEN_SLIDER 1043 #define IDC_SEEKWIN_SLIDER 1044 @@ -53,7 +52,9 @@ #define IDC_OPEN_CONFIG_DEBUG 1059 #define IDC_GLOBALFOCUS_DISABLE 1060 #define IDC_GLOBALFOCUS_DISABLE2 1061 -#define IDC_USE_HARDWARE 1061 +#define IDC_USE_HARDWARE 1062 +#define IDC_COMBO1 1063 +#define IDC_SYNCHMODE 1064 // Next default values for new objects // @@ -61,7 +62,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 119 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1061 +#define _APS_NEXT_CONTROL_VALUE 1065 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/plugins/spu2-x/src/spu2sys.cpp b/plugins/spu2-x/src/spu2sys.cpp index f0a1f99d68..fdd59b9556 100644 --- a/plugins/spu2-x/src/spu2sys.cpp +++ b/plugins/spu2-x/src/spu2sys.cpp @@ -272,8 +272,6 @@ void V_Voice::Stop() uint TickInterval = 768; static const int SanityInterval = 4800; -//#define USE_ASYNC_MIXING - __forceinline void TimeUpdate(u32 cClocks) { u32 dClocks = cClocks - lClocks; @@ -296,8 +294,9 @@ __forceinline void TimeUpdate(u32 cClocks) } //UpdateDebugDialog(); - if(asyncMixingEnabled) + if( SynchMode == 1 ) // AsyncMix on SndBuffer::UpdateTempoChangeAsyncMixing(); + else TickInterval = 768; // Reset to default, in case the user hotswitched from async to something else. //Update Mixing Progress while(dClocks>=TickInterval) @@ -858,7 +857,7 @@ static void __fastcall RegWrite_Core( u16 value ) // Async mixing can cause a scheduled reset to happen untimely, ff12 hates it and dies. // So do the next best thing and reset the core directly. - if(cyclePtr != NULL && !asyncMixingEnabled) + if(cyclePtr != NULL && SynchMode != 1) // !AsyncMix { thiscore.InitDelay = 1; thiscore.Regs.STATX = 0;