mirror of https://github.com/snes9xgit/snes9x.git
MSU-1 pop/skip fixes
This commit is contained in:
parent
4f457f0c89
commit
32f70fa38e
|
@ -385,6 +385,7 @@ void S9xFinalizeSamples (void)
|
||||||
{
|
{
|
||||||
if (Settings.MSU1)
|
if (Settings.MSU1)
|
||||||
{
|
{
|
||||||
|
S9xMSU1SetOutput((int16 *)msu::landing_buffer, msu::buffer_size);
|
||||||
S9xMSU1Generate(SNES::dsp.spc_dsp.sample_count());
|
S9xMSU1Generate(SNES::dsp.spc_dsp.sample_count());
|
||||||
if (!msu::resampler->push((short *)msu::landing_buffer, S9xMSU1Samples()))
|
if (!msu::resampler->push((short *)msu::landing_buffer, S9xMSU1Samples()))
|
||||||
{
|
{
|
||||||
|
@ -415,9 +416,6 @@ void S9xFinalizeSamples (void)
|
||||||
spc::sound_in_sync = FALSE;
|
spc::sound_in_sync = FALSE;
|
||||||
|
|
||||||
SNES::dsp.spc_dsp.set_output((SNES::SPC_DSP::sample_t *) spc::landing_buffer, spc::buffer_size);
|
SNES::dsp.spc_dsp.set_output((SNES::SPC_DSP::sample_t *) spc::landing_buffer, spc::buffer_size);
|
||||||
|
|
||||||
if (Settings.MSU1)
|
|
||||||
S9xMSU1SetOutput((int16 *)msu::landing_buffer, msu::buffer_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void S9xLandSamples (void)
|
void S9xLandSamples (void)
|
||||||
|
@ -488,7 +486,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) * 44100 / 32040) << 2; // Always 16-bit, Stereo
|
msu::buffer_size = sample_count << 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);
|
||||||
|
|
||||||
|
|
27
msu1.cpp
27
msu1.cpp
|
@ -200,7 +200,7 @@
|
||||||
STREAM dataStream = NULL;
|
STREAM dataStream = NULL;
|
||||||
STREAM audioStream = NULL;
|
STREAM audioStream = NULL;
|
||||||
uint32 audioLoopPos;
|
uint32 audioLoopPos;
|
||||||
uint32 partial_samples;
|
size_t partial_samples;
|
||||||
|
|
||||||
// Sample buffer
|
// Sample buffer
|
||||||
int16 *bufPos, *bufBegin, *bufEnd;
|
int16 *bufPos, *bufBegin, *bufEnd;
|
||||||
|
@ -374,13 +374,13 @@ bool S9xMSU1ROMExists(void)
|
||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
void S9xMSU1Generate(int sample_count)
|
void S9xMSU1Generate(size_t sample_count)
|
||||||
{
|
{
|
||||||
partial_samples += 44100 * sample_count;
|
partial_samples += 4410 * sample_count;
|
||||||
|
|
||||||
while (((uintptr_t)bufPos < (uintptr_t)bufEnd) && (MSU1.MSU1_STATUS & AudioPlaying) && partial_samples > 32040)
|
while (((uintptr_t)bufPos < (uintptr_t)bufEnd) && partial_samples > 3204)
|
||||||
{
|
{
|
||||||
if (audioStream)
|
if (MSU1.MSU1_STATUS & AudioPlaying && audioStream)
|
||||||
{
|
{
|
||||||
int16 sample;
|
int16 sample;
|
||||||
int bytes_read = READ_STREAM((char *)&sample, 2, audioStream);
|
int bytes_read = READ_STREAM((char *)&sample, 2, audioStream);
|
||||||
|
@ -390,7 +390,7 @@ void S9xMSU1Generate(int sample_count)
|
||||||
|
|
||||||
*(bufPos++) = sample;
|
*(bufPos++) = sample;
|
||||||
MSU1.MSU1_AUDIO_POS += 2;
|
MSU1.MSU1_AUDIO_POS += 2;
|
||||||
partial_samples -= 32040;
|
partial_samples -= 3204;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (bytes_read >= 0)
|
if (bytes_read >= 0)
|
||||||
|
@ -399,7 +399,7 @@ void S9xMSU1Generate(int sample_count)
|
||||||
|
|
||||||
*(bufPos++) = sample;
|
*(bufPos++) = sample;
|
||||||
MSU1.MSU1_AUDIO_POS += 2;
|
MSU1.MSU1_AUDIO_POS += 2;
|
||||||
partial_samples -= 32040;
|
partial_samples -= 3204;
|
||||||
|
|
||||||
if (MSU1.MSU1_STATUS & AudioRepeating)
|
if (MSU1.MSU1_STATUS & AudioRepeating)
|
||||||
{
|
{
|
||||||
|
@ -410,25 +410,24 @@ void S9xMSU1Generate(int sample_count)
|
||||||
{
|
{
|
||||||
MSU1.MSU1_STATUS &= ~(AudioPlaying | AudioRepeating);
|
MSU1.MSU1_STATUS &= ~(AudioPlaying | AudioRepeating);
|
||||||
REVERT_STREAM(audioStream, 8, 0);
|
REVERT_STREAM(audioStream, 8, 0);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MSU1.MSU1_STATUS &= ~(AudioPlaying | AudioRepeating);
|
MSU1.MSU1_STATUS &= ~(AudioPlaying | AudioRepeating);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MSU1.MSU1_STATUS &= ~(AudioPlaying | AudioRepeating);
|
MSU1.MSU1_STATUS &= ~(AudioPlaying | AudioRepeating);
|
||||||
return;
|
partial_samples -= 3204;
|
||||||
|
*(bufPos++) = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8 S9xMSU1ReadPort(int port)
|
uint8 S9xMSU1ReadPort(uint8 port)
|
||||||
{
|
{
|
||||||
switch (port)
|
switch (port)
|
||||||
{
|
{
|
||||||
|
@ -466,7 +465,7 @@ uint8 S9xMSU1ReadPort(int port)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void S9xMSU1WritePort(int port, uint8 byte)
|
void S9xMSU1WritePort(uint8 port, uint8 byte)
|
||||||
{
|
{
|
||||||
switch (port)
|
switch (port)
|
||||||
{
|
{
|
||||||
|
@ -537,12 +536,12 @@ void S9xMSU1WritePort(int port, uint8 byte)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16 S9xMSU1Samples(void)
|
size_t S9xMSU1Samples(void)
|
||||||
{
|
{
|
||||||
return bufPos - bufBegin;
|
return bufPos - bufBegin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void S9xMSU1SetOutput(int16 * out, int size)
|
void S9xMSU1SetOutput(int16 * out, size_t size)
|
||||||
{
|
{
|
||||||
bufPos = bufBegin = out;
|
bufPos = bufBegin = out;
|
||||||
bufEnd = out + size;
|
bufEnd = out + size;
|
||||||
|
|
10
msu1.h
10
msu1.h
|
@ -231,11 +231,11 @@ void S9xMSU1Init(void);
|
||||||
bool S9xMSU1ROMExists(void);
|
bool S9xMSU1ROMExists(void);
|
||||||
STREAM S9xMSU1OpenFile(char *msu_ext);
|
STREAM S9xMSU1OpenFile(char *msu_ext);
|
||||||
void S9xMSU1Init(void);
|
void S9xMSU1Init(void);
|
||||||
void S9xMSU1Generate(int sample_count);
|
void S9xMSU1Generate(size_t sample_count);
|
||||||
uint8 S9xMSU1ReadPort(int port);
|
uint8 S9xMSU1ReadPort(uint8 port);
|
||||||
void S9xMSU1WritePort(int port, uint8 byte);
|
void S9xMSU1WritePort(uint8 port, uint8 byte);
|
||||||
uint16 S9xMSU1Samples(void);
|
size_t S9xMSU1Samples(void);
|
||||||
void S9xMSU1SetOutput(int16 *out, int size);
|
void S9xMSU1SetOutput(int16 *out, size_t size);
|
||||||
void S9xMSU1PostLoadState(void);
|
void S9xMSU1PostLoadState(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue