SPU2: Clean up + add Gaussian value in comment

This commit is contained in:
RedDevilus 2021-04-15 19:32:21 +02:00 committed by lightningterror
parent be2bf9faca
commit 2195ac9051
9 changed files with 89 additions and 84 deletions

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2021 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -31,17 +31,18 @@ int AutoDMAPlayRate[2] = {0, 0};
// MIXING
int Interpolation = 5;
/* values:
0: no interpolation (use nearest)
1. linear interpolation
2. cubic interpolation
3. hermite interpolation
4. catmull-rom interpolation
0: No interpolation (uses nearest)
1. Linear interpolation
2. Cubic interpolation
3. Hermite interpolation
4. Catmull-Rom interpolation
5. Gaussian interpolation
*/
bool EffectsDisabled = false;
float FinalVolume; // global
bool AdvancedVolumeControl;
float VolumeAdjustFLdb; // decibels settings, cos audiophiles love that
float VolumeAdjustFLdb; // Decibels settings, because audiophiles love that.
float VolumeAdjustCdb;
float VolumeAdjustFRdb;
float VolumeAdjustBLdb;
@ -49,7 +50,7 @@ float VolumeAdjustBRdb;
float VolumeAdjustSLdb;
float VolumeAdjustSRdb;
float VolumeAdjustLFEdb;
float VolumeAdjustFL; // linear coefs calculated from decibels,
float VolumeAdjustFL; // Linear coefficients calculated from decibels,
float VolumeAdjustC;
float VolumeAdjustFR;
float VolumeAdjustBL;
@ -60,12 +61,12 @@ float VolumeAdjustLFE;
bool postprocess_filter_enabled = true;
bool postprocess_filter_dealias = false;
bool _visual_debug_enabled = false; // windows only feature
bool _visual_debug_enabled = false; // Windows-only feature
// OUTPUT
u32 OutputModule = 0;
int SndOutLatencyMS = 100;
int SynchMode = 0; // Time Stretch, Async or Disabled
int SynchMode = 0; // Time Stretch, Async or Disabled.
#ifdef SPU2X_PORTAUDIO
u32 OutputAPI = 0;
#endif
@ -80,7 +81,7 @@ bool temp_debug_state;
void ReadSettings()
{
// For some reason this can be called before we know what ini file we're writing to.
// Lets not try to read it if that happens.
// Let's not try to read it if that happens.
if (!pathSet)
initIni();
@ -116,9 +117,9 @@ void ReadSettings()
#else
CfgReadStr(L"OUTPUT", L"Output_Module", temp, PortaudioOut->GetIdent());
#endif
OutputModule = FindOutputModuleById(temp.c_str()); // find the driver index of this module
OutputModule = FindOutputModuleById(temp.c_str()); // Find the driver index of this module...
// find current API
// Find current API.
#ifdef SPU2X_PORTAUDIO
#ifdef __linux__
CfgReadStr(L"PORTAUDIO", L"HostApi", temp, L"ALSA");
@ -138,7 +139,7 @@ void ReadSettings()
CfgReadStr(L"SDL", L"HostApi", temp, L"pulseaudio");
SdlOutputAPI = 0;
#if SDL_MAJOR_VERSION >= 2
// YES It sucks ...
// Yes, it sucks ...
for (int i = 0; i < SDL_GetNumAudioDrivers(); ++i)
{
if (!temp.Cmp(wxString(SDL_GetAudioDriver(i), wxConvUTF8)))

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2021 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -158,7 +158,7 @@ static __forceinline s32 GetNextDataBuffered(V_Core& thiscore, uint voiceidx)
{
if (vc.PendingLoopStart)
{
if ((Cycles - vc.PlayCycle) >= 4 )
if ((Cycles - vc.PlayCycle) >= 4)
{
if (vc.LoopCycle < vc.PlayCycle)
{
@ -364,10 +364,10 @@ static __forceinline void CalculateADSR(V_Core& thiscore, uint voiceidx)
__forceinline static s32 GaussianInterpolate(s32 pv4, s32 pv3, s32 pv2, s32 pv1, s32 i)
{
s32 out = 0;
out = (interpTable[0x0FF-i] * pv4) >> 15;
out += (interpTable[0x1FF-i] * pv3) >> 15;
out += (interpTable[0x100+i] * pv2) >> 15;
out += (interpTable[0x000+i] * pv1) >> 15;
out = (interpTable[0x0FF - i] * pv4) >> 15;
out += (interpTable[0x1FF - i] * pv3) >> 15;
out += (interpTable[0x100 + i] * pv2) >> 15;
out += (interpTable[0x000 + i] * pv1) >> 15;
return out;
}
@ -937,7 +937,7 @@ __forceinline
SndBuffer::Write(Out);
if(SampleRate == 96000) // Double up samples for 96khz (Port Audio Non-Exclusive)
if (SampleRate == 96000) // Double up samples for 96khz (Port Audio Non-Exclusive)
SndBuffer::Write(Out);
// Update AutoDMA output positioning

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2021 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -324,7 +324,7 @@ public:
}
if (err != paNoError)
{
if(err == paInvalidSampleRate)
if (err == paInvalidSampleRate)
Console.Warning("Failed to create Port Audio Device %dkhz, Please use Exclusive Mode", SampleRate / 1000);
fprintf(stderr, "* SPU2: PortAudio error: %s\n", Pa_GetErrorText(err));
Pa_Terminate();

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2021 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -50,7 +50,7 @@ namespace
void callback_fillBuffer(void* userdata, Uint8* stream, int len)
{
StereoOut16 *out = (StereoOut16 *)stream;
StereoOut16* out = (StereoOut16*)stream;
// Length should always be samples in bytes.
assert(len / sizeof(StereoOut_SDL) == samples);

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2021 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -31,18 +31,19 @@ static const int LATENCY_MIN_TS = 15;
// MIXING
int Interpolation = 5;
/* values:
0: no interpolation (use nearest)
1. linear interpolation
2. cubic interpolation
3. hermite interpolation
4. catmull-rom interpolation
0: No interpolation (uses nearest)
1. Linear interpolation
2. Cubic interpolation
3. Hermite interpolation
4. Catmull-Rom interpolation
5. Gaussian interpolation
*/
bool EffectsDisabled = false;
float FinalVolume; // Global
bool AdvancedVolumeControl;
float VolumeAdjustFLdb; // decibels settings, cos audiophiles love that
float VolumeAdjustFLdb; // Decibels settings, because audiophiles love that.
float VolumeAdjustCdb;
float VolumeAdjustFRdb;
float VolumeAdjustBLdb;
@ -50,7 +51,7 @@ float VolumeAdjustBRdb;
float VolumeAdjustSLdb;
float VolumeAdjustSRdb;
float VolumeAdjustLFEdb;
float VolumeAdjustFL; // linear coefs calcualted from decibels,
float VolumeAdjustFL; // Linear coefficients calculated from decibels,
float VolumeAdjustC;
float VolumeAdjustFR;
float VolumeAdjustBL;
@ -64,7 +65,7 @@ bool postprocess_filter_dealias = false;
// OUTPUT
int SndOutLatencyMS = 100;
int SynchMode = 0; // Time Stretch, Async or Disabled
int SynchMode = 0; // Time Stretch, Async or Disabled.
u32 OutputModule = 0;
@ -115,20 +116,20 @@ void ReadSettings()
dplLevel = CfgReadInt(L"OUTPUT", L"DplDecodingLevel", 0);
SndOutLatencyMS = CfgReadInt(L"OUTPUT", L"Latency", 100);
if ((SynchMode == 0) && (SndOutLatencyMS < LATENCY_MIN_TS)) // can't use low-latency with timestretcher atm
if ((SynchMode == 0) && (SndOutLatencyMS < LATENCY_MIN_TS)) // Can't use low-latency with timestretcher at the moment.
SndOutLatencyMS = LATENCY_MIN_TS;
else if (SndOutLatencyMS < LATENCY_MIN)
SndOutLatencyMS = LATENCY_MIN;
wchar_t omodid[128];
// portaudio occasionally has issues selecting the proper default audio device.
// let's use xaudio2 until this is sorted (rama)
// Portaudio occasionally has issues selecting the proper default audio device.
// Let's use xaudio2 until this is sorted (rama).
// CfgReadStr(L"OUTPUT", L"Output_Module", omodid, 127, PortaudioOut->GetIdent());
CfgReadStr(L"OUTPUT", L"Output_Module", omodid, 127, XAudio2Out->GetIdent());
// find the driver index of this module:
// Find the driver index of this module:
OutputModule = FindOutputModuleById(omodid);
CfgReadStr(L"DSP PLUGIN", L"Filename", dspPlugin, 255, L"");
@ -227,12 +228,12 @@ BOOL CALLBACK ConfigProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_INITDIALOG:
{
SendDialogMsg(hWnd, IDC_INTERPOLATE, CB_RESETCONTENT, 0, 0);
SendDialogMsg(hWnd, IDC_INTERPOLATE, CB_ADDSTRING, 0, (LPARAM)L"0 - Nearest (Fastest/bad quality)");
SendDialogMsg(hWnd, IDC_INTERPOLATE, CB_ADDSTRING, 0, (LPARAM)L"1 - Linear (Simple/okay sound)");
SendDialogMsg(hWnd, IDC_INTERPOLATE, CB_ADDSTRING, 0, (LPARAM)L"2 - Cubic (Artificial highs)");
SendDialogMsg(hWnd, IDC_INTERPOLATE, CB_ADDSTRING, 0, (LPARAM)L"3 - Hermite (Better highs)");
SendDialogMsg(hWnd, IDC_INTERPOLATE, CB_ADDSTRING, 0, (LPARAM)L"4 - Catmull-Rom (PS2-like/slow)");
SendDialogMsg(hWnd, IDC_INTERPOLATE, CB_ADDSTRING, 0, (LPARAM)L"5 - Gaussian (SPU native)");
SendDialogMsg(hWnd, IDC_INTERPOLATE, CB_ADDSTRING, 0, (LPARAM)L"0 - Nearest (Fastest / worst quality)");
SendDialogMsg(hWnd, IDC_INTERPOLATE, CB_ADDSTRING, 0, (LPARAM)L"1 - Linear (Simple / okay sound)");
SendDialogMsg(hWnd, IDC_INTERPOLATE, CB_ADDSTRING, 0, (LPARAM)L"2 - Cubic (Fake highs / okay sound)");
SendDialogMsg(hWnd, IDC_INTERPOLATE, CB_ADDSTRING, 0, (LPARAM)L"3 - Hermite (Better highs / okay sound)");
SendDialogMsg(hWnd, IDC_INTERPOLATE, CB_ADDSTRING, 0, (LPARAM)L"4 - Catmull-Rom (PS2-like / good sound)");
SendDialogMsg(hWnd, IDC_INTERPOLATE, CB_ADDSTRING, 0, (LPARAM)L"5 - Gaussian (PS2-like / great sound)");
SendDialogMsg(hWnd, IDC_INTERPOLATE, CB_SETCURSEL, Interpolation, 0);
SendDialogMsg(hWnd, IDC_SYNCHMODE, CB_RESETCONTENT, 0, 0);

View File

@ -30,33 +30,33 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x0
BEGIN
PUSHBUTTON "OK",IDOK,101,238,50,14,NOT WS_TABSTOP
PUSHBUTTON "Cancel",IDCANCEL,157,238,50,14,NOT WS_TABSTOP
GROUPBOX "Mixing Settings",IDC_STATIC,6,5,145,115
LTEXT "Interpolation:",IDC_STATIC,12,16,61,10,NOT WS_GROUP
COMBOBOX IDC_INTERPOLATE,14,26,129,84,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CHECKBOX "Disable Effects Processing",IDC_EFFECTS_DISABLE,14,47,126,10
LTEXT "(speedup!) Skips reverb effects processing, but won't sound as good in most games.",IDC_STATIC,26,59,110,36
CONTROL "Use the de-alias filter",IDC_DEALIASFILTER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,92,126,10
LTEXT "(overemphasizes the highs)",IDC_STATIC,26,104,114,12,NOT WS_GROUP
GROUPBOX "",IDC_STATIC,6,123,145,45
CHECKBOX "Enable Debug Options",IDC_DEBUG_ENABLE,14,135,118,10,NOT WS_TABSTOP
PUSHBUTTON "Configure...",IDC_OPEN_CONFIG_DEBUG,14,147,52,13
GROUPBOX "Output Settings",IDC_STATIC,157,5,145,225
LTEXT "Module:",IDC_STATIC,163,16,50,9,NOT WS_GROUP
COMBOBOX IDC_OUTPUT,165,26,129,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Configure...",IDC_OUTCONF,165,42,52,13
LTEXT "Volume:",IDC_STATIC,192,61,27,8,NOT WS_GROUP
CTEXT "100%",IDC_VOLUME_LABEL,226,61,58,9
CONTROL "",IDC_VOLUME_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | WS_TABSTOP,165,72,129,10
LTEXT "Latency:",IDC_STATIC,190,86,29,8,NOT WS_GROUP
CTEXT "100 ms (avg)",IDC_LATENCY_LABEL,227,86,58,9
CONTROL "Slider2",IDC_LATENCY_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | WS_TABSTOP,165,96,129,10
CONTROL "Synchronizing Mode:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,163,116,133,8
COMBOBOX IDC_SYNCHMODE,165,126,129,62,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Advanced...",IDC_OPEN_CONFIG_SOUNDTOUCH,165,142,52,13
LTEXT "Audio Expansion Mode:",IDC_SPEAKERS_TEXT,163,162,137,10,NOT WS_GROUP
COMBOBOX IDC_SPEAKERS,165,172,129,84,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Use a Winamp DSP plugin",IDC_DSP_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,165,195,129,11
LTEXT "(currently requires manual configuration via the ini file)",IDC_STATIC,177,207,100,20
GROUPBOX "Mixing Settings",IDC_STATIC,3,5,154,115
LTEXT "Interpolation:",IDC_STATIC,9,16,61,10,NOT WS_GROUP
COMBOBOX IDC_INTERPOLATE,9,26,145,84,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CHECKBOX "Disable Effects Processing",IDC_EFFECTS_DISABLE,11,47,126,10
LTEXT "(speedup!) Skips reverb effects processing, but won't sound as good in most games.",IDC_STATIC,23,59,110,36
CONTROL "Use the de-alias filter",IDC_DEALIASFILTER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,92,126,10
LTEXT "(overemphasizes the highs)",IDC_STATIC,23,104,114,12,NOT WS_GROUP
GROUPBOX "",IDC_STATIC,3,124,154,45
CHECKBOX "Enable Debug Options",IDC_DEBUG_ENABLE,11,135,118,10,NOT WS_TABSTOP
PUSHBUTTON "Configure...",IDC_OPEN_CONFIG_DEBUG,11,147,52,13
GROUPBOX "Output Settings",IDC_STATIC,165,5,141,225
LTEXT "Module:",IDC_STATIC,171,16,50,9,NOT WS_GROUP
COMBOBOX IDC_OUTPUT,173,26,130,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Configure...",IDC_OUTCONF,173,42,52,13
LTEXT "Volume:",IDC_STATIC,200,61,27,8,NOT WS_GROUP
CTEXT "100%",IDC_VOLUME_LABEL,234,61,58,9
CONTROL "",IDC_VOLUME_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | WS_TABSTOP,170,72,129,10
LTEXT "Latency:",IDC_STATIC,196,86,29,8,NOT WS_GROUP
CTEXT "100 ms (avg)",IDC_LATENCY_LABEL,233,86,58,9
CONTROL "Slider2",IDC_LATENCY_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | WS_TABSTOP,173,96,129,10
CONTROL "Synchronizing Mode:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,171,116,133,8
COMBOBOX IDC_SYNCHMODE,173,126,129,62,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Advanced...",IDC_OPEN_CONFIG_SOUNDTOUCH,172,142,52,13
LTEXT "Audio Expansion Mode:",IDC_SPEAKERS_TEXT,170,162,137,10,NOT WS_GROUP
COMBOBOX IDC_SPEAKERS,172,172,129,84,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Use a Winamp DSP plugin",IDC_DSP_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,172,195,129,11
LTEXT "(currently requires manual configuration via the ini file)",IDC_STATIC,184,207,100,20
END
IDD_DEBUG DIALOGEX 0, 0, 303, 473

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2021 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -94,7 +94,7 @@ void SPU2writeDMA4Mem(u16* pMem, u32 size) // size now in 16bit units
void SPU2interruptDMA4()
{
FileLog("[%10d] SPU2 interruptDMA4\n", Cycles);
if(Cores[0].DmaMode)
if (Cores[0].DmaMode)
Cores[0].Regs.STATX |= 0x80;
Cores[0].Regs.STATX &= ~0x400;
Cores[0].TSA = Cores[0].ActiveTSA;
@ -451,6 +451,9 @@ void SPU2async(u32 cycles)
case 4:
printf(" - Catmull-Rom.\n");
break;
case 5:
printf(" - Gaussian.\n");
break;
default:
printf(" (unknown).\n");
break;

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2021 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -30,12 +30,12 @@ MixerTab::MixerTab(wxWindow* parent)
top_box->Add(new wxStaticText(this, wxID_ANY, "Interpolation"), wxSizerFlags().Centre());
wxArrayString interpolation_entries;
interpolation_entries.Add("Nearest (Fastest/bad quality)");
interpolation_entries.Add("Linear (Simple/okay sound)");
interpolation_entries.Add("Cubic (Artificial highs)");
interpolation_entries.Add("Hermite (Better highs)");
interpolation_entries.Add("Catmull-Rom (PS2-like/slow)");
interpolation_entries.Add("Gaussian (SPU native)");
interpolation_entries.Add("Nearest (Fastest / worst quality)");
interpolation_entries.Add("Linear (Simple / okay sound)");
interpolation_entries.Add("Cubic (Fake highs / okay sound)");
interpolation_entries.Add("Hermite (Better highs / okay sound)");
interpolation_entries.Add("Catmull-Rom (PS2-like / good sound)");
interpolation_entries.Add("Gaussian (PS2-like / great sound)");
m_inter_select = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, interpolation_entries);
@ -393,7 +393,7 @@ Dialog::Dialog()
m_sdl_text = new wxStaticText(this, wxID_ANY, "SDL API");
m_sdl_box->Add(m_sdl_text, wxSizerFlags().Centre());
wxArrayString sdl_entries;
wxArrayString sdl_entries;
for (int i = 0; i < SDL_GetNumAudioDrivers(); ++i)
sdl_entries.Add(SDL_GetAudioDriver(i));

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
* Copyright (C) 2002-2021 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -30,7 +30,7 @@
class MixerTab : public wxPanel
{
public:
wxChoice* m_inter_select, *m_audio_select;
wxChoice *m_inter_select, *m_audio_select;
wxCheckBox *effect_check, *dealias_check;
wxSlider *m_latency_slider, *m_volume_slider;
wxStaticBoxSizer *m_volume_box, *m_latency_box;
@ -47,7 +47,7 @@ class SyncTab : public wxPanel
{
public:
wxChoice* m_sync_select;
wxButton* launch_adv_dialog, *reset_button;
wxButton *launch_adv_dialog, *reset_button;
wxSpinCtrl *seq_spin, *seek_spin, *overlap_spin;
SyncTab(wxWindow* parent);