Skip to content

Commit

Permalink
Fix music not stopping fully (playing at low volume forever) when the…
Browse files Browse the repository at this point in the history
… game is paused.

There appears to be a bug introduced in a recent version of Avocado that was causing voice ADSR envelopes to not complete fully.

@JaCzekanski this fix might be of interest. The issue was reported by some users of 'PsyDoom' on DoomWorld:
https://www.doomworld.com/forum/topic/111024-psydoom-formerly-stationdoom-reverse-engineered-source-port-of-psx-doom-for-pc-early-progress/?page=4
  • Loading branch information
BodbDearg committed Mar 7, 2020
1 parent 9063083 commit d8203f6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion third_party_libs/avocado/avocado/src/device/spu/voice.cpp
Expand Up @@ -65,7 +65,17 @@ void Voice::processEnvelope() {
cycles *= 4;
}
if (e.direction == Dir::Decrease) {
step = step * adsrVolume._reg / 0x8000;
// DOOM: fix music not stopping fully when the game is paused, despite the game stopping all voices.
// It seems as though the ADSR envelope was not fully completing, resulting in some of the music voices
// playing at a low volume when the game was paused. This issue was introduced in an Avocado update.
// Previously this worked due to floating point operations and a 'ceil()' being done.
#if DOOM_AVOCADO_MODS
int stepMul = adsrVolume._reg / 0x8000;
stepMul += ((adsrVolume._reg & 0x7FFF) != 0) ? 1 : 0; // Round this up to the next whole number (ceil)
step *= stepMul;
#else
step = step * adsrVolume._reg / 0x8000;
#endif
}
}

Expand Down

4 comments on commit d8203f6

@JaCzekanski
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BodbDearg Thanks for the heads up.
I'll try to check your bugfix as soon as I have a way to compare it against the real hardware - currently I'm waiting for parts to mod my PS1 for digital audio capture.
Then I'll be able to improve my implementation and find such bugs.

@BodbDearg
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're welcome! That sounds like a nice addition to your arsenal :) Looking forward to seeing the advancements that come from being able to directly compare against the real hardware.

@JaCzekanski
Copy link

@JaCzekanski JaCzekanski commented on d8203f6 Mar 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearly a regression - didn't test my changes before removing float-based computations.
Fixed in latest commit using slightly simpler method.

@BodbDearg
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for the update!

Please sign in to comment.