change AI sampling rate based on framelimit

This commit is contained in:
degasus 2014-02-11 14:53:53 +01:00
parent ca9fd64df9
commit bbd58b8f6a
2 changed files with 12 additions and 3 deletions

View File

@ -7,6 +7,8 @@
#include "AudioCommon.h"
#include "CPUDetect.h"
#include "../Core/Host.h"
#include "ConfigManager.h"
#include "HW/VideoInterface.h"
#include "../Core/HW/AudioInterface.h"
@ -54,8 +56,15 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples)
//advance indexR with sample position
//remember fractional offset
u32 framelimit = SConfig::GetInstance().m_Framelimit;
float aid_sample_rate = AudioInterface::GetAIDSampleRate() + offset;
if (framelimit > 2)
{
aid_sample_rate = aid_sample_rate * (framelimit - 1) * 5 / VideoInterface::TargetRefreshRate;
}
static u32 frac = 0;
const u32 ratio = (u32)( 65536.0f * (float)AudioInterface::GetAIDSampleRate() / (float)m_sampleRate + offset );
const u32 ratio = (u32)( 65536.0f * aid_sample_rate / (float)m_sampleRate );
if(ratio > 0x10000)
ERROR_LOG(AUDIO, "ratio out of range");

View File

@ -12,8 +12,8 @@
#define INDEX_MASK (MAX_SAMPLES * 2 - 1)
#define LOW_WATERMARK 1280 // 40 ms
#define MAX_FREQ_SHIFT 0x0100 // of 0x10000
#define CONTROL_FACTOR 0.3 // in freq_shift per fifo size offset
#define MAX_FREQ_SHIFT 200 // per 32000 Hz
#define CONTROL_FACTOR 0.2 // in freq_shift per fifo size offset
#define CONTROL_AVG 32
class CMixer {