Trying to fix mixer problem when AIsrc is @48kHz, should fix games like All Star Baseball 2004/

XGRA Extreme-G Racing Association/Conduit 2... Enabled 48kHz output for LLE (before it was just 32kHz). I hope it works, if there are serious problems, it will be reverted.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7511 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Marko Pusljar 2011-05-05 14:53:00 +00:00
parent 3d7a2b92d4
commit ff63ef20c2
3 changed files with 9 additions and 7 deletions

View File

@ -58,8 +58,7 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples)
if (m_AIplaying) { if (m_AIplaying) {
numLeft = (numLeft > numSamples) ? numSamples : numLeft; numLeft = (numLeft > numSamples) ? numSamples : numLeft;
// Do re-sampling if needed if (AudioInterface::GetAIDSampleRate() == m_sampleRate) // (1:1)
if (m_sampleRate == 32000)
{ {
#if _M_SSE >= 0x301 #if _M_SSE >= 0x301
if (cpu_info.bSSSE3 && !((numLeft * 2) % 8)) if (cpu_info.bSSSE3 && !((numLeft * 2) % 8))
@ -91,7 +90,7 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples)
//remember fractional offset //remember fractional offset
static u32 frac = 0; static u32 frac = 0;
const u32 ratio = (u32)( 65536.0f * 32000.0f / (float)m_sampleRate ); const u32 ratio = (u32)( 65536.0f * (float)AudioInterface::GetAIDSampleRate() / (float)m_sampleRate );
for (u32 i = 0; i < numLeft * 2; i+=2) { for (u32 i = 0; i < numLeft * 2; i+=2) {
u32 m_indexR2 = m_indexR + 2; //next sample u32 m_indexR2 = m_indexR + 2; //next sample
@ -199,10 +198,12 @@ void CMixer::PushSamples(const short *samples, unsigned int num_samples)
m_indexW += num_samples * 2; m_indexW += num_samples * 2;
if (m_sampleRate == 32000) if (AudioInterface::GetAIDSampleRate() == m_sampleRate)
Common::AtomicAdd(m_numSamples, num_samples); Common::AtomicAdd(m_numSamples, num_samples);
else // Assume 48000 otherwise else if ((AudioInterface::GetAIDSampleRate() == 32000) && (m_sampleRate == 48000))
Common::AtomicAdd(m_numSamples, num_samples * 3 / 2); Common::AtomicAdd(m_numSamples, num_samples * 3 / 2);
else
Common::AtomicAdd(m_numSamples, num_samples * 2 / 3);
return; return;
} }

View File

@ -22,6 +22,7 @@
#include "UCode_AX_ADPCM.h" #include "UCode_AX_ADPCM.h"
#include "UCode_AX.h" #include "UCode_AX.h"
#include "Mixer.h" #include "Mixer.h"
#include "../../AudioInterface.h"
// MRAM -> ARAM for GC // MRAM -> ARAM for GC
inline bool ReadPB(u32 addr, AXPB &PB) inline bool ReadPB(u32 addr, AXPB &PB)
@ -104,7 +105,7 @@ inline void MixAddVoice(ParamBlockType &pb,
if (pb.running) if (pb.running)
{ {
const u32 ratio = (u32)(((pb.src.ratio_hi << 16) + pb.src.ratio_lo) const u32 ratio = (u32)(((pb.src.ratio_hi << 16) + pb.src.ratio_lo)
* /*ratioFactor:*/(32000.0f / (float)soundStream->GetMixer()->GetSampleRate())); * /*ratioFactor:*/((float)AudioInterface::GetAIDSampleRate() / (float)soundStream->GetMixer()->GetSampleRate()));
u32 sampleEnd = (pb.audio_addr.end_addr_hi << 16) | pb.audio_addr.end_addr_lo; u32 sampleEnd = (pb.audio_addr.end_addr_hi << 16) | pb.audio_addr.end_addr_lo;
u32 loopPos = (pb.audio_addr.loop_addr_hi << 16) | pb.audio_addr.loop_addr_lo; u32 loopPos = (pb.audio_addr.loop_addr_hi << 16) | pb.audio_addr.loop_addr_lo;

View File

@ -157,7 +157,7 @@ u16 DSPLLE::DSP_WriteControlRegister(u16 _uFlag)
{ {
unsigned int AISampleRate, DACSampleRate; unsigned int AISampleRate, DACSampleRate;
AudioInterface::Callback_GetSampleRate(AISampleRate, DACSampleRate); AudioInterface::Callback_GetSampleRate(AISampleRate, DACSampleRate);
soundStream = AudioCommon::InitSoundStream(new CMixer(AISampleRate, DACSampleRate), m_hWnd); soundStream = AudioCommon::InitSoundStream(new CMixer(AISampleRate, DACSampleRate, ac_Config.iFrequency), m_hWnd);
if(!soundStream) PanicAlert("Error starting up sound stream"); if(!soundStream) PanicAlert("Error starting up sound stream");
// Mixer is initialized // Mixer is initialized
m_InitMixer = true; m_InitMixer = true;