diff --git a/plugins/spu2-x/src/Config.h b/plugins/spu2-x/src/Config.h index ffa6c5f076..1596115c46 100644 --- a/plugins/spu2-x/src/Config.h +++ b/plugins/spu2-x/src/Config.h @@ -65,6 +65,7 @@ extern int Interpolation; extern int ReverbBoost; extern int numSpeakers; extern bool EffectsDisabled; +extern float FinalVolume; extern bool postprocess_filter_enabled; extern u32 OutputModule; diff --git a/plugins/spu2-x/src/Linux/Config.cpp b/plugins/spu2-x/src/Linux/Config.cpp index 979ec96525..af11828d57 100644 --- a/plugins/spu2-x/src/Linux/Config.cpp +++ b/plugins/spu2-x/src/Linux/Config.cpp @@ -42,6 +42,7 @@ int Interpolation = 4; */ bool EffectsDisabled = false; +float FinalVolume; int ReverbBoost = 0; bool postprocess_filter_enabled = 1; bool _visual_debug_enabled = false; // windows only feature @@ -66,6 +67,8 @@ void ReadSettings() Interpolation = CfgReadInt( L"MIXING",L"Interpolation", 4 ); EffectsDisabled = CfgReadBool( L"MIXING", L"Disable_Effects", false ); + FinalVolume = ((float)CfgReadInt( L"MIXING", L"FinalVolume", 100 )) / 100; + if ( FinalVolume > 1.0f) FinalVolume = 1.0f; ReverbBoost = CfgReadInt( L"MIXING",L"Reverb_Boost", 0 ); wxString temp; @@ -107,6 +110,7 @@ void WriteSettings() CfgWriteInt(L"MIXING",L"Interpolation",Interpolation); CfgWriteBool(L"MIXING",L"Disable_Effects",EffectsDisabled); + CfgWriteInt(L"MIXING",L"FinalVolume",(int)(FinalVolume*100)); CfgWriteInt(L"MIXING",L"Reverb_Boost",ReverbBoost); CfgWriteStr(L"OUTPUT",L"Output_Module", mods[OutputModule]->GetIdent() ); @@ -244,6 +248,7 @@ void DisplayDialog() gtk_container_add(GTK_CONTAINER(main_box), output_frame); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(effects_check), EffectsDisabled); + //FinalVolume; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(debug_check), DebugEnabled); gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame); @@ -261,8 +266,9 @@ void DisplayDialog() Interpolation = gtk_combo_box_get_active(GTK_COMBO_BOX(int_box)); EffectsDisabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(effects_check)); - - if (gtk_combo_box_get_active(GTK_COMBO_BOX(reverb_box)) != -1) + //FinalVolume; + + if (gtk_combo_box_get_active(GTK_COMBO_BOX(reverb_box)) != -1) ReverbBoost = gtk_combo_box_get_active(GTK_COMBO_BOX(reverb_box)); if (gtk_combo_box_get_active(GTK_COMBO_BOX(mod_box)) != -1) diff --git a/plugins/spu2-x/src/Linux/Config.h b/plugins/spu2-x/src/Linux/Config.h index e50cbe4d0c..a0475b83f9 100644 --- a/plugins/spu2-x/src/Linux/Config.h +++ b/plugins/spu2-x/src/Linux/Config.h @@ -70,6 +70,7 @@ static __forceinline bool RegDump() { return _RegDump & DebugEnabled; }*/ extern int Interpolation; extern int ReverbBoost; extern bool EffectsDisabled; +extern float FinalVolume; extern bool postprocess_filter_enabled; extern int AutoDMAPlayRate[2]; diff --git a/plugins/spu2-x/src/Mixer.cpp b/plugins/spu2-x/src/Mixer.cpp index 93e507685b..d270ba152c 100644 --- a/plugins/spu2-x/src/Mixer.cpp +++ b/plugins/spu2-x/src/Mixer.cpp @@ -871,9 +871,17 @@ void Mix() // Like any good audio system, the PS2 pumps the volume and incurs some distortion in its // output, giving us a nice thumpy sound at times. So we add 1 above (2x volume pump) and // then clamp it all here. + + // Edit: I'm sorry Jake, but I know of no good audio system that arbitrary distorts and clips + // output by design. + // Good thing though that this code gets the volume exactly right, as per tests :) Out = clamp_mix( Out, SndOutVolumeShift ); } - + + // Configurable output volume + Out.Left *= FinalVolume; + Out.Right *= FinalVolume; + SndBuffer::Write( Out ); // Update AutoDMA output positioning diff --git a/plugins/spu2-x/src/Windows/Config.cpp b/plugins/spu2-x/src/Windows/Config.cpp index 53e0a1a2fa..1b8262daa7 100644 --- a/plugins/spu2-x/src/Windows/Config.cpp +++ b/plugins/spu2-x/src/Windows/Config.cpp @@ -37,6 +37,7 @@ int Interpolation = 4; */ int ReverbBoost = 0; bool EffectsDisabled = false; +float FinalVolume; bool postprocess_filter_enabled = 1; // OUTPUT @@ -64,7 +65,8 @@ void ReadSettings() SynchMode = CfgReadInt( L"OUTPUT", L"Synch_Mode", 0); EffectsDisabled = CfgReadBool( L"MIXING", L"Disable_Effects", false ); - + FinalVolume = ((float)CfgReadInt( L"MIXING", L"FinalVolume", 100 )) / 100; + if ( FinalVolume > 1.0f) FinalVolume = 1.0f; numSpeakers = CfgReadInt( L"OUTPUT", L"XAudio2_SpeakerConfiguration", 0); SndOutLatencyMS = CfgReadInt(L"OUTPUT",L"Latency", 150); @@ -109,6 +111,7 @@ void WriteSettings() CfgWriteInt(L"MIXING",L"Reverb_Boost",ReverbBoost); CfgWriteBool(L"MIXING",L"Disable_Effects",EffectsDisabled); + CfgWriteInt(L"MIXING",L"FinalVolume",(int)(FinalVolume*100)); CfgWriteStr(L"OUTPUT",L"Output_Module", mods[OutputModule]->GetIdent() ); CfgWriteInt(L"OUTPUT",L"Latency", SndOutLatencyMS); @@ -192,6 +195,7 @@ 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); + //FinalVolume; SET_CHECK(IDC_DEBUG_ENABLE, DebugEnabled); SET_CHECK(IDC_DSP_ENABLE, dspPluginEnabled); } @@ -248,6 +252,7 @@ BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) break; HANDLE_CHECK(IDC_EFFECTS_DISABLE,EffectsDisabled); + //FinalVolume; HANDLE_CHECK(IDC_DSP_ENABLE,dspPluginEnabled); // Fixme : Eh, how to update this based on drop list selections? :p