mirror of https://github.com/snes9xgit/snes9x.git
Generate sample example.
This commit is contained in:
parent
1f7926c48b
commit
91790a5e08
16
apu/apu.cpp
16
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,13 +397,9 @@ void S9xFinalizeSamples (void)
|
|||
if (Settings.SoundSync && !Settings.TurboMode)
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.MSU1 && !msu::resampler->push((short *) msu::landing_buffer, S9xMSU1Samples()))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!Settings.SoundSync || Settings.TurboMode || Settings.Mute)
|
||||
spc::sound_in_sync = TRUE;
|
||||
else
|
||||
|
@ -649,8 +651,6 @@ void S9xAPUEndScanline (void)
|
|||
S9xAPUExecute();
|
||||
SNES::dsp.synchronize();
|
||||
|
||||
S9xMSU1Execute();
|
||||
|
||||
if (SNES::dsp.spc_dsp.sample_count() >= APU_MINIMUM_SAMPLE_BLOCK || !spc::sound_in_sync)
|
||||
S9xLandSamples();
|
||||
}
|
||||
|
|
16
msu1.cpp
16
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,20 +234,19 @@ void S9xMSU1Init(void)
|
|||
dataFile.open(S9xGetFilename(".msu", ROMFILENAME_DIR), std::ios::in | std::ios::binary);
|
||||
}
|
||||
|
||||
void S9xMSU1Execute(void)
|
||||
void S9xMSU1Generate(int sample_count)
|
||||
{
|
||||
static long long hitcount = 0;
|
||||
//return; // Dummy out for now because it's broken
|
||||
while ((bufPos < bufEnd) && (MSU1.MSU1_STATUS & AudioPlaying))
|
||||
partial_samples += 441000 * sample_count;
|
||||
|
||||
while ((bufPos < bufEnd) && (MSU1.MSU1_STATUS & AudioPlaying) && partial_samples > 320405)
|
||||
{
|
||||
hitcount++;
|
||||
if (audioFile.good())
|
||||
{
|
||||
audioPos += 2;
|
||||
int16 sample = 0;
|
||||
((uint8 *)&sample)[0] = audioFile.get();
|
||||
((uint8 *)&sample)[1] = audioFile.get();
|
||||
|
||||
|
||||
sample = (double)sample * (double)MSU1.MSU1_VOLUME / 255.0;
|
||||
|
||||
*bufPos = ((uint8 *)&sample)[0];
|
||||
|
@ -252,6 +254,8 @@ void S9xMSU1Execute(void)
|
|||
|
||||
bufPos += 2;
|
||||
|
||||
partial_samples -= 320405;
|
||||
|
||||
if (audioFile.eof())
|
||||
{
|
||||
if (MSU1.MSU1_STATUS & AudioRepeating)
|
||||
|
|
Loading…
Reference in New Issue