change audio sample rate depending on video mode.

This commit is contained in:
dborth 2011-05-15 18:33:57 +00:00
parent 197ba79dd6
commit 82cf404231
4 changed files with 26 additions and 8 deletions

View File

@ -31,8 +31,6 @@
bool romLoaded = false;
#define SAMPLERATE 48000
int GCMemROM(int size)
{
bool biosError = false;
@ -47,8 +45,6 @@ int GCMemROM(int size)
GameInfo->archiveCount = 0;
/*** Set some default values ***/
GameInfo->soundchan = 1;
GameInfo->soundrate = SAMPLERATE;
GameInfo->name=0;
GameInfo->type=GIT_CART;
GameInfo->vidsys=(EGIV)GCSettings.timing;
@ -57,7 +53,7 @@ int GCMemROM(int size)
GameInfo->cspecial=SIS_NONE;
/*** Set internal sound information ***/
FCEUI_Sound(SAMPLERATE);
SetSampleRate();
FCEUI_SetSoundVolume(100); // 0-100
FCEUI_SetLowPass(0);

View File

@ -13,8 +13,7 @@
#include <gccore.h>
#include <string.h>
#include <asndlib.h>
#define SAMPLERATE 48000
#include "fceusupport.h"
static u8 ConfigRequested = 0;
static u8 soundbuffer[2][3840] ATTRIBUTE_ALIGN(32);
@ -23,6 +22,7 @@ static int mixhead = 0;
static int mixtail = 0;
static int whichab = 0;
static int IsPlaying = 0;
static int samplerate;
/****************************************************************************
* MixerCollect
@ -176,3 +176,13 @@ void PlaySound( int *Buffer, int count )
AudioSwitchBuffers ();
}
}
void UpdateSampleRate(int rate)
{
samplerate = rate;
}
void SetSampleRate()
{
FCEUI_Sound(samplerate);
}

View File

@ -15,3 +15,5 @@ void ResetAudio();
void PlaySound( int *Buffer, int samples );
void SwitchAudioMode(int mode);
void ShutdownAudio();
void UpdateSampleRate(int rate);
void SetSampleRate();

View File

@ -22,6 +22,7 @@
#include "fceugx.h"
#include "fceusupport.h"
#include "gcvideo.h"
#include "gcaudio.h"
#include "menu.h"
#include "pad.h"
#include "gui/gui.h"
@ -613,11 +614,20 @@ ResetVideo_Emu ()
GXRModeObj *rmode;
Mtx44 p;
// change current VI mode if using original render mode
// set VI mode and audio sample rate depending on if original mode is used
if (GCSettings.render == 0)
{
rmode = tvmodes[FCEUI_GetCurrentVidSystem(NULL, NULL)];
UpdateSampleRate(48220);
SetSampleRate();
}
else
{
rmode = FindVideoMode();
UpdateSampleRate(48000);
SetSampleRate();
}
SetupVideoMode(rmode); // reconfigure VI