From 11df9dabf9abe62b8de94a454e2d53873f64c76c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 18 Feb 2014 23:32:37 -0800 Subject: [PATCH] Add an extra delay to VAG keyon. It seems to come in an extra sample late. PCM doesn't. This corrects timing for VAG samples so they match up exactly. Really minor, of course... --- Core/HW/SasAudio.cpp | 5 ++++- Core/HW/SasAudio.h | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index fb9254b1fe..542b3953f1 100644 --- a/Core/HW/SasAudio.cpp +++ b/Core/HW/SasAudio.cpp @@ -48,7 +48,7 @@ static const s8 f[16][2] = { { 0, 0 }, }; -void VagDecoder::Start(u32 data, int vagSize, bool loopEnabled) { +void VagDecoder::Start(u32 data, u32 vagSize, bool loopEnabled) { loopEnabled_ = loopEnabled; loopAtNextBlock_ = false; loopStartBlock_ = 0; @@ -462,6 +462,9 @@ void SasInstance::MixVoice(SasVoice &voice) { const bool ignorePitch = voice.type == VOICETYPE_PCM && voice.pitch > PSP_SAS_PITCH_BASE; if (voice.envelope.NeedsKeyOn()) { int delay = ignorePitch ? 32 : (32 * (u32)voice.pitch) >> PSP_SAS_PITCH_BASE_SHIFT; + // VAG seems to have an extra sample delay (not shared by PCM.) + if (voice.type == VOICETYPE_VAG) + ++delay; voice.ReadSamples(resampleBuffer + 2 + delay, numSamples - delay); } else { voice.ReadSamples(resampleBuffer + 2, numSamples); diff --git a/Core/HW/SasAudio.h b/Core/HW/SasAudio.h index ffcf66eddb..0c825652ab 100644 --- a/Core/HW/SasAudio.h +++ b/Core/HW/SasAudio.h @@ -88,7 +88,7 @@ enum VoiceType { class VagDecoder { public: VagDecoder() : data_(0), read_(0), end_(true) {} - void Start(u32 dataPtr, int vagSize, bool loopEnabled); + void Start(u32 dataPtr, u32 vagSize, bool loopEnabled); void GetSamples(s16 *outSamples, int numSamples); @@ -229,7 +229,7 @@ struct SasVoice { VoiceType type; u32 vagAddr; - int vagSize; + u32 vagSize; u32 pcmAddr; int pcmSize; int pcmIndex;