AudioCommon/Mixer: Allow input sample rate changes
This commit is contained in:
parent
e91db62f1b
commit
7d920bbb3a
|
@ -181,11 +181,26 @@ void CMixer::PushStreamingSamples(const short *samples, unsigned int num_samples
|
||||||
m_streaming_mixer.PushSamples(samples, num_samples);
|
m_streaming_mixer.PushSamples(samples, num_samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMixer::SetDMAInputSampleRate(unsigned int rate)
|
||||||
|
{
|
||||||
|
m_dma_mixer.SetInputSampleRate(rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMixer::SetStreamInputSampleRate(unsigned int rate)
|
||||||
|
{
|
||||||
|
m_streaming_mixer.SetInputSampleRate(rate);
|
||||||
|
}
|
||||||
|
|
||||||
void CMixer::SetStreamingVolume(unsigned int lvolume, unsigned int rvolume)
|
void CMixer::SetStreamingVolume(unsigned int lvolume, unsigned int rvolume)
|
||||||
{
|
{
|
||||||
m_streaming_mixer.SetVolume(lvolume, rvolume);
|
m_streaming_mixer.SetVolume(lvolume, rvolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMixer::MixerFifo::SetInputSampleRate(unsigned int rate)
|
||||||
|
{
|
||||||
|
m_input_sample_rate = rate;
|
||||||
|
}
|
||||||
|
|
||||||
void CMixer::MixerFifo::SetVolume(unsigned int lvolume, unsigned int rvolume)
|
void CMixer::MixerFifo::SetVolume(unsigned int lvolume, unsigned int rvolume)
|
||||||
{
|
{
|
||||||
m_LVolume = lvolume + (lvolume >> 7);
|
m_LVolume = lvolume + (lvolume >> 7);
|
||||||
|
|
|
@ -41,6 +41,9 @@ public:
|
||||||
virtual void PushSamples(const short* samples, unsigned int num_samples);
|
virtual void PushSamples(const short* samples, unsigned int num_samples);
|
||||||
virtual void PushStreamingSamples(const short* samples, unsigned int num_samples);
|
virtual void PushStreamingSamples(const short* samples, unsigned int num_samples);
|
||||||
unsigned int GetSampleRate() const { return m_sampleRate; }
|
unsigned int GetSampleRate() const { return m_sampleRate; }
|
||||||
|
|
||||||
|
void SetDMAInputSampleRate(unsigned int rate);
|
||||||
|
void SetStreamInputSampleRate(unsigned int rate);
|
||||||
void SetStreamingVolume(unsigned int lvolume, unsigned int rvolume);
|
void SetStreamingVolume(unsigned int lvolume, unsigned int rvolume);
|
||||||
|
|
||||||
void SetThrottle(bool use) { m_throttle = use;}
|
void SetThrottle(bool use) { m_throttle = use;}
|
||||||
|
@ -97,6 +100,7 @@ protected:
|
||||||
}
|
}
|
||||||
void PushSamples(const short* samples, unsigned int num_samples);
|
void PushSamples(const short* samples, unsigned int num_samples);
|
||||||
unsigned int Mix(short* samples, unsigned int numSamples, bool consider_framelimit = true);
|
unsigned int Mix(short* samples, unsigned int numSamples, bool consider_framelimit = true);
|
||||||
|
void SetInputSampleRate(unsigned int rate);
|
||||||
void SetVolume(unsigned int lvolume, unsigned int rvolume);
|
void SetVolume(unsigned int lvolume, unsigned int rvolume);
|
||||||
private:
|
private:
|
||||||
CMixer *m_mixer;
|
CMixer *m_mixer;
|
||||||
|
|
|
@ -183,20 +183,22 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
||||||
// Set frequency of streaming audio
|
// Set frequency of streaming audio
|
||||||
if (tmpAICtrl.AISFR != m_Control.AISFR)
|
if (tmpAICtrl.AISFR != m_Control.AISFR)
|
||||||
{
|
{
|
||||||
|
// AISFR rates below are intentionally inverted wrt yagcd
|
||||||
DEBUG_LOG(AUDIO_INTERFACE, "Change AISFR to %s", tmpAICtrl.AISFR ? "48khz":"32khz");
|
DEBUG_LOG(AUDIO_INTERFACE, "Change AISFR to %s", tmpAICtrl.AISFR ? "48khz":"32khz");
|
||||||
m_Control.AISFR = tmpAICtrl.AISFR;
|
m_Control.AISFR = tmpAICtrl.AISFR;
|
||||||
|
g_AISSampleRate = tmpAICtrl.AISFR ? 48000 : 32000;
|
||||||
|
soundStream->GetMixer()->SetStreamInputSampleRate(g_AISSampleRate);
|
||||||
|
g_CPUCyclesPerSample = SystemTimers::GetTicksPerSecond() / g_AISSampleRate;
|
||||||
}
|
}
|
||||||
// Set frequency of DMA
|
// Set frequency of DMA
|
||||||
if (tmpAICtrl.AIDFR != m_Control.AIDFR)
|
if (tmpAICtrl.AIDFR != m_Control.AIDFR)
|
||||||
{
|
{
|
||||||
DEBUG_LOG(AUDIO_INTERFACE, "Change AIDFR to %s", tmpAICtrl.AIDFR ? "32khz":"48khz");
|
DEBUG_LOG(AUDIO_INTERFACE, "Change AIDFR to %s", tmpAICtrl.AIDFR ? "32khz":"48khz");
|
||||||
m_Control.AIDFR = tmpAICtrl.AIDFR;
|
m_Control.AIDFR = tmpAICtrl.AIDFR;
|
||||||
|
g_AIDSampleRate = tmpAICtrl.AIDFR ? 32000 : 48000;
|
||||||
|
soundStream->GetMixer()->SetDMAInputSampleRate(g_AIDSampleRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_AISSampleRate = tmpAICtrl.AISFR ? 48000 : 32000;
|
|
||||||
g_AIDSampleRate = tmpAICtrl.AIDFR ? 32000 : 48000;
|
|
||||||
|
|
||||||
g_CPUCyclesPerSample = SystemTimers::GetTicksPerSecond() / g_AISSampleRate;
|
|
||||||
|
|
||||||
// Streaming counter
|
// Streaming counter
|
||||||
if (tmpAICtrl.PSTAT != m_Control.PSTAT)
|
if (tmpAICtrl.PSTAT != m_Control.PSTAT)
|
||||||
|
|
Loading…
Reference in New Issue