Skip to content

Commit

Permalink
Merge pull request #1974 from unknownbrackets/sas-audio
Browse files Browse the repository at this point in the history
Fix undead VAG loops, KeyOff should stop them
  • Loading branch information
hrydgard committed May 29, 2013
2 parents f32fa30 + 42ced72 commit 89b2fdf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Core/HW/SasAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void VagDecoder::DecodeBlock(u8 *&readp) {
predict_nr >>= 4;
int flags = *readp++;
if (flags == 7) {
VERBOSE_LOG(SAS, "VAG ending block at %d", curBlock_);
end_ = true;
return;
}
Expand Down Expand Up @@ -102,13 +103,14 @@ void VagDecoder::GetSamples(s16 *outSamples, int numSamples) {
u8 *readp = Memory::GetPointer(read_);
if (!readp)
{
WARN_LOG(HLE, "Bad VAG samples address?");
WARN_LOG(SAS, "Bad VAG samples address?");
return;
}
u8 *origp = readp;
for (int i = 0; i < numSamples; i++) {
if (curSample == 28) {
if (loopAtNextBlock_) {
VERBOSE_LOG(SAS, "Looping VAG from block %d/%d to %d", curBlock_, numBlocks_, loopStartBlock_);
// data_ starts at curBlock = -1.
read_ = data_ + 16 * loopStartBlock_ + 16;
readp = Memory::GetPointer(read_);
Expand Down Expand Up @@ -482,6 +484,7 @@ void SasVoice::KeyOn() {
void SasVoice::KeyOff() {
on = false;
envelope.KeyOff();
vag.SetLoop(false);
}

void SasVoice::ChangedParams(bool changedVag) {
Expand Down
1 change: 1 addition & 0 deletions Core/HW/SasAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class VagDecoder {

void DecodeBlock(u8 *&readp);
bool End() const { return end_; }
void SetLoop(bool enabled) { loopEnabled_ = enabled; }

void DoState(PointerWrap &p);

Expand Down

0 comments on commit 89b2fdf

Please sign in to comment.