From 951e1ec90e2bb390eb9e1d5c35c150afd047c926 Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Tue, 18 May 2010 15:26:16 +0000 Subject: [PATCH] SPU2-X: KrossX3 coded user selectable audio expansion (Still Xaudio2 only) support. Since the automatic detection fails on some systems, this is the next best option. Tested and works as expected. Thanks a bunch, KrossX3 ;) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3041 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/spu2-x/src/Config.h | 2 +- plugins/spu2-x/src/Linux/Config.h | 1 - plugins/spu2-x/src/Windows/Config.cpp | 18 ++++++++++++------ plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp | 18 +++++++++++++----- plugins/spu2-x/src/Windows/SndOut_waveOut.cpp | 2 +- plugins/spu2-x/src/Windows/Spu2-X.rc | 5 +++-- plugins/spu2-x/src/Windows/resource.h | 2 +- 7 files changed, 31 insertions(+), 17 deletions(-) diff --git a/plugins/spu2-x/src/Config.h b/plugins/spu2-x/src/Config.h index 6edee2e9d6..f08ba64265 100644 --- a/plugins/spu2-x/src/Config.h +++ b/plugins/spu2-x/src/Config.h @@ -63,6 +63,7 @@ extern wchar_t RegDumpFileName[255]; extern int Interpolation; extern int ReverbBoost; +extern int numSpeakers; extern bool EffectsDisabled; extern u32 OutputModule; @@ -75,7 +76,6 @@ extern wchar_t dspPlugin[]; extern int dspPluginModule; extern bool dspPluginEnabled; -extern bool StereoExpansionEnabled; #endif namespace SoundtouchCfg diff --git a/plugins/spu2-x/src/Linux/Config.h b/plugins/spu2-x/src/Linux/Config.h index bf38e9d88b..8b80108458 100644 --- a/plugins/spu2-x/src/Linux/Config.h +++ b/plugins/spu2-x/src/Linux/Config.h @@ -80,7 +80,6 @@ extern int dspPluginModule; extern bool dspPluginEnabled; extern bool timeStretchEnabled; extern bool asyncMixingEnabled; -extern bool StereoExpansionEnabled; namespace SoundtouchCfg { diff --git a/plugins/spu2-x/src/Windows/Config.cpp b/plugins/spu2-x/src/Windows/Config.cpp index 55a42167b5..6ffc0d6989 100644 --- a/plugins/spu2-x/src/Windows/Config.cpp +++ b/plugins/spu2-x/src/Windows/Config.cpp @@ -53,7 +53,7 @@ bool dspPluginEnabled = false; int dspPluginModule = 0; wchar_t dspPlugin[256]; -bool StereoExpansionEnabled = false; +int numSpeakers = 0; /*****************************************************************************/ @@ -66,7 +66,7 @@ void ReadSettings() asyncMixingEnabled = CfgReadBool( L"OUTPUT", L"Enable_AsyncMixing", false ); EffectsDisabled = CfgReadBool( L"MIXING", L"Disable_Effects", false ); - StereoExpansionEnabled = CfgReadBool( L"OUTPUT", L"Enable_StereoExpansion", false ); + numSpeakers = CfgReadInt( L"OUTPUT", L"XAudio2_SpeakerConfiguration", 0); SndOutLatencyMS = CfgReadInt(L"OUTPUT",L"Latency", 150); wchar_t omodid[128]; @@ -115,7 +115,7 @@ void WriteSettings() CfgWriteInt(L"OUTPUT",L"Latency", SndOutLatencyMS); CfgWriteBool(L"OUTPUT",L"Enable_Timestretch", timeStretchEnabled); CfgWriteBool(L"OUTPUT",L"Enable_AsyncMixing", asyncMixingEnabled); - CfgWriteBool(L"OUTPUT",L"Enable_StereoExpansion", StereoExpansionEnabled); + CfgWriteInt(L"OUTPUT",L"XAudio2_SpeakerConfiguration", numSpeakers); if( Config_WaveOut.Device.empty() ) Config_WaveOut.Device = L"default"; CfgWriteStr(L"WAVEOUT",L"Device",Config_WaveOut.Device); @@ -157,6 +157,13 @@ 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_SPEAKERS, CB_RESETCONTENT,0,0 ); + SendDialogMsg( hWnd, IDC_SPEAKERS, CB_ADDSTRING,0,(LPARAM) L"Stereo (none, default)" ); + SendDialogMsg( hWnd, IDC_SPEAKERS, CB_ADDSTRING,0,(LPARAM) L"Quadrafonic" ); + SendDialogMsg( hWnd, IDC_SPEAKERS, CB_ADDSTRING,0,(LPARAM) L"Surround 5.1" ); + SendDialogMsg( hWnd, IDC_SPEAKERS, CB_ADDSTRING,0,(LPARAM) L"Surround 7.1" ); + SendDialogMsg( hWnd, IDC_SPEAKERS, CB_SETCURSEL,numSpeakers,0 ); SendDialogMsg( hWnd, IDC_OUTPUT, CB_RESETCONTENT,0,0 ); @@ -181,7 +188,6 @@ BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) EnableWindow( GetDlgItem( hWnd, IDC_OPEN_CONFIG_DEBUG ), DebugEnabled ); SET_CHECK(IDC_EFFECTS_DISABLE, EffectsDisabled); - SET_CHECK(IDC_EXPANSION_ENABLE,StereoExpansionEnabled); SET_CHECK(IDC_TS_ENABLE, timeStretchEnabled); SET_CHECK(IDC_DEBUG_ENABLE, DebugEnabled); SET_CHECK(IDC_DSP_ENABLE, dspPluginEnabled); @@ -202,7 +208,8 @@ 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 ); + OutputModule = (int)SendDialogMsg( hWnd, IDC_OUTPUT, CB_GETCURSEL,0,0 ); + numSpeakers = (int)SendDialogMsg( hWnd, IDC_SPEAKERS, CB_GETCURSEL,0,0 ); WriteSettings(); EndDialog(hWnd,0); @@ -238,7 +245,6 @@ BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) HANDLE_CHECK(IDC_EFFECTS_DISABLE,EffectsDisabled); HANDLE_CHECK(IDC_DSP_ENABLE,dspPluginEnabled); - HANDLE_CHECK(IDC_EXPANSION_ENABLE,StereoExpansionEnabled); HANDLE_CHECKNB(IDC_TS_ENABLE,timeStretchEnabled); EnableWindow( GetDlgItem( hWnd, IDC_OPEN_CONFIG_SOUNDTOUCH ), timeStretchEnabled ); break; diff --git a/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp b/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp index 1074ad7c94..69786d53d7 100644 --- a/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp +++ b/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp @@ -265,11 +265,19 @@ public: XAUDIO2_DEVICE_DETAILS deviceDetails; pXAudio2->GetDeviceDetails( 0, &deviceDetails ); - // Defaults to Stereo - int speakers = 2; - // nChannels gives the current Windows' Speaker setup (6 if 5.1) - if( StereoExpansionEnabled ) - speakers = deviceDetails.OutputFormat.Format.nChannels; + // Stereo Expansion was planned to grab the currently configured number of + // Speakers from Windows's audio config. + // This doesn't always work though, so let it be a user configurable option. + + int speakers; + switch(numSpeakers) // speakers = (numSpeakers + 1) *2; ? + { + case 0: speakers = 2; break; // Stereo + case 1: speakers = 4; break; // Quadrafonic + case 2: speakers = 6; break; // Surround 5.1 + case 3: speakers = 8; break; // Surround 7.1 + default: speakers = 2; + } // Any windows driver should support stereo at the software level, I should think! jASSUME( deviceDetails.OutputFormat.Format.nChannels > 1 ); diff --git a/plugins/spu2-x/src/Windows/SndOut_waveOut.cpp b/plugins/spu2-x/src/Windows/SndOut_waveOut.cpp index 8b2de3a5a3..ed3c366335 100644 --- a/plugins/spu2-x/src/Windows/SndOut_waveOut.cpp +++ b/plugins/spu2-x/src/Windows/SndOut_waveOut.cpp @@ -95,7 +95,7 @@ public: #if 0 int speakerConfig; - if( StereoExpansionEnabled ) + //if( StereoExpansionEnabled ) speakerConfig = 2; // better not mess with this in wavout :p (rama) // Any windows driver should support stereo at the software level, I should think! diff --git a/plugins/spu2-x/src/Windows/Spu2-X.rc b/plugins/spu2-x/src/Windows/Spu2-X.rc index e91376fb76..681cdd8e65 100644 --- a/plugins/spu2-x/src/Windows/Spu2-X.rc +++ b/plugins/spu2-x/src/Windows/Spu2-X.rc @@ -73,8 +73,9 @@ BEGIN 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 - CONTROL "Enable Audio Expansion",IDC_EXPANSION_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,150,152,135,10 - LTEXT "Audio expansion to 5.1. Currently for XAudio2 only. WIP.",IDC_STATIC,162,164,146,44 + 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 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 END diff --git a/plugins/spu2-x/src/Windows/resource.h b/plugins/spu2-x/src/Windows/resource.h index e1ac30294d..7df81ea03a 100644 --- a/plugins/spu2-x/src/Windows/resource.h +++ b/plugins/spu2-x/src/Windows/resource.h @@ -25,6 +25,7 @@ #define IDC_REVERB_BOOST 1012 #define IDC_OUTPUT 1013 #define IDC_BUFFERS_SLIDER 1014 +#define IDC_SPEAKERS 1015 #define IDC_MSGKEY 1020 #define IDC_MSGDMA 1021 #define IDC_MSGADMA 1022 @@ -44,7 +45,6 @@ #define IDC_OVERLAP_SLIDER 1045 #define IDC_MSG_PUBLIC_BUILD 1048 #define IDC_XA2_TRIBLE_BUFFER 1050 -#define IDC_EXPANSION_ENABLE 1051 #define IDC_LABEL_VERSION_INFO 1054 #define IDC_LINK_WEBSITE 1055 #define IDC_LINK_GOOGLECODE 1056