Implement pcm voice correctly.

This commit is contained in:
oioitff committed 2013-05-24 00:42:15 +08:00
1 parent 4d97916058
commit 99f8041375
3 files changed
+14 -4

No files matched your search

+1
View File
@@ -164,6 +164,7 @@ u32 sceSasSetVoicePCM(u32 core, int voiceNum, u32 pcmAddr, int size, int loop)
v.type = VOICETYPE_PCM;
v.pcmAddr = pcmAddr;
v.pcmSize = size;
v.pcmIndex = 0;
v.loop = loop ? false : true;
v.playing = true;
v.ChangedParams(pcmAddr == prevPcmAddr);
+12 -4
View File
@@ -311,10 +311,17 @@ void SasInstance::Mix(u32 outAddr, u32 inAddr, int leftVol, int rightVol) {
break;
case VOICETYPE_PCM:
{
u32 size = std::min(voice.pcmSize, (int)(numSamples * sizeof(s16)));
Memory::Memcpy(resampleBuffer + 2, voice.pcmAddr, size);
if (numSamples * sizeof(s16) > size)
memset(resampleBuffer + 2 + voice.pcmSize, 0, numSamples * sizeof(s16) - size);
u32 size = std::min(voice.pcmSize * 2 - voice.pcmIndex, (int)(numSamples * sizeof(s16)));
memset(resampleBuffer + 2, 0, numSamples * sizeof(s16));
if (!voice.on) {
voice.pcmIndex = 0;
break;
}
Memory::Memcpy(resampleBuffer + 2, voice.pcmAddr + voice.pcmIndex, size);
voice.pcmIndex += size;
if (voice.pcmIndex >= voice.pcmSize * 2) {
voice.pcmIndex = 0;
}
}
break;
default:
@@ -357,6 +364,7 @@ void SasInstance::Mix(u32 outAddr, u32 inAddr, int leftVol, int rightVol) {
// Let's hope grainSize is a power of 2.
//voice.sampleFrac &= grainSize * PSP_SAS_PITCH_BASE - 1;
voice.sampleFrac -= numSamples * PSP_SAS_PITCH_BASE;
if (voice.envelope.HasEnded())
{
// NOTICE_LOG(SAS, "Hit end of envelope");
+1
View File
@@ -196,6 +196,7 @@ struct SasVoice
int vagSize;
u32 pcmAddr;
int pcmSize;
int pcmIndex;
int sampleRate;
int sampleFrac;