From e006ab5b2d05eb43e732b7c85b16556b6623d9df Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Feb 2014 18:39:27 -0800 Subject: [PATCH] Don't read the first 32 samples after keyon. The way I'm approximating this is ugly... --- Core/HW/SasAudio.cpp | 7 ++++++- Core/HW/SasAudio.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index 22e5776889..3c7781e821 100644 --- a/Core/HW/SasAudio.cpp +++ b/Core/HW/SasAudio.cpp @@ -468,7 +468,12 @@ void SasInstance::MixVoice(SasVoice &voice) { numSamples = grainSize * 4; } - voice.ReadSamples(resampleBuffer + 2, numSamples); + // This feels a bit hacky. The first 32 samples after a keyon are 0s. + if (voice.envelope.NeedsKeyOn()) { + voice.ReadSamples(resampleBuffer + 2 + 32, numSamples - 32); + } else { + voice.ReadSamples(resampleBuffer + 2, numSamples); + } // Smoothness HACKERY resampleBuffer[2 + numSamples] = resampleBuffer[2 + numSamples - 1]; diff --git a/Core/HW/SasAudio.h b/Core/HW/SasAudio.h index a0d7eeba94..2daf6104cf 100644 --- a/Core/HW/SasAudio.h +++ b/Core/HW/SasAudio.h @@ -146,9 +146,13 @@ public: int GetHeight() const { return height_ > (s64)PSP_SAS_ENVELOPE_HEIGHT_MAX ? PSP_SAS_ENVELOPE_HEIGHT_MAX : height_; } + bool NeedsKeyOn() const { + return state_ == STATE_KEYON; + } bool HasEnded() const { return state_ == STATE_OFF; } + int attackRate; int decayRate; int sustainRate;