Use 32040hz with more consistency.

This commit is contained in:
Brandon Wright 2016-12-09 17:50:50 -06:00
parent 6b46ed0d00
commit cf846e0c56
2 changed files with 8 additions and 10 deletions

View File

@ -462,7 +462,7 @@ static void UpdatePlaybackRate (void)
if (Settings.MSU1) if (Settings.MSU1)
{ {
time_ratio = (44100.0 / Settings.SoundPlaybackRate) * (Settings.SoundInputRate / 32040.5); time_ratio = (44100.0 / Settings.SoundPlaybackRate) * (Settings.SoundInputRate / 32040);
msu::resampler->time_ratio(time_ratio); msu::resampler->time_ratio(time_ratio);
} }
} }
@ -472,8 +472,8 @@ bool8 S9xInitSound (int buffer_ms, int lag_ms)
// buffer_ms : buffer size given in millisecond // buffer_ms : buffer size given in millisecond
// lag_ms : allowable time-lag given in millisecond // lag_ms : allowable time-lag given in millisecond
int sample_count = buffer_ms * 32000 / 1000; int sample_count = buffer_ms * 32040 / 1000;
int lag_sample_count = lag_ms * 32000 / 1000; int lag_sample_count = lag_ms * 32040 / 1000;
spc::lag_master = lag_sample_count; spc::lag_master = lag_sample_count;
if (Settings.Stereo) if (Settings.Stereo)
@ -488,7 +488,7 @@ bool8 S9xInitSound (int buffer_ms, int lag_ms)
spc::buffer_size <<= 1; spc::buffer_size <<= 1;
if (Settings.SixteenBitSound) if (Settings.SixteenBitSound)
spc::buffer_size <<= 1; spc::buffer_size <<= 1;
msu::buffer_size = ((buffer_ms * 44100 / 1000) * 441000 / 320405) << 2; // Always 16-bit, Stereo msu::buffer_size = ((buffer_ms * 44100 / 1000) * 44100 / 32040) << 2; // Always 16-bit, Stereo
printf("Sound buffer size: %d (%d samples)\n", spc::buffer_size, sample_count); printf("Sound buffer size: %d (%d samples)\n", spc::buffer_size, sample_count);

View File

@ -197,8 +197,6 @@
#include <fstream> #include <fstream>
#include <sys/stat.h> #include <sys/stat.h>
#define APU_DEFAULT_INPUT_RATE 32000
std::ifstream dataFile, audioFile; std::ifstream dataFile, audioFile;
uint32 audioLoopPos; uint32 audioLoopPos;
uint32 partial_samples; uint32 partial_samples;
@ -294,9 +292,9 @@ bool S9xMSU1ROMExists(void)
void S9xMSU1Generate(int sample_count) void S9xMSU1Generate(int sample_count)
{ {
partial_samples += 441000 * sample_count; partial_samples += 44100 * sample_count;
while (((uintptr_t)bufPos < (uintptr_t)bufEnd) && (MSU1.MSU1_STATUS & AudioPlaying) && partial_samples > 320405) while (((uintptr_t)bufPos < (uintptr_t)bufEnd) && (MSU1.MSU1_STATUS & AudioPlaying) && partial_samples > 32040)
{ {
if (audioFile.is_open()) if (audioFile.is_open())
{ {
@ -307,7 +305,7 @@ void S9xMSU1Generate(int sample_count)
*(bufPos++) = sample; *(bufPos++) = sample;
MSU1.MSU1_AUDIO_POS += 2; MSU1.MSU1_AUDIO_POS += 2;
partial_samples -= 320405; partial_samples -= 32040;
} }
else else
if (audioFile.eof()) if (audioFile.eof())
@ -316,7 +314,7 @@ void S9xMSU1Generate(int sample_count)
*(bufPos++) = sample; *(bufPos++) = sample;
MSU1.MSU1_AUDIO_POS += 2; MSU1.MSU1_AUDIO_POS += 2;
partial_samples -= 320405; partial_samples -= 32040;
if (MSU1.MSU1_STATUS & AudioRepeating) if (MSU1.MSU1_STATUS & AudioRepeating)
{ {