From 6782f7c75dd16b2b11bb95372ff81f1ccdd4599f Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Tue, 20 Dec 2016 21:47:50 +0100 Subject: [PATCH] Just figure out how many samples to read, then read it, instead of one-by-one. --- Core/HW/SasAudio.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index ae0dc707ab..f23b9e0ffc 100644 --- a/Core/HW/SasAudio.cpp +++ b/Core/HW/SasAudio.cpp @@ -502,13 +502,20 @@ void SasInstance::MixVoice(SasVoice &voice) { u32 sampleFrac = voice.sampleFrac; temp[tempPos++] = voice.resampleHist[0]; temp[tempPos++] = voice.resampleHist[1]; + + int samplesToRead = 0; for (int i = delay; i < grainSize; i++) { while (sampleFrac >= PSP_SAS_PITCH_BASE) { - voice.ReadSamples(&temp[tempPos++], 1); + samplesToRead++; sampleFrac -= PSP_SAS_PITCH_BASE; } sampleFrac += voice.pitch; } + voice.ReadSamples(&temp[tempPos], samplesToRead); + tempPos += samplesToRead; + + if (tempPos - 2 != samplesToRead) + Crash(); sampleFrac = voice.sampleFrac; for (int i = delay; i < grainSize; i++) {