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...
This commit is contained in:
Unknown W. Brackets 2014-02-18 23:32:37 -08:00
parent 9ceeedba8d
commit 11df9dabf9
2 changed files with 6 additions and 3 deletions

View file

@ -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);

View file

@ -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;