SPC: Use 32040hz output rate for SPC (same as bsnes/snes9x) - fixes Fievel Goes West
This commit is contained in:
parent
31630ad04d
commit
bc6067707c
5 changed files with 15 additions and 22 deletions
|
@ -6,6 +6,7 @@
|
|||
#include "RewindManager.h"
|
||||
#include "VideoRenderer.h"
|
||||
#include "WaveRecorder.h"
|
||||
#include "Spc.h"
|
||||
#include "Msu1.h"
|
||||
#include "../Utilities/Equalizer.h"
|
||||
#include "../Utilities/blip_buf.h"
|
||||
|
@ -70,15 +71,8 @@ void SoundMixer::PlayAudioBuffer(int16_t* samples, uint32_t sampleCount)
|
|||
_leftSample = samples[0];
|
||||
_rightSample = samples[1];
|
||||
|
||||
int16_t *out = nullptr;
|
||||
uint32_t count = 0;
|
||||
if(cfg.SampleRate == SoundResampler::SpcSampleRate && cfg.DisableDynamicSampleRate) {
|
||||
out = samples;
|
||||
count = sampleCount;
|
||||
} else {
|
||||
count = _resampler->Resample(samples, sampleCount, cfg.SampleRate, _sampleBuffer);
|
||||
out = _sampleBuffer;
|
||||
}
|
||||
int16_t *out = _sampleBuffer;
|
||||
uint32_t count = _resampler->Resample(samples, sampleCount, cfg.SampleRate, out);
|
||||
|
||||
shared_ptr<Msu1> msu1 = _console->GetMsu1();
|
||||
if(msu1) {
|
||||
|
@ -126,7 +120,7 @@ void SoundMixer::ProcessEqualizer(int16_t* samples, uint32_t sampleCount)
|
|||
cfg.Band11Gain, cfg.Band12Gain, cfg.Band13Gain, cfg.Band14Gain, cfg.Band15Gain,
|
||||
cfg.Band16Gain, cfg.Band17Gain, cfg.Band18Gain, cfg.Band19Gain, cfg.Band20Gain
|
||||
};
|
||||
_equalizer->UpdateEqualizers(bandGains, SoundResampler::SpcSampleRate);
|
||||
_equalizer->UpdateEqualizers(bandGains, Spc::SpcSampleRate);
|
||||
_equalizer->ApplyEqualizer(sampleCount, samples);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "stdafx.h"
|
||||
#include "SoundResampler.h"
|
||||
#include "Console.h"
|
||||
#include "Spc.h"
|
||||
#include "EmuSettings.h"
|
||||
#include "SoundMixer.h"
|
||||
#include "VideoRenderer.h"
|
||||
|
@ -9,8 +10,8 @@
|
|||
SoundResampler::SoundResampler(Console *console)
|
||||
{
|
||||
_console = console;
|
||||
_blipBufLeft = blip_new(SoundResampler::SpcSampleRate);
|
||||
_blipBufRight = blip_new(SoundResampler::SpcSampleRate);
|
||||
_blipBufLeft = blip_new(Spc::SpcSampleRate);
|
||||
_blipBufRight = blip_new(Spc::SpcSampleRate);
|
||||
}
|
||||
|
||||
SoundResampler::~SoundResampler()
|
||||
|
@ -75,13 +76,13 @@ double SoundResampler::GetTargetRateAdjustment()
|
|||
|
||||
void SoundResampler::UpdateTargetSampleRate(uint32_t sampleRate)
|
||||
{
|
||||
uint32_t spcSampleRate = SoundResampler::SpcSampleRate;
|
||||
uint32_t spcSampleRate = Spc::SpcSampleRate;
|
||||
if(_console->GetSettings()->GetVideoConfig().IntegerFpsMode) {
|
||||
//Adjust sample rate when running at 60.0 fps instead of 60.1
|
||||
switch(_console->GetRegion()) {
|
||||
default:
|
||||
case ConsoleRegion::Ntsc: spcSampleRate = (uint32_t)(SoundResampler::SpcSampleRate * (60.0 / 60.0988118623484)); break;
|
||||
case ConsoleRegion::Pal: spcSampleRate = (uint32_t)(SoundResampler::SpcSampleRate * (50.0 / 50.00697796826829)); break;
|
||||
case ConsoleRegion::Ntsc: spcSampleRate = (uint32_t)(Spc::SpcSampleRate * (60.0 / 60.0988118623484)); break;
|
||||
case ConsoleRegion::Pal: spcSampleRate = (uint32_t)(Spc::SpcSampleRate * (50.0 / 50.00697796826829)); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,8 +113,8 @@ uint32_t SoundResampler::Resample(int16_t *inSamples, uint32_t sampleCount, uint
|
|||
blip_end_frame(_blipBufLeft, sampleCount);
|
||||
blip_end_frame(_blipBufRight, sampleCount);
|
||||
|
||||
uint32_t resampledCount = blip_read_samples(_blipBufLeft, outSamples, SoundResampler::SpcSampleRate, true);
|
||||
blip_read_samples(_blipBufRight, outSamples + 1, SoundResampler::SpcSampleRate, true);
|
||||
uint32_t resampledCount = blip_read_samples(_blipBufLeft, outSamples, Spc::SpcSampleRate, true);
|
||||
blip_read_samples(_blipBufRight, outSamples + 1, Spc::SpcSampleRate, true);
|
||||
|
||||
return resampledCount;
|
||||
}
|
|
@ -6,9 +6,6 @@ struct blip_t;
|
|||
|
||||
class SoundResampler
|
||||
{
|
||||
public:
|
||||
static constexpr int SpcSampleRate = 32000;
|
||||
|
||||
private:
|
||||
Console *_console;
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ Spc::Spc(Console* console)
|
|||
_operandB = 0;
|
||||
_enabled = true;
|
||||
|
||||
_clockRatio = (double)2048000 / _console->GetMasterClockRate();
|
||||
_clockRatio = (double)(Spc::SpcSampleRate * 64) / _console->GetMasterClockRate();
|
||||
}
|
||||
|
||||
#ifndef DUMMYSPC
|
||||
|
@ -359,7 +359,7 @@ void Spc::ProcessEndFrame()
|
|||
{
|
||||
Run();
|
||||
|
||||
_clockRatio = (double)2048000 / _console->GetMasterClockRate();
|
||||
_clockRatio = (double)(Spc::SpcSampleRate * 64) / _console->GetMasterClockRate();
|
||||
|
||||
int sampleCount = _dsp->sample_count();
|
||||
if(sampleCount != 0) {
|
||||
|
|
|
@ -22,6 +22,7 @@ class Spc : public ISerializable
|
|||
public:
|
||||
static constexpr int SpcRamSize = 0x10000;
|
||||
static constexpr int SpcRomSize = 0x40;
|
||||
static constexpr int SpcSampleRate = 32040;
|
||||
|
||||
private:
|
||||
static constexpr int SampleBufferSize = 0x20000;
|
||||
|
|
Loading…
Add table
Reference in a new issue