[Audio] Add settings for BufferDivided, BufferFPS, etc
This commit is contained in:
parent
64bcfa15dd
commit
a92569deb1
|
@ -33,6 +33,7 @@
|
||||||
AUDIO_INFO g_AudioInfo;
|
AUDIO_INFO g_AudioInfo;
|
||||||
|
|
||||||
bool g_PluginInit = false;
|
bool g_PluginInit = false;
|
||||||
|
bool g_romopen = false;
|
||||||
uint32_t g_Dacrate = 0;
|
uint32_t g_Dacrate = 0;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -191,6 +192,8 @@ EXPORT int32_t CALL InitiateAudio(AUDIO_INFO Audio_Info)
|
||||||
EXPORT void CALL RomOpen()
|
EXPORT void CALL RomOpen()
|
||||||
{
|
{
|
||||||
WriteTrace(TraceAudioInterface, TraceDebug, "Start");
|
WriteTrace(TraceAudioInterface, TraceDebug, "Start");
|
||||||
|
g_romopen = true;
|
||||||
|
g_settings->ReadSettings();
|
||||||
if (g_SoundDriver)
|
if (g_SoundDriver)
|
||||||
{
|
{
|
||||||
g_SoundDriver->AI_Startup();
|
g_SoundDriver->AI_Startup();
|
||||||
|
@ -206,6 +209,7 @@ EXPORT void CALL RomClosed(void)
|
||||||
{
|
{
|
||||||
g_SoundDriver->AI_Shutdown();
|
g_SoundDriver->AI_Shutdown();
|
||||||
}
|
}
|
||||||
|
g_romopen = false;
|
||||||
WriteTrace(TraceAudioInterface, TraceDebug, "Done");
|
WriteTrace(TraceAudioInterface, TraceDebug, "Done");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,14 @@ CSettings::CSettings() :
|
||||||
m_AudioEnabled(true),
|
m_AudioEnabled(true),
|
||||||
m_advanced_options(false),
|
m_advanced_options(false),
|
||||||
m_debugger_enabled(false),
|
m_debugger_enabled(false),
|
||||||
m_Volume(100)
|
m_Volume(100),
|
||||||
|
m_BufferDivider(90),
|
||||||
|
m_BufferLevel(4),
|
||||||
|
m_SyncAudio(false)
|
||||||
{
|
{
|
||||||
memset(m_log_dir, 0, sizeof(m_log_dir));
|
memset(m_log_dir, 0, sizeof(m_log_dir));
|
||||||
RegisterSettings();
|
RegisterSettings();
|
||||||
SettingsChanged();
|
ReadSettings();
|
||||||
|
|
||||||
if (m_Set_EnableAudio != 0) { SettingsRegisterChange(false, m_Set_EnableAudio, this, stSettingsChanged); }
|
if (m_Set_EnableAudio != 0) { SettingsRegisterChange(false, m_Set_EnableAudio, this, stSettingsChanged); }
|
||||||
if (m_Set_basic_mode != 0) { SettingsRegisterChange(false, m_Set_basic_mode, this, stSettingsChanged); }
|
if (m_Set_basic_mode != 0) { SettingsRegisterChange(false, m_Set_basic_mode, this, stSettingsChanged); }
|
||||||
|
@ -78,6 +81,9 @@ void CSettings::RegisterSettings(void)
|
||||||
RegisterSetting(Set_Logging_InitShutdown, Data_DWORD_General, "InitShutdown", "Logging", g_ModuleLogLevel[TraceAudioInitShutdown], NULL);
|
RegisterSetting(Set_Logging_InitShutdown, Data_DWORD_General, "InitShutdown", "Logging", g_ModuleLogLevel[TraceAudioInitShutdown], NULL);
|
||||||
RegisterSetting(Set_Logging_Interface, Data_DWORD_General, "Interface", "Logging", g_ModuleLogLevel[TraceAudioInterface], NULL);
|
RegisterSetting(Set_Logging_Interface, Data_DWORD_General, "Interface", "Logging", g_ModuleLogLevel[TraceAudioInterface], NULL);
|
||||||
RegisterSetting(Set_Logging_Driver, Data_DWORD_General, "Driver", "Logging", g_ModuleLogLevel[TraceAudioDriver], NULL);
|
RegisterSetting(Set_Logging_Driver, Data_DWORD_General, "Driver", "Logging", g_ModuleLogLevel[TraceAudioDriver], NULL);
|
||||||
|
RegisterSetting(Set_BufferDivider, Data_DWORD_Game, "BufferDivider", "", 90, NULL);
|
||||||
|
RegisterSetting(Set_BufferLevel, Data_DWORD_Game, "BufferLevel", "", 4, NULL);
|
||||||
|
RegisterSetting(Set_SyncAudio, Data_DWORD_Game, "SyncAudio", "", (uint32_t)false, NULL);
|
||||||
LogLevelChanged();
|
LogLevelChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +103,21 @@ void CSettings::SetVolume(uint32_t Volume)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSettings::SetBufferDivider(uint32_t BufferDivider)
|
||||||
|
{
|
||||||
|
SetSetting(Set_BufferDivider, BufferDivider);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettings::SetBufferLevel(uint32_t BufferLevel)
|
||||||
|
{
|
||||||
|
SetSetting(Set_BufferLevel, BufferLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettings::SetSyncAudio(bool Enabled)
|
||||||
|
{
|
||||||
|
SetSetting(Set_SyncAudio, Enabled ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
void CSettings::LogLevelChanged(void)
|
void CSettings::LogLevelChanged(void)
|
||||||
{
|
{
|
||||||
g_ModuleLogLevel[TraceMD5] = GetSetting(Set_Logging_MD5);
|
g_ModuleLogLevel[TraceMD5] = GetSetting(Set_Logging_MD5);
|
||||||
|
@ -107,12 +128,15 @@ void CSettings::LogLevelChanged(void)
|
||||||
g_ModuleLogLevel[TraceAudioDriver] = GetSetting(Set_Logging_Driver);
|
g_ModuleLogLevel[TraceAudioDriver] = GetSetting(Set_Logging_Driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettings::SettingsChanged(void)
|
void CSettings::ReadSettings(void)
|
||||||
{
|
{
|
||||||
m_Volume = GetSetting(Set_Volume);
|
m_Volume = GetSetting(Set_Volume);
|
||||||
m_AudioEnabled = m_Set_EnableAudio ? GetSystemSetting(m_Set_EnableAudio) != 0 : true;
|
m_AudioEnabled = m_Set_EnableAudio ? GetSystemSetting(m_Set_EnableAudio) != 0 : true;
|
||||||
m_advanced_options = m_Set_basic_mode ? GetSystemSetting(m_Set_basic_mode) == 0 : false;
|
m_advanced_options = m_Set_basic_mode ? GetSystemSetting(m_Set_basic_mode) == 0 : false;
|
||||||
m_debugger_enabled = m_advanced_options && m_Set_debugger ? GetSystemSetting(m_Set_debugger) == 1 : false;
|
m_debugger_enabled = m_advanced_options && m_Set_debugger ? GetSystemSetting(m_Set_debugger) == 1 : false;
|
||||||
|
m_BufferDivider = GetSetting(Set_BufferDivider);
|
||||||
|
m_BufferLevel = GetSetting(Set_BufferLevel);
|
||||||
|
m_SyncAudio = GetSetting(Set_SyncAudio) != 0;
|
||||||
|
|
||||||
if (m_Set_log_dir != 0)
|
if (m_Set_log_dir != 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,11 +19,17 @@ public:
|
||||||
inline bool AudioEnabled(void) const { return m_AudioEnabled; }
|
inline bool AudioEnabled(void) const { return m_AudioEnabled; }
|
||||||
inline bool debugger_enabled(void) const { return m_debugger_enabled; }
|
inline bool debugger_enabled(void) const { return m_debugger_enabled; }
|
||||||
inline uint32_t GetVolume(void) const { return m_Volume; }
|
inline uint32_t GetVolume(void) const { return m_Volume; }
|
||||||
|
inline uint32_t BufferDivider(void) const { return m_BufferDivider; }
|
||||||
|
inline uint32_t BufferLevel(void) const { return m_BufferLevel; }
|
||||||
|
inline bool SyncAudio(void) const { return m_SyncAudio; }
|
||||||
inline bool FlushLogs(void) const { return m_FlushLogs; }
|
inline bool FlushLogs(void) const { return m_FlushLogs; }
|
||||||
inline const char * log_dir(void) const { return m_log_dir; }
|
inline const char * log_dir(void) const { return m_log_dir; }
|
||||||
|
|
||||||
void SetAudioEnabled(bool Enabled);
|
void SetAudioEnabled(bool Enabled);
|
||||||
void SetVolume(uint32_t Volume);
|
void SetVolume(uint32_t Volume);
|
||||||
|
void SetBufferDivider(uint32_t BufferDivider);
|
||||||
|
void SetBufferLevel(uint32_t BufferLevel);
|
||||||
|
void SetSyncAudio(bool Enabled);
|
||||||
void ReadSettings();
|
void ReadSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -33,12 +39,11 @@ private:
|
||||||
}
|
}
|
||||||
static void stSettingsChanged(void * _this)
|
static void stSettingsChanged(void * _this)
|
||||||
{
|
{
|
||||||
((CSettings *)_this)->SettingsChanged();
|
((CSettings *)_this)->ReadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterSettings(void);
|
void RegisterSettings(void);
|
||||||
void LogLevelChanged(void);
|
void LogLevelChanged(void);
|
||||||
void SettingsChanged(void);
|
|
||||||
|
|
||||||
short m_Set_EnableAudio;
|
short m_Set_EnableAudio;
|
||||||
short m_Set_basic_mode;
|
short m_Set_basic_mode;
|
||||||
|
@ -51,6 +56,9 @@ private:
|
||||||
bool m_advanced_options;
|
bool m_advanced_options;
|
||||||
bool m_debugger_enabled;
|
bool m_debugger_enabled;
|
||||||
uint32_t m_Volume;
|
uint32_t m_Volume;
|
||||||
|
uint32_t m_BufferDivider;
|
||||||
|
uint32_t m_BufferLevel;
|
||||||
|
bool m_SyncAudio;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CSettings * g_settings;
|
extern CSettings * g_settings;
|
||||||
|
|
|
@ -24,11 +24,14 @@
|
||||||
#include <wtl/atlcrack.h>
|
#include <wtl/atlcrack.h>
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#include <Settings/Settings.h>
|
#include <Settings/Settings.h>
|
||||||
|
#include <Common/StdString.h>
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "AudioSettings.h"
|
#include "AudioSettings.h"
|
||||||
#include "SettingsID.h"
|
#include "SettingsID.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
|
extern bool g_romopen;
|
||||||
|
|
||||||
void SetComboBoxIndex(CComboBox & cmb, uint32_t data)
|
void SetComboBoxIndex(CComboBox & cmb, uint32_t data)
|
||||||
{
|
{
|
||||||
cmb.SetCurSel(0);
|
cmb.SetCurSel(0);
|
||||||
|
@ -92,6 +95,63 @@ private:
|
||||||
CButton m_btnMute;
|
CButton m_btnMute;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CGameSettings :
|
||||||
|
public CPropertyPageImpl<CGameSettings>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum { IDD = IDD_GAME_SETTING };
|
||||||
|
|
||||||
|
BEGIN_MSG_MAP(CDebugSettings)
|
||||||
|
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
|
||||||
|
COMMAND_HANDLER(IDC_BUFFER_DIVIDER, EN_CHANGE, ItemChanged)
|
||||||
|
COMMAND_HANDLER(IDC_BUFFER_LEVEL, EN_CHANGE, ItemChanged)
|
||||||
|
CHAIN_MSG_MAP(CPropertyPageImpl<CGameSettings>)
|
||||||
|
END_MSG_MAP()
|
||||||
|
|
||||||
|
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||||
|
{
|
||||||
|
m_BufferDivider.Attach(GetDlgItem(IDC_BUFFER_DIVIDER));
|
||||||
|
m_BufferDivider.SetWindowText(stdstr_f("%d", g_settings->BufferDivider()).c_str());
|
||||||
|
|
||||||
|
m_BufferLevel.Attach(GetDlgItem(IDC_BUFFER_LEVEL));
|
||||||
|
m_BufferLevel.SetWindowText(stdstr_f("%d", g_settings->BufferLevel()).c_str());
|
||||||
|
|
||||||
|
m_btnSyncAudio.Attach(GetDlgItem(IDC_SYNC_AUDIO));
|
||||||
|
m_btnSyncAudio.SetCheck(g_settings->SyncAudio() ? BST_CHECKED : BST_UNCHECKED);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OnApply()
|
||||||
|
{
|
||||||
|
char buffer[100];
|
||||||
|
m_BufferDivider.GetWindowText(buffer, sizeof(buffer));
|
||||||
|
g_settings->SetBufferDivider(atoi(buffer));
|
||||||
|
m_BufferLevel.GetWindowText(buffer, sizeof(buffer));
|
||||||
|
g_settings->SetBufferLevel(atoi(buffer));
|
||||||
|
g_settings->SetSyncAudio(m_btnSyncAudio.GetCheck() == BST_CHECKED);
|
||||||
|
|
||||||
|
FlushSettings();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CEdit m_BufferDivider;
|
||||||
|
CEdit m_BufferLevel;
|
||||||
|
CButton m_btnSyncAudio;
|
||||||
|
|
||||||
|
LRESULT ItemChangedNotify(NMHDR* /*pNMHDR*/)
|
||||||
|
{
|
||||||
|
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT ItemChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
||||||
|
{
|
||||||
|
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class CLogSettings :
|
class CLogSettings :
|
||||||
public CPropertyPageImpl<CLogSettings>
|
public CPropertyPageImpl<CLogSettings>
|
||||||
{
|
{
|
||||||
|
@ -186,14 +246,20 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CGeneralSettings * m_pgGeneralSettings;
|
CGeneralSettings * m_pgGeneralSettings;
|
||||||
|
CGameSettings * m_pgGameSettings;
|
||||||
CLogSettings * m_pgLogSettings;
|
CLogSettings * m_pgLogSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
CAudioUI::CAudioUI() :
|
CAudioUI::CAudioUI() :
|
||||||
m_pgGeneralSettings(new CGeneralSettings),
|
m_pgGeneralSettings(new CGeneralSettings),
|
||||||
|
m_pgGameSettings(new CGameSettings),
|
||||||
m_pgLogSettings(new CLogSettings)
|
m_pgLogSettings(new CLogSettings)
|
||||||
{
|
{
|
||||||
AddPage(&m_pgGeneralSettings->m_psp);
|
AddPage(&m_pgGeneralSettings->m_psp);
|
||||||
|
if (g_romopen)
|
||||||
|
{
|
||||||
|
AddPage(&m_pgGameSettings->m_psp);
|
||||||
|
}
|
||||||
if (g_settings->debugger_enabled())
|
if (g_settings->debugger_enabled())
|
||||||
{
|
{
|
||||||
AddPage(&m_pgLogSettings->m_psp);
|
AddPage(&m_pgLogSettings->m_psp);
|
||||||
|
@ -203,6 +269,7 @@ CAudioUI::CAudioUI() :
|
||||||
CAudioUI::~CAudioUI()
|
CAudioUI::~CAudioUI()
|
||||||
{
|
{
|
||||||
delete m_pgLogSettings;
|
delete m_pgLogSettings;
|
||||||
|
delete m_pgGameSettings;
|
||||||
delete m_pgGeneralSettings;
|
delete m_pgGeneralSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ void DirectSoundDriver::SetFrequency(uint32_t Frequency)
|
||||||
{
|
{
|
||||||
WriteTrace(TraceAudioDriver, TraceDebug, "Start (Frequency: 0x%08X)", Frequency);
|
WriteTrace(TraceAudioDriver, TraceDebug, "Start (Frequency: 0x%08X)", Frequency);
|
||||||
StopAudio();
|
StopAudio();
|
||||||
m_LOCK_SIZE = (uint32_t)((Frequency / BufferFPS)) * 4;
|
m_LOCK_SIZE = (uint32_t)((Frequency / g_settings->BufferDivider())) * 4;
|
||||||
SetSegmentSize(m_LOCK_SIZE, Frequency);
|
SetSegmentSize(m_LOCK_SIZE, Frequency);
|
||||||
|
|
||||||
StartAudio();
|
StartAudio();
|
||||||
|
|
|
@ -24,8 +24,7 @@ SoundDriverBase::SoundDriverBase() :
|
||||||
m_AI_DMASecondaryBytes(0),
|
m_AI_DMASecondaryBytes(0),
|
||||||
m_CurrentReadLoc(0),
|
m_CurrentReadLoc(0),
|
||||||
m_CurrentWriteLoc(0),
|
m_CurrentWriteLoc(0),
|
||||||
m_BufferRemaining(0),
|
m_BufferRemaining(0)
|
||||||
m_SyncAudio(false)
|
|
||||||
{
|
{
|
||||||
memset(&m_Buffer, 0, sizeof(m_Buffer));
|
memset(&m_Buffer, 0, sizeof(m_Buffer));
|
||||||
}
|
}
|
||||||
|
@ -38,7 +37,7 @@ bool SoundDriverBase::Initialize()
|
||||||
void SoundDriverBase::AI_SetFrequency(uint32_t Frequency)
|
void SoundDriverBase::AI_SetFrequency(uint32_t Frequency)
|
||||||
{
|
{
|
||||||
SetFrequency(Frequency);
|
SetFrequency(Frequency);
|
||||||
m_MaxBufferSize = (uint32_t)((Frequency / BufferFPS)) * 4 * BufferLevel;
|
m_MaxBufferSize = (uint32_t)((Frequency / g_settings->BufferDivider())) * 4 * g_settings->BufferLevel();
|
||||||
m_BufferRemaining = 0;
|
m_BufferRemaining = 0;
|
||||||
m_CurrentReadLoc = m_CurrentWriteLoc = m_BufferRemaining = 0;
|
m_CurrentReadLoc = m_CurrentWriteLoc = m_BufferRemaining = 0;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +47,7 @@ void SoundDriverBase::AI_LenChanged(uint8_t *start, uint32_t length)
|
||||||
WriteTrace(TraceAudioDriver, TraceDebug, "Start");
|
WriteTrace(TraceAudioDriver, TraceDebug, "Start");
|
||||||
|
|
||||||
// Bleed off some of this buffer to smooth out audio
|
// Bleed off some of this buffer to smooth out audio
|
||||||
if (length < m_MaxBufferSize && m_SyncAudio)
|
if (length < m_MaxBufferSize && g_settings->SyncAudio())
|
||||||
{
|
{
|
||||||
while ((m_BufferRemaining) == m_MaxBufferSize)
|
while ((m_BufferRemaining) == m_MaxBufferSize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,11 +16,6 @@
|
||||||
class SoundDriverBase
|
class SoundDriverBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum
|
|
||||||
{
|
|
||||||
BufferFPS = 90,
|
|
||||||
BufferLevel = 2,
|
|
||||||
};
|
|
||||||
SoundDriverBase();
|
SoundDriverBase();
|
||||||
|
|
||||||
void AI_SetFrequency(uint32_t Frequency);
|
void AI_SetFrequency(uint32_t Frequency);
|
||||||
|
@ -52,5 +47,4 @@ private:
|
||||||
uint32_t m_CurrentReadLoc; // Currently playing Buffer
|
uint32_t m_CurrentReadLoc; // Currently playing Buffer
|
||||||
uint32_t m_CurrentWriteLoc; // Currently writing Buffer
|
uint32_t m_CurrentWriteLoc; // Currently writing Buffer
|
||||||
uint8_t m_Buffer[MAX_SIZE]; // Emulated buffers
|
uint8_t m_Buffer[MAX_SIZE]; // Emulated buffers
|
||||||
bool m_SyncAudio;
|
|
||||||
};
|
};
|
||||||
|
|
Binary file not shown.
|
@ -20,4 +20,7 @@ enum
|
||||||
Set_Logging_InitShutdown,
|
Set_Logging_InitShutdown,
|
||||||
Set_Logging_Interface,
|
Set_Logging_Interface,
|
||||||
Set_Logging_Driver,
|
Set_Logging_Driver,
|
||||||
|
Set_BufferDivider,
|
||||||
|
Set_BufferLevel,
|
||||||
|
Set_SyncAudio,
|
||||||
};
|
};
|
Binary file not shown.
Loading…
Reference in New Issue