Sound channel volume control fixes, fixed the formula for square & noise. Win32 - Added a "restore defaults" button to the sound channel volume control.

This commit is contained in:
adelikat 2009-02-06 16:31:31 +00:00
parent 39138fa0b5
commit 899cb27e6d
5 changed files with 42 additions and 20 deletions

View File

@ -122,12 +122,12 @@ int soundbuftime = 50;
int soundquality = 0;
//Sound volume controls (range 0-150 by 10's)j-----
int soundvolume = 100; //Master sound volume
int soundTrianglevol = 150; //Sound channel Triangle - volume control
int soundSquare1vol = 150; //Sound channel Square1 - volume control
int soundSquare2vol = 150; //Sound channel Square2 - volume control
int soundNoisevol = 150; //Sound channel Noise - volume control
int soundPCMvol = 150; //Sound channel PCM - volume control
int soundvolume = 150; //Master sound volume
int soundTrianglevol = 100; //Sound channel Triangle - volume control
int soundSquare1vol = 100; //Sound channel Square1 - volume control
int soundSquare2vol = 100; //Sound channel Square2 - volume control
int soundNoisevol = 100; //Sound channel Noise - volume control
int soundPCMvol = 100; //Sound channel PCM - volume control
//-------------------------------------------------
double saspectw = 1, saspecth = 1;

View File

@ -7,8 +7,7 @@
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
@ -750,12 +749,12 @@ BEGIN
PUSHBUTTON "6",305,126,23,16,12
END
SOUNDCONFIG DIALOGEX 8, 95, 334, 268
SOUNDCONFIG DIALOGEX 8, 95, 334, 282
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Sound Configuration"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "Close",BTN_CLOSE,280,246,44,14
DEFPUSHBUTTON "Close",BTN_CLOSE,280,260,44,14
GROUPBOX "Output/Output Format:",302,10,9,131,93,WS_GROUP
CONTROL "Sound enabled.",CHECK_SOUND_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,22,117,12
CONTROL "Force 8-bit sound.",CHECK_SOUND_8BIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,38,117,11
@ -785,7 +784,8 @@ BEGIN
CONTROL "",CTL_VOLUME_TRACKBAR_NOISE,"msctls_trackbar32",TBS_AUTOTICKS | TBS_VERT | TBS_BOTH | WS_TABSTOP,229,150,28,83
GROUPBOX "PCM",135,271,142,44,93,WS_GROUP
CONTROL "",CTL_VOLUME_TRACKBAR_PCM,"msctls_trackbar32",TBS_AUTOTICKS | TBS_VERT | TBS_BOTH | WS_TABSTOP,279,150,28,83
GROUPBOX "Volume Control",IDC_STATIC,10,127,314,118
GROUPBOX "Volume Control",IDC_STATIC,10,127,314,127
PUSHBUTTON "Restore defaults",IDC_SOUND_RESTOREDEFAULTVOL,19,238,56,11
END
TIMINGCONFIG DIALOGEX 23, 157, 203, 60
@ -1531,7 +1531,7 @@ BEGIN
LEFTMARGIN, 10
RIGHTMARGIN, 324
TOPMARGIN, 8
BOTTOMMARGIN, 260
BOTTOMMARGIN, 274
END
"TIMINGCONFIG", DIALOG
@ -1766,8 +1766,7 @@ IDB_TE_ARROW BITMAP "res/te_arrow.bmp"
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -354,6 +354,7 @@
#define IDC_BUTTON1 1133
#define TASEDIT_REWIND 1133
#define MEMW_EXPANDCOLLAPSE 1133
#define IDC_SOUND_RESTOREDEFAULTVOL 1133
#define IDC_BUTTON2 1134
#define TASEDIT_FOWARD 1134
#define IDC_BUTTON3 1135
@ -398,6 +399,7 @@
#define IDC_MOVIE_DISPLAYSUBTITLES 1196
#define IDC_MOVIE_SUBTITLESINAVI 1197
#define IDC_MOVIE_AUTOBACKUP 1198
#define IDC_SOUNDS_RESTOREDEFAULTS 1199
#define MENU_NETWORK 40040
#define MENU_PALETTE 40041
#define MENU_SOUND 40042
@ -681,7 +683,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 125
#define _APS_NEXT_COMMAND_VALUE 40353
#define _APS_NEXT_CONTROL_VALUE 1199
#define _APS_NEXT_CONTROL_VALUE 1200
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -636,6 +636,22 @@ case WM_COMMAND:
else soundo=InitSound();
UpdateSD(hwndDlg);
break;
case IDC_SOUND_RESTOREDEFAULTVOL:
//Restore default values
soundvolume = 150;
soundTrianglevol = 100;
soundSquare1vol = 100;
soundSquare2vol = 100;
soundNoisevol = 100;
soundPCMvol = 100;
//Update trackbars
SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR,TBM_SETPOS,1,150-soundvolume);
SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_TRIANGLE,TBM_SETPOS,1,150-soundTrianglevol);
SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE1,TBM_SETPOS,1,150-soundSquare1vol);
SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_SQUARE2,TBM_SETPOS,1,150-soundSquare2vol);
SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_NOISE,TBM_SETPOS,1,150-soundNoisevol);
SendDlgItemMessage(hwndDlg,CTL_VOLUME_TRACKBAR_PCM,TBM_SETPOS,1,150-soundPCMvol);
break;
}
}

View File

@ -575,8 +575,9 @@ static INLINE void RDoSQ(int x) //Int x decides if this is Square Wave 1 or 2
amp=EnvUnits[x].decvolume; //Set the volume of the Square Wave
//Modify Square wave volume based on channel volume modifiers
if (x && FSettings.Square2Volume != 150) amp = amp << (FSettings.Square2Volume / 5); //&& FSettings.Sqauare2 added to save processing power if volume is at default
else if (FSettings.Square1Volume != 150) amp = amp << (FSettings.Square1Volume / 5);
//adelikat: Note: the formulat x = x * y /100 does not yield exact results, but is "close enough" and avoids the need for using double vales or implicit cohersion which are slower (we need speed here)
if (x && FSettings.Square2Volume != 100) amp = (amp * FSettings.Square2Volume) / 100; //&& FSettings.Sqauare2 added to save processing power if volume is at default
else if (FSettings.Square1Volume != 100) amp = (amp * FSettings.Square1Volume) / 100;
amp<<=24;
@ -717,7 +718,10 @@ static void RDoTriangle(void)
{
uint32 V; //mbg merge 7/17/06 made uitn32
int32 tcout;
if (FSettings.TriangleVolume < 150) return; //On/Off for now
//Modify Square wave volume based on channel volume modifiers
if (FSettings.TriangleVolume < 100) return; //On/Off for now
tcout=(tristep&0xF);
if(!(tristep&0x10)) tcout^=0xF;
tcout=(tcout*3) << 16; //(tcout<<1);
@ -891,9 +895,10 @@ static void RDoNoise(void)
amptab[0]=EnvUnits[2].Speed;
else
amptab[0]=EnvUnits[2].decvolume;
//Modfiy Noise channel volume based on channel volume setting
if (FSettings.NoiseVolume != 150) amptab[0] = amptab[0] << ((150 - FSettings.NoiseVolume) / 5); //if() to reduce save processing power if volume modifier is the default setting
//adelikat: Note: the formulat x = x * y /100 does not yield exact results, but is "close enough" and avoids the need for using double vales or implicit cohersion which are slower (we need speed here)
if (FSettings.NoiseVolume != 100) amptab[0] = (amptab[0] * FSettings.NoiseVolume) / 100; //if() to save processing power if volume modifier is the default setting
amptab[0]<<=16;
amptab[1]=0;