ADDED volume control to audio effects dialog and renamed it to audio core settings dialog

This commit is contained in:
spacy51 2008-08-27 18:49:09 +00:00
parent b2e13838db
commit 7eaef013a3
9 changed files with 225 additions and 117 deletions

View File

@ -606,7 +606,7 @@
>
</File>
<File
RelativePath="..\..\src\win32\AudioEffectsDlg.cpp"
RelativePath="..\..\src\win32\AudioCoreSettingsDlg.cpp"
>
</File>
<File
@ -1160,7 +1160,7 @@
>
</File>
<File
RelativePath="..\..\src\win32\AudioEffectsDlg.h"
RelativePath="..\..\src\win32\AudioCoreSettingsDlg.h"
>
</File>
<File

View File

@ -0,0 +1,147 @@
#include "AudioCoreSettingsDlg.h"
#define MIN_VOLUME 0.0f
#define MAX_VOLUME 4.0f
// AudioCoreSettingsDlg dialog
IMPLEMENT_DYNAMIC(AudioCoreSettingsDlg, CDialog)
AudioCoreSettingsDlg::AudioCoreSettingsDlg(CWnd* pParent /*=NULL*/)
: CDialog(AudioCoreSettingsDlg::IDD, pParent)
, m_enabled( false )
, m_surround( false )
, m_echo( 0.0f )
, m_stereo( 0.0f )
, toolTip( NULL )
{
}
AudioCoreSettingsDlg::~AudioCoreSettingsDlg()
{
delete toolTip;
}
void AudioCoreSettingsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_ENHANCE_SOUND, enhance_sound);
DDX_Control(pDX, IDC_SURROUND, surround);
DDX_Control(pDX, IDC_ECHO, echo);
DDX_Control(pDX, IDC_STEREO, stereo);
DDX_Control(pDX, IDC_VOLUME, volume);
if( pDX->m_bSaveAndValidate == TRUE ) {
m_enabled = BST_CHECKED == enhance_sound.GetCheck();
m_surround = BST_CHECKED == surround.GetCheck();
m_echo = (float)echo.GetPos() / 100.0f;
m_stereo = (float)stereo.GetPos() / 100.0f;
m_volume = (float)volume.GetPos() / 100.0f;
}
}
BOOL AudioCoreSettingsDlg::OnTtnNeedText(UINT id, NMHDR *pNMHDR, LRESULT *pResult)
{
TOOLTIPTEXT *t3 = (TOOLTIPTEXT *)pNMHDR; // dirty Windows API
BOOL i_provided_tooltip_with_text = TRUE;
if( !( t3->uFlags & TTF_IDISHWND ) ) {
return FALSE;
}
// even dirtier Windows API:
// t3->hdr.idFrom is actually a HWND, holy cow, why?
// The other case does not even occur.
int controlID = ::GetDlgCtrlID( (HWND)t3->hdr.idFrom );
CString res;
TCHAR buf[0x400]; // Use own string buffer because szText has an 80 char limit.
// We can't use a dynamic buffer size because Windows does some shady things with
// t3->lpszText at the end of this function, so we have no chance to free the buffer
// before the end of this function.
switch( controlID ) {
case IDC_VOLUME:
_stprintf_s( t3->szText, _countof( t3->szText ), _T( "%i%%" ), volume.GetPos() );
break;
case IDC_ECHO:
_stprintf_s( t3->szText, _countof( t3->szText ), _T( "%i%%" ), echo.GetPos() );
break;
case IDC_STEREO:
_stprintf_s( t3->szText, _countof( t3->szText ), _T( "%i%%" ), stereo.GetPos() );
break;
case IDC_DEFAULT_VOLUME:
res.LoadString( IDS_TOOLTIP_DEFAULT_VOLUME );
_tcscpy_s( buf, _countof( buf ), res.GetString() );
t3->lpszText = buf;
break;
case IDC_ENHANCE_SOUND:
res.LoadString( IDS_TOOLTIP_ENHANCE_SOUND );
_tcscpy_s( buf, _countof( buf ), res.GetString() );
t3->lpszText = buf;
break;
case IDC_SURROUND:
res.LoadString( IDS_TOOLTIP_SURROUND );
_tcscpy_s( buf, _countof( buf ), res.GetString() );
t3->lpszText = buf;
break;
default:
i_provided_tooltip_with_text = FALSE;
break;
}
return i_provided_tooltip_with_text;
}
BEGIN_MESSAGE_MAP(AudioCoreSettingsDlg, CDialog)
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, &AudioCoreSettingsDlg::OnTtnNeedText)
ON_BN_CLICKED(IDC_DEFAULT_VOLUME, &AudioCoreSettingsDlg::OnBnClickedDefaultVolume)
END_MESSAGE_MAP()
// AudioCoreSettingsDlg message handlers
BOOL AudioCoreSettingsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set up tooltip control
toolTip = new CToolTipCtrl;
toolTip->Create( this );
toolTip->AddTool( GetDlgItem( IDC_DEFAULT_VOLUME ) );
toolTip->AddTool( GetDlgItem( IDC_ENHANCE_SOUND ) );
toolTip->AddTool( GetDlgItem( IDC_SURROUND ) );
toolTip->Activate( TRUE );
enhance_sound.SetCheck( m_enabled ? BST_CHECKED : BST_UNCHECKED );
surround.SetCheck( m_surround ? BST_CHECKED : BST_UNCHECKED );
echo.SetRange( 0, 100 );
echo.SetPos( (int)( m_echo * 100.0f ) );
stereo.SetRange( 0, 100 );
stereo.SetPos( (int)( m_stereo * 100.0f ) );
volume.SetRange( (int)( MIN_VOLUME * 100.0f ), (int)( MAX_VOLUME * 100.0f ) );
volume.SetPos( (int)( m_volume * 100.0f ) );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL AudioCoreSettingsDlg::PreTranslateMessage(MSG* pMsg)
{
// Required for enabling ToolTips in a modal dialog box.
if( NULL != toolTip ) {
toolTip->RelayEvent( pMsg );
}
return CDialog::PreTranslateMessage(pMsg);
}
void AudioCoreSettingsDlg::OnBnClickedDefaultVolume()
{
volume.SetPos( 100 );
}

View File

@ -0,0 +1,42 @@
#pragma once
#include "stdafx.h"
// AudioCoreSettingsDlg dialog
class AudioCoreSettingsDlg : public CDialog
{
DECLARE_DYNAMIC(AudioCoreSettingsDlg)
public:
bool m_enabled;
bool m_surround;
float m_echo;
float m_stereo;
float m_volume;
AudioCoreSettingsDlg(CWnd* pParent = NULL); // standard constructor
virtual ~AudioCoreSettingsDlg();
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnBnClickedDefaultVolume();
// Dialog Data
enum { IDD = IDD_AUDIO_CORE_SETTINGS };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
afx_msg BOOL OnTtnNeedText(UINT id, NMHDR *pNMHDR, LRESULT *pResult); // Retrieve text for ToolTip
DECLARE_MESSAGE_MAP()
private:
CButton enhance_sound;
CButton surround;
CSliderCtrl echo;
CSliderCtrl stereo;
CSliderCtrl volume;
CToolTipCtrl *toolTip;
};

View File

@ -1,70 +0,0 @@
// ..\..\src\win32\AudioEffectsDlg.cpp : implementation file
//
#include "stdafx.h"
#include "AudioEffectsDlg.h"
// Has to be in int range!
#define SLIDER_RESOLUTION ( 100 )
// We do everything in percents.
// AudioEffectsDlg dialog
IMPLEMENT_DYNAMIC(AudioEffectsDlg, CDialog)
AudioEffectsDlg::AudioEffectsDlg(CWnd* pParent /*=NULL*/)
: CDialog(AudioEffectsDlg::IDD, pParent)
, m_enabled( false )
, m_surround( false )
, m_echo( 0.0f )
, m_stereo( 0.0f )
{
}
AudioEffectsDlg::~AudioEffectsDlg()
{
}
void AudioEffectsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
CButton *enhance_sound = (CButton *)GetDlgItem( IDC_ENHANCE_SOUND );
CButton *surround = (CButton * )GetDlgItem( IDC_SURROUND );
CSliderCtrl *echo = (CSliderCtrl *)GetDlgItem( IDC_ECHO );
CSliderCtrl *stereo = (CSliderCtrl *)GetDlgItem( IDC_STEREO );
if( pDX->m_bSaveAndValidate == TRUE ) {
m_enabled = BST_CHECKED == enhance_sound->GetCheck();
m_surround = BST_CHECKED == surround->GetCheck();
m_echo = (float)echo->GetPos() / (float)SLIDER_RESOLUTION;
m_stereo = (float)stereo->GetPos() / (float)SLIDER_RESOLUTION;
} else {
enhance_sound->SetCheck( m_enabled ? BST_CHECKED : BST_UNCHECKED );
surround->SetCheck( m_surround ? BST_CHECKED : BST_UNCHECKED );
echo->SetPos( (int)( m_echo * (float)SLIDER_RESOLUTION ) );
stereo->SetPos( (int)( m_stereo * (float)SLIDER_RESOLUTION ) );
}
}
BEGIN_MESSAGE_MAP(AudioEffectsDlg, CDialog)
END_MESSAGE_MAP()
// AudioEffectsDlg message handlers
BOOL AudioEffectsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CSliderCtrl *echo = (CSliderCtrl *)GetDlgItem( IDC_ECHO );
echo->SetRange( 0, SLIDER_RESOLUTION );
CSliderCtrl *stereo = (CSliderCtrl *)GetDlgItem( IDC_STEREO );
stereo->SetRange( 0, SLIDER_RESOLUTION );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

View File

@ -1,28 +0,0 @@
#pragma once
// AudioEffectsDlg dialog
class AudioEffectsDlg : public CDialog
{
DECLARE_DYNAMIC(AudioEffectsDlg)
public:
bool m_enabled;
bool m_surround;
float m_echo;
float m_stereo;
AudioEffectsDlg(CWnd* pParent = NULL); // standard constructor
virtual ~AudioEffectsDlg();
// Dialog Data
enum { IDD = IDD_AUDIO_EFFECTS };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
};

View File

@ -431,7 +431,7 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd)
ON_COMMAND(ID_OUTPUTAPI_XAUDIO2CONFIG, &MainWnd::OnOutputapiXaudio2config)
ON_UPDATE_COMMAND_UI(ID_OUTPUTAPI_XAUDIO2CONFIG, &MainWnd::OnUpdateOutputapiXaudio2config)
ON_WM_ENTERSIZEMOVE()
ON_COMMAND(ID_AUDIO_EFFECTS, &MainWnd::OnAudioEffects)
ON_COMMAND(ID_AUDIO_CORE_SETTINGS, &MainWnd::OnAudioEffects)
END_MESSAGE_MAP()

View File

@ -36,7 +36,7 @@
#include "OALConfig.h"
#include "XAudio2_Config.h"
#include "BIOSDialog.h"
#include "AudioEffectsDlg.h"
#include "AudioCoreSettingsDlg.h"
#include "../System.h"
#include "../agb/agbprint.h"
@ -816,12 +816,13 @@ void MainWnd::OnUpdateOptionsSoundMute(CCmdUI* pCmdUI)
void MainWnd::OnAudioEffects()
{
AudioEffectsDlg dlg;
AudioCoreSettingsDlg dlg;
dlg.m_enabled = gb_effects_config.enabled;
dlg.m_surround = gb_effects_config.surround;
dlg.m_echo = gb_effects_config.echo;
dlg.m_stereo = gb_effects_config.stereo;
dlg.m_volume = soundGetVolume();
if( IDOK == dlg.DoModal() ) {
gb_effects_config_t _new;
@ -832,6 +833,8 @@ void MainWnd::OnAudioEffects()
_new.stereo = dlg.m_stereo;
gbSoundConfigEffects( _new );
soundSetVolume( dlg.m_volume );
}
}

View File

@ -1167,24 +1167,30 @@ BEGIN
RTEXT "Device:",IDC_STATIC,6,6,48,12
END
IDD_AUDIO_EFFECTS DIALOGEX 0, 0, 136, 144
IDD_AUDIO_CORE_SETTINGS DIALOGEX 0, 0, 256, 144
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Audio Effects"
CAPTION "Audio Core Settings"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,30,126,48,14
PUSHBUTTON "Cancel",IDCANCEL,84,126,48,14
DEFPUSHBUTTON "OK",IDOK,150,126,48,14
PUSHBUTTON "Cancel",IDCANCEL,204,126,48,14
GROUPBOX "Game Boy only",IDC_STATIC,6,6,126,114
CONTROL "Enhance sound",IDC_ENHANCE_SOUND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,18,90,12
CONTROL "Surround",IDC_SURROUND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,30,90,12
CONTROL "Enhance sound",IDC_ENHANCE_SOUND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,18,65,10
CONTROL "Surround",IDC_SURROUND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,30,45,10
GROUPBOX "Echo",IDC_STATIC,24,42,102,36
CONTROL "",IDC_ECHO,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,30,54,90,12
CONTROL "",IDC_ECHO,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TOOLTIPS | WS_TABSTOP,30,54,90,12
LTEXT "None",IDC_STATIC,30,66,36,8,SS_CENTERIMAGE
RTEXT "Lots",IDC_STATIC,84,66,36,8,SS_CENTERIMAGE
GROUPBOX "Stereo",IDC_STATIC,24,78,102,36
CONTROL "",IDC_STEREO,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,30,90,90,12
CONTROL "",IDC_STEREO,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TOOLTIPS | WS_TABSTOP,30,90,90,12
LTEXT "Center",IDC_STATIC,30,102,36,8,SS_CENTERIMAGE
RTEXT "Left/Right",IDC_STATIC,84,102,36,8,SS_CENTERIMAGE
GROUPBOX "Game Boy Advance only",IDC_STATIC,138,6,114,114
GROUPBOX "Volume",IDC_STATIC,144,18,102,42
CONTROL "",IDC_VOLUME,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TOOLTIPS | WS_TABSTOP,150,30,90,12
LTEXT "Mute",IDC_STATIC,150,42,18,12,SS_CENTERIMAGE
RTEXT "Max",IDC_STATIC,222,42,18,12,SS_CENTERIMAGE
PUSHBUTTON "Default",IDC_DEFAULT_VOLUME,174,42,42,12,BS_NOTIFY
END
@ -1537,10 +1543,10 @@ BEGIN
BOTTOMMARGIN, 89
END
IDD_AUDIO_EFFECTS, DIALOG
IDD_AUDIO_CORE_SETTINGS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 129
RIGHTMARGIN, 249
TOPMARGIN, 7
BOTTOMMARGIN, 137
END
@ -1796,7 +1802,7 @@ BEGIN
MENUITEM "Off", ID_OPTIONS_SOUND_PCMINTERPOLATION_NONE
END
MENUITEM SEPARATOR
MENUITEM "Effects...", ID_AUDIO_EFFECTS
MENUITEM "Core Settings...", ID_AUDIO_CORE_SETTINGS
MENUITEM SEPARATOR
POPUP "Sound Channels"
BEGIN
@ -2222,6 +2228,9 @@ BEGIN
IDS_INVALID_CBA_CODE "Invalid CBA code. Format is XXXXXXXX YYYY."
IDS_CBA_CODE_WARNING "Warning: Codes seem to be for a different game.\nCodes may not work correctly."
IDS_OUT_OF_MEMORY "Failed to allocate memory for %s"
IDS_TOOLTIP_DEFAULT_VOLUME "Reset to default volume (100%)."
IDS_TOOLTIP_ENHANCE_SOUND "Enable the following sound enhancements."
IDS_TOOLTIP_SURROUND "Inverts the phase of some channels, making it sound as if sound is coming from behind."
END
STRINGTABLE

View File

@ -45,7 +45,10 @@
#define IDS_CBA_CODE_WARNING 40
#define IDS_OUT_OF_MEMORY 41
#define IDS_WRONG_GAMESHARK_CODE 42
#define IDS_TOOLTIP_DEFAULT_VOLUME 42
#define IDS_UNSUPPORTED_GAMESHARK_CODE 43
#define IDS_TOOLTIP_ENHANCE_SOUND 43
#define IDS_TOOLTIP_SURROUND 44
#define IDI_MAINICON 101
#define IDD_REGISTERS 102
#define IDD_DEBUG 103
@ -101,7 +104,7 @@
#define IDD_BIOS 161
#define IDD_FULLSCREEN 162
#define IDD_XAUDIO2_CONFIG 163
#define IDD_AUDIO_EFFECTS 164
#define IDD_AUDIO_CORE_SETTINGS 164
#define IDC_R0 1000
#define IDC_EDIT_UP 1000
#define IDC_R1 1001
@ -545,6 +548,8 @@
#define IDC_ECHO 1289
#define IDC_STEREO 1290
#define IDC_SLIDER2 1291
#define IDC_VOLUME 1291
#define IDC_DEFAULT_VOLUME 1292
#define IDS_OAL_NODEVICE 2000
#define IDS_OAL_NODLL 2001
#define IDS_AVI_CANNOT_CREATE_AVI 2002
@ -861,7 +866,7 @@
#define ID_LOADGAME_DONOTCHANGEBATTERYSAVE 40362
#define ID_OUTPUTAPI_CONFIGURATION40363 40363
#define ID_OUTPUTAPI_XAUDIO2CONFIG 40364
#define ID_AUDIO_EFFECTS 40365
#define ID_AUDIO_CORE_SETTINGS 40365
// Next default values for new objects
//
@ -869,7 +874,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 165
#define _APS_NEXT_COMMAND_VALUE 40366
#define _APS_NEXT_CONTROL_VALUE 1292
#define _APS_NEXT_CONTROL_VALUE 1296
#define _APS_NEXT_SYMED_VALUE 103
#endif
#endif