diff --git a/Source/Core/AudioCommon/Src/Mixer.cpp b/Source/Core/AudioCommon/Src/Mixer.cpp index b0f1f0f653..6ee0ddbf7a 100644 --- a/Source/Core/AudioCommon/Src/Mixer.cpp +++ b/Source/Core/AudioCommon/Src/Mixer.cpp @@ -58,8 +58,7 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples) if (m_AIplaying) { numLeft = (numLeft > numSamples) ? numSamples : numLeft; - // Do re-sampling if needed - if (m_sampleRate == 32000) + if (AudioInterface::GetAIDSampleRate() == m_sampleRate) // (1:1) { #if _M_SSE >= 0x301 if (cpu_info.bSSSE3 && !((numLeft * 2) % 8)) @@ -91,7 +90,7 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples) //remember fractional offset 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) { 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; - if (m_sampleRate == 32000) + if (AudioInterface::GetAIDSampleRate() == m_sampleRate) 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); + else + Common::AtomicAdd(m_numSamples, num_samples * 2 / 3); return; } diff --git a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX_Voice.h b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX_Voice.h index 8bdc7ff7e4..e6ee063ae3 100644 --- a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX_Voice.h +++ b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX_Voice.h @@ -22,6 +22,7 @@ #include "UCode_AX_ADPCM.h" #include "UCode_AX.h" #include "Mixer.h" +#include "../../AudioInterface.h" // MRAM -> ARAM for GC inline bool ReadPB(u32 addr, AXPB &PB) @@ -104,7 +105,7 @@ inline void MixAddVoice(ParamBlockType &pb, if (pb.running) { 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 loopPos = (pb.audio_addr.loop_addr_hi << 16) | pb.audio_addr.loop_addr_lo; diff --git a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp index 97fbe2ec28..7ee5f68001 100644 --- a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp +++ b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp @@ -157,7 +157,7 @@ u16 DSPLLE::DSP_WriteControlRegister(u16 _uFlag) { unsigned int 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"); // Mixer is initialized m_InitMixer = true;