mirror of https://github.com/snes9xgit/snes9x.git
MSU-1 audio streaming now works, but it pops.
This commit is contained in:
parent
024d92086a
commit
80d9ee7a97
29
msu1.cpp
29
msu1.cpp
|
@ -236,12 +236,24 @@ void S9xMSU1Init(void)
|
||||||
|
|
||||||
void S9xMSU1Generate(int sample_count)
|
void S9xMSU1Generate(int sample_count)
|
||||||
{
|
{
|
||||||
|
static uint32 hitcount = 0;
|
||||||
partial_samples += 441000 * sample_count;
|
partial_samples += 441000 * 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 > 320405)
|
||||||
{
|
{
|
||||||
if (audioFile.is_open())
|
if (audioFile.is_open())
|
||||||
{
|
{
|
||||||
|
int16 sample;
|
||||||
|
if (audioFile.read((char *)&sample, 2).good())
|
||||||
|
{
|
||||||
|
hitcount++;
|
||||||
|
sample = (double)sample * (double)MSU1.MSU1_VOLUME / 255.0;
|
||||||
|
|
||||||
|
*(bufPos++) = sample;
|
||||||
|
audioPos += 2;
|
||||||
|
partial_samples -= 320405;
|
||||||
|
}
|
||||||
|
else
|
||||||
if (audioFile.eof())
|
if (audioFile.eof())
|
||||||
{
|
{
|
||||||
if (MSU1.MSU1_STATUS & AudioRepeating)
|
if (MSU1.MSU1_STATUS & AudioRepeating)
|
||||||
|
@ -256,20 +268,15 @@ void S9xMSU1Generate(int sample_count)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
int16 sample = 0;
|
{
|
||||||
audioFile.get(((char *)&sample), 2);
|
MSU1.MSU1_STATUS &= ~(AudioPlaying | AudioRepeating);
|
||||||
|
return;
|
||||||
sample = (double)sample * (double)MSU1.MSU1_VOLUME / 255.0;
|
}
|
||||||
|
|
||||||
*(bufPos++) = sample;
|
|
||||||
audioPos += 2;
|
|
||||||
partial_samples -= 320405;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MSU1.MSU1_STATUS &= ~(AudioPlaying | AudioRepeating);
|
MSU1.MSU1_STATUS &= ~(AudioPlaying | AudioRepeating);
|
||||||
audioFile.seekg(8);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,7 +343,7 @@ void S9xMSU1WritePort(int port, uint8 byte)
|
||||||
fName[strlen(fName) - 4] = '\0';
|
fName[strlen(fName) - 4] = '\0';
|
||||||
sprintf(fName, "%s-%d.pcm", fName, audioTrack);
|
sprintf(fName, "%s-%d.pcm", fName, audioTrack);
|
||||||
|
|
||||||
audioFile.open(fName);
|
audioFile.open(fName, std::ios::in | std::ios::binary);
|
||||||
if (audioFile.is_open() && audioFile.good())
|
if (audioFile.is_open() && audioFile.good())
|
||||||
{
|
{
|
||||||
MSU1.MSU1_STATUS |= AudioError;
|
MSU1.MSU1_STATUS |= AudioError;
|
||||||
|
|
Loading…
Reference in New Issue