sound options work better, and they save with the configuration now

This commit is contained in:
zeromus 2008-05-12 17:57:12 +00:00
parent ef228133f6
commit 412304e840
5 changed files with 210 additions and 201 deletions

View File

@ -1,3 +1,6 @@
//this code is sloppily ripped from an unfinished sound system written for internal use by m.gambrell
//it is released into the public domain and its stability is not warranted
#include "oakra.h"
#include "dsound.h"
@ -64,7 +67,6 @@ public:
cPlay = 0;
hr = ds_buf->Play(0,0,DSBPLAY_LOOPING);
int xxx=9;
}
//not supported

View File

@ -95,7 +95,12 @@ void ApplyDefaultCommandMapping(void);
uint8 *xbsave = NULL;
int eoptions = EO_BGRUN | EO_FORCEISCALE;
//global variables
int soundoptions = SO_SECONDARY | SO_GFOCUS;
int soundrate = 44100;
int soundbuftime = 50;
int soundvolume = 100;
int soundquality = 0;
/**
* Contains the names of the overridden standard directories

View File

@ -54,10 +54,12 @@ static double winsizemulx = 1, winsizemuly = 1;
static int winwidth, winheight;
static int ismaximized = 0;
static int soundrate = 44100;
static int soundbuftime = 50;
static int soundvolume = 100;
static int soundquality = 0;
extern int soundoptions;
extern int soundrate;
extern int soundbuftime;
extern int soundvolume;
extern int soundquality;
static uint8 cpalette[192];
//mbg 5/7/08 - I changed the ntsc settings to match pal.
//this is more for precision emulation, instead of entertainment, which is what fceux is all about nowadays

Binary file not shown.

View File

@ -1,22 +1,26 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel and zeromus
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel and zeromus
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//todo - config synchronization guards
//todo - use correct framerate instead of 60
//todo - find out why fast forwarding at 96khz causes buffering to glitch?
#include <list>
#include "common.h"
@ -165,9 +169,9 @@ public:
int bufferSamples = buffers.length>>1;
//if we're we're too far behind, playback faster
if(bufferSamples > 44100*3/60) {
int behind = bufferSamples - 44100/60;
incr = behind*256*60/44100/2;
if(bufferSamples > soundrate*3/60) {
int behind = bufferSamples - soundrate/60;
incr = behind*256*60/soundrate/2;
//we multiply our playback rate by 1/2 the number of frames we're behind
}
if(incr<256) printf("OHNO -- %d -- shouldnt be less than 256!\n",incr); //sanity check: should never be less than 256
@ -206,8 +210,8 @@ public:
dsout->lock();
int remain = buffers.length>>1;
dsout->unlock();
if(remain<44100/60) break;
//if(remain<44100*scale/256/60) break; ??
if(remain<soundrate/60) break;
//if(remain<soundrate*scale/256/60) break; ??
Sleep(1);
}
}
@ -249,10 +253,6 @@ public:
}
};
//todo - a properly synchronized method ShouldntTouchSound() which is totally safe (use mutexes) and use that to guard all sound code
//also add an alternate timer-based throttler for when sound is disabled
static Player *player;
static Player8 *player8;
@ -303,7 +303,7 @@ void win_SoundInit(int bits) {
OAKRA_Format fmt;
fmt.format = bits==8?OAKRA_U8:OAKRA_S16;
fmt.channels = 1;
fmt.rate = 44100;
fmt.rate = soundrate;
fmt.size = OAKRA_Module::calcSize(fmt);
OAKRA_Voice *voice = dsout->getVoice(fmt);
@ -318,23 +318,25 @@ void win_SoundInit(int bits) {
int InitSound() {
if(soundoptions&SO_FORCE8BIT)
bits = 8;
else {
if(!(soundoptions&SO_FORCE8BIT))
{
//no modern system should have this problem, and we dont use primary buffer
/*if( (!(dscaps.dwFlags&DSCAPS_PRIMARY16BIT) && !(soundoptions&SO_SECONDARY)) ||
(!(dscaps.dwFlags&DSCAPS_SECONDARY16BIT) && (soundoptions&SO_SECONDARY)))
{
FCEUD_PrintError("DirectSound: 16-bit sound is not supported. Forcing 8-bit sound.");*/
//if(dscaps.dwFlags&DSCAPS_SECONDARY16BIT)
bits = 16;
//else
// FCEUD_PrintError("DirectSound: 16-bit sound is not supported. Forcing 8-bit sound.")
}
bits = 8;
win_SoundInit(bits);
FCEUI_Sound(soundrate);
return 1;
// FCEUD_PrintError("DirectSound: Sound device is being emulated through waveform-audio functions. Sound quality will most likely be awful. Try to update your sound device's sound drivers.");
}
@ -384,11 +386,11 @@ BOOL CALLBACK SoundConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
{
switch(uMsg) {
case WM_NCRBUTTONDOWN:
case WM_NCMBUTTONDOWN:
case WM_NCLBUTTONDOWN:break;
case WM_NCRBUTTONDOWN:
case WM_NCMBUTTONDOWN:
case WM_NCLBUTTONDOWN:break;
case WM_INITDIALOG:
case WM_INITDIALOG:
/* Volume Trackbar */
SendDlgItemMessage(hwndDlg,500,TBM_SETRANGE,1,MAKELONG(0,150));
SendDlgItemMessage(hwndDlg,500,TBM_SETTICFREQ,25,0);
@ -417,11 +419,11 @@ BOOL CALLBACK SoundConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
UpdateSD(hwndDlg);
break;
case WM_VSCROLL:
case WM_VSCROLL:
soundvolume=150-SendDlgItemMessage(hwndDlg,500,TBM_GETPOS,0,0);
FCEUI_SetSoundVolume(soundvolume);
break;
case WM_HSCROLL:
case WM_HSCROLL:
{
char tbuf[8];
soundbuftime=SendDlgItemMessage(hwndDlg,128,TBM_GETPOS,0,0);
@ -430,9 +432,9 @@ BOOL CALLBACK SoundConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
//soundbufsize=(soundbuftime*soundrate/1000);
}
break;
case WM_CLOSE:
case WM_QUIT: goto gornk;
case WM_COMMAND:
case WM_CLOSE:
case WM_QUIT: goto gornk;
case WM_COMMAND:
switch(HIWORD(wParam))
{
case CBN_SELENDOK:
@ -524,7 +526,7 @@ BOOL CALLBACK SoundConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
switch(wParam&0xFFFF)
{
case 1:
gornk:
gornk:
DestroyWindow(hwndDlg);
uug=0;
break;
@ -533,9 +535,7 @@ BOOL CALLBACK SoundConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
return 0;
}
/**
* Shows the sounds configuration dialog.
**/
/// Shows the sounds configuration dialog.
void ConfigSound()
{
if(!uug)