mirror of https://github.com/snes9xgit/snes9x.git
Merge branch 'msu1' of https://github.com/snes9xgit/snes9x into msu1
This commit is contained in:
commit
024d92086a
21
apu/apu.cpp
21
apu/apu.cpp
|
@ -383,7 +383,13 @@ void S9xFinalizeSamples (void)
|
|||
{
|
||||
if (!Settings.Mute)
|
||||
{
|
||||
if (!spc::resampler->push((short *) spc::landing_buffer, SNES::dsp.spc_dsp.sample_count ()))
|
||||
if (Settings.MSU1)
|
||||
{
|
||||
S9xMSU1Generate(SNES::dsp.spc_dsp.sample_count());
|
||||
msu::resampler->push((short *)msu::landing_buffer, S9xMSU1Samples());
|
||||
}
|
||||
|
||||
if (!spc::resampler->push((short *)spc::landing_buffer, SNES::dsp.spc_dsp.sample_count()))
|
||||
{
|
||||
/* We weren't able to process the entire buffer. Potential overrun. */
|
||||
spc::sound_in_sync = FALSE;
|
||||
|
@ -391,20 +397,9 @@ void S9xFinalizeSamples (void)
|
|||
if (Settings.SoundSync && !Settings.TurboMode)
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.MSU1)
|
||||
{
|
||||
S9xMSU1Execute();
|
||||
if (!msu::resampler->push((short *)msu::landing_buffer, S9xMSU1Samples()))
|
||||
{
|
||||
spc::sound_in_sync = FALSE;
|
||||
|
||||
if (Settings.SoundSync && !Settings.TurboMode)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!Settings.SoundSync || Settings.TurboMode || Settings.Mute)
|
||||
spc::sound_in_sync = TRUE;
|
||||
else
|
||||
|
|
11
msu1.cpp
11
msu1.cpp
|
@ -199,6 +199,7 @@ std::ifstream dataFile, audioFile;
|
|||
uint32 dataPos, audioPos, audioResumePos, audioLoopPos;
|
||||
uint16 audioTrack, audioResumeTrack;
|
||||
char fName[64];
|
||||
uint32 partial_samples;
|
||||
|
||||
// Sample buffer
|
||||
int16 *bufPos, *bufBegin, *bufEnd;
|
||||
|
@ -222,6 +223,8 @@ void S9xMSU1Init(void)
|
|||
bufBegin = 0;
|
||||
bufEnd = 0;
|
||||
|
||||
partial_samples = 0;
|
||||
|
||||
if (dataFile.is_open())
|
||||
dataFile.close();
|
||||
|
||||
|
@ -231,9 +234,11 @@ void S9xMSU1Init(void)
|
|||
dataFile.open(S9xGetFilename(".msu", ROMFILENAME_DIR), std::ios::in | std::ios::binary);
|
||||
}
|
||||
|
||||
void S9xMSU1Execute(void)
|
||||
void S9xMSU1Generate(int sample_count)
|
||||
{
|
||||
while (((uintptr_t)bufPos < (uintptr_t)bufEnd) && (MSU1.MSU1_STATUS & AudioPlaying))
|
||||
partial_samples += 441000 * sample_count;
|
||||
|
||||
while (((uintptr_t)bufPos < (uintptr_t)bufEnd) && (MSU1.MSU1_STATUS & AudioPlaying) && partial_samples > 320405)
|
||||
{
|
||||
if (audioFile.is_open())
|
||||
{
|
||||
|
@ -258,8 +263,8 @@ void S9xMSU1Execute(void)
|
|||
sample = (double)sample * (double)MSU1.MSU1_VOLUME / 255.0;
|
||||
|
||||
*(bufPos++) = sample;
|
||||
|
||||
audioPos += 2;
|
||||
partial_samples -= 320405;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue