mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-03 03:03:50 +01:00
Implement pcm voice correctly.
This commit is contained in:
1 parent
4d97916058
commit
99f8041375
3 files changed
+14
-4
No files matched your search
@@ -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
@@ -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");
|
||||
|
||||
@@ -196,6 +196,7 @@ struct SasVoice
|
||||
int vagSize;
|
||||
u32 pcmAddr;
|
||||
int pcmSize;
|
||||
int pcmIndex;
|
||||
int sampleRate;
|
||||
|
||||
int sampleFrac;
|
||||
|
||||
Reference in new issue
Block a user