ROM Hack Scott Pilgrim vs The World: The Game audio volume fix

bobmcjr

Well-Known Member
OP
Member
Joined
Apr 26, 2013
Messages
1,156
Trophies
1
XP
3,279
Country
United States
I guess this is a ROM Hack lol

The PC port of this game has had a bug since its release almost a year ago that has resulted in super quiet audio for seemingly no good reason.

Over the past two days, I've gone and reverse engineered enough of the game to track down the relevant parts in the audio code, and discovered the issue is related to how the game uses XAudio. The game attempts to create 8-channel surround sound for no apparent reason, and then proceeds to only use the left and right channels as far as I know (please tell me if this is not the case, I have not played the whole thing with this patch, but I didn't see any surround-related code outside of XAudio).

Under XAudio2.7 specifically, when using 8-channel sound to output to a 2-channel stereo output, XAudio2.7 presumably downmixes all the channels with some factor to avoid clipping. However, the 6 unused channels have their volumes set to 0. This results in an unnecessary roughly -13.5dB drop in audio volume (XAudio2.9 does not seem to have this drop).

After a good 16 hours+ of searching, the solution was to simply not ask for 8-channel surround sound in a single-byte patch, asking for normal stereo instead.


I don't really know how to release patches like this, so I'm just including the raw x64dbg patches I made.
The patch should be applied to Scott.exe with the following SHA256 checksum:
300F31732679D28EF4F8D99F176CDA3F55BAEFAC41E195D230818EAD1CD0141B

Pick one of the following included patches to apply:
DumbSurroundToStereo.1337 is the basic fix
S2S_Louder.1337 further amplifies the game by 2
S2S_Loudest.1337 further still amplifies the game by 4 (this is probably too loud)
 

Attachments

  • Scott Pilgrim_Patches.zip
    621 bytes · Views: 223

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,796
Trophies
3
XP
28,413
Country
United Kingdom
The OP is still around (was on earlier today it seems) but for the time being
https://x64dbg.com/ is seemingly the tool used to find the relevant problems with the game, it also features patching options it seems (fairly standard feature in such software really) which is what the patches above use.

It mentions it is for a specific file (if the devs released an update in the time since or someone tries this on an older version then with modern PC games/compilers it will not match the expected file and locations for changes) and gives a SHA256 hash that it expects
https://codebeautify.org/sha256-hash-generator should have one if you want to confirm it.

I am not sure offhand where the patch options are in the program but hunt around the menus (it is all I would have done https://xkcd.com/627/ ) and you should be able to find it, hopefully them lacking on its wiki page mean it is simple and obvious. From there you are given three patches it seems. Basic fix, 2x volume multiply and 4x volume multiply which is noted as possibly being a bit much so pick which one you want. Most patching tools have the source file you are going to patch, the patch containing the required changes and the destination you want the newly altered file to land (some really old tools will do it in place so always have backup) so nothing too drastic.
 

DV2FOX

New Member
Newbie
Joined
Jan 5, 2023
Messages
2
Trophies
0
Age
38
XP
13
Country
Spain
Sadly this patch cannot be applied to today's STEAM release. I tried grabbing the exe, put it into the app ya shared, put the 1st fix into the patch but it says that some bytes/whatever does NOT MATCH with the exe.

If i tried to ignore the message and continue on patching it'd patch the file anyways, but the game would still sound as low as... Errr...*BEEEP!*

The STEAM exe obviously does not uses the uPlay version's of the exe but a new one (And still with Denuvo)

BobMcJrr, do you think you could re-patch the new STEAM exe file?. The game's actually on a huge sale for just 5€/$ (A big steal)

I bought the game instantly but whenever i've noticed this issue and seen it's been nearly 2 years with this issue i was like "How come they haven't fixed this yet?...."

Thanks in advance
 
Last edited by DV2FOX,

bobmcjr

Well-Known Member
OP
Member
Joined
Apr 26, 2013
Messages
1,156
Trophies
1
XP
3,279
Country
United States
Sadly this patch cannot be applied to today's STEAM release. I tried grabbing the exe, put it into the app ya shared, put the 1st fix into the patch but it says that some bytes/whatever does NOT MATCH with the exe.

The STEAM exe obviously does not uses the uPlay version's of the exe but a new one (And still with Denuvo)

BobMcJrr, do you think you could re-patch the new STEAM exe file?. The game's actually on a huge sale for just 5€/$ (A big steal)

I bought the game instantly but whenever i've noticed this issue and seen it's been nearly 2 years with this issue i was like "How come they haven't fixed this yet?...."

Thanks in advance
 

Attachments

  • Scott Pilgrim Patches Steam (x64dbg).zip
    656 bytes · Views: 124
  • Scott Pilgrim Patches Steam (xdelta3).zip
    2.2 KB · Views: 115

shengolol

New Member
Newbie
Joined
Jan 9, 2019
Messages
2
Trophies
0
Age
30
XP
65
Country
Germany
@bobmcjr , could you please roughly outline how you did the troubleshooting and reverse engineering for this? Which debugger did you use, etc? I would be very grateful for this as I am currently learning reverse engineering. Also, for new updates, others could produce a patch.
 

bobmcjr

Well-Known Member
OP
Member
Joined
Apr 26, 2013
Messages
1,156
Trophies
1
XP
3,279
Country
United States
@bobmcjr , could you please roughly outline how you did the troubleshooting and reverse engineering for this? Which debugger did you use, etc? I would be very grateful for this as I am currently learning reverse engineering. Also, for new updates, others could produce a patch.
iirc I mostly did it with x64dbg, procmon, and a little Ghidra. While this game has Denuvo, as it turns out, Denuvo is super tolerant of reverse engineering attempts and as long as you're not attempting to touch the DRM, things are fairly normal.

I believe I found the part where it outputs the samples by converting them from float to s16 with a lucky search for the constant 32768.0f and messing with that code.

I wanted to look at the xaudio initialization process to see if it had any funny filters, and that with a combination of writing my own program that mimicked the game's xaudio initialization process led me to discovering the behavior of downmixing in xaudio 2.7.

I did some recordings of a 7.1 channel audio device, and while the game requests 7.1 surround, it never appears to make use of the other channels. Interestingly I know for a fact the PS3 version of the game does, so they clearly messed something up in the PC port. I'd be interested to know if the modern console ports do proper 7.1 surround.

I feel like there's probably a better fix deeper in the game's audio engine, but tracing the audio functions is kind of a pain.

Edit: I forgot the important one. I wouldn't have been able to actually trace the XAudio initialization without the somewhat poorly-named API Monitor: http://www.rohitab.com/apimonitor
Post automatically merged:

Right, I decided to dig into this a little more, and discovered why the audio is still fairly quiet even after fixing the funny 7.1 surround channel bug.

I have located where the volume setting gets applied as well as the values themselves for each of the 11 steps:
Music:
Bars​
Gain​
0​
0​
1​
0.039753​
2​
0.0795059​
3​
0.119587​
4​
0.159012​
5​
0.199533​
6​
0.239175​
7​
0.277943​
8​
0.318024​
9​
0.358606​
10​
0.399065​
SFX:
Bars​
Gain​
0​
0​
1​
0.0706053​
2​
0.141211​
3​
0.212954​
4​
0.282421​
5​
0.354197​
6​
0.425907​
7​
0.495707​
8​
0.564842​
9​
0.636227​
10​
0.708393​

As you can see, there's a hefty dropoff on the music even at max volume, roughly -8dB!

I temporarily nerfed the volume controls so the gain is always 1.0, and that results in nice high-quality full-blast music without clipping (at least when no SFX are playing):
1673326058857.png


I believe I've located the function where the gain is calculated, so I'm looking into how that works now.
 
Last edited by bobmcjr,

bobmcjr

Well-Known Member
OP
Member
Joined
Apr 26, 2013
Messages
1,156
Trophies
1
XP
3,279
Country
United States
Last attempt at this I guess. The audio mixing of the PC port is so bad. I'm going to assume this was due to reliance on how consoles mixed audio and the game likely being designed for 7.1 surround sound? This is a hack that adjusts the dB->gain conversion to be louder. The individual dB specified for each audio source/sound file(?) are just wrong.

I found where the menu music gets set to -8dB explicitly and the sfx to -3dB, matching the tables I found above.

The sfx are still a bit weird, with some being too quiet while others are fine.

At this point I just recommend going back to emulating the PS3 version if you have it (the switch version might be ok? idk). It's a shame because the music on the PC port is uncompressed PCM too.
 

Attachments

  • Scott Steam DB hack.zip
    1 KB · Views: 71

bobmcjr

Well-Known Member
OP
Member
Joined
Apr 26, 2013
Messages
1,156
Trophies
1
XP
3,279
Country
United States
Right, after some comparison between PS3, 360, Switch, and PC, PS3 still wins hands down (and yes, I've confirmed this on rpcs3 and hardware).

PS3/360 seem to have some low-pass filter over the audio/music which I like that seems to be absent from the new ports; makes the sound effects less jarring imo.

PS3 has softer panning for sound effects; everything else I tested including 360 has the sound effects hard-panned left/right with a very tiny spot on the screen where it's centered. This is also very jarring when a sound effect is playing suddenly switches ears when you move on the screen.

360 version has the worst audio compression by far. PC is uncompressed, but I can't tell a meaningful difference while playing between PS3/PC/Switch.

PC obviously has the multiple audio bugs resulting in everything being very quiet, and sound effects are just mixed way quieter than the music compared to PS3 or 360.

Switch doesn't have the volume bugs, but sound effects are still too quiet imo.


I just really prefer the PS3's overall mix, so I strongly recommend just playing that version and only that version. It runs pretty much perfectly in rpcs3 (and while the game itself has bugs, these weren't fixed in the later ports either, so you're not missing much). I also just added nearest neighbor filtering to rpcs3 for sharp pixelated upscaling just for this game.


Another fun fact: the game is natively some multiple of 1080p. The PS3/360 versions just have black borders when run at 720p for integer scaling so there aren't weird scaling artifacts. However, seems Ubi was just lazy with the Switch port and enabled nearest scaling there, as I see the same artifacts on the Switch when doing 1080p->720p nearest with rpcs3 on my Deck.
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,796
Trophies
3
XP
28,413
Country
United Kingdom
Compressed as in someone twiddled the volume knob in the mixed/decided to hit normalise (if not worse) or compressed as in pushed the bitrate of their MP3 (or WMA in the case of the 360 I guess) rather harder than is advisable?
 

bobmcjr

Well-Known Member
OP
Member
Joined
Apr 26, 2013
Messages
1,156
Trophies
1
XP
3,279
Country
United States
Compressed as in someone twiddled the volume knob in the mixed/decided to hit normalise (if not worse) or compressed as in pushed the bitrate of their MP3 (or WMA in the case of the 360 I guess) rather harder than is advisable?
The WMA or equivalent file compression seems to be pretty crusty on the 360 version.
PC is uncompressed PCM, and PS3 is some version of ATRAC which has always been pretty decent imo.
 

ZedHqX4

New Member
Newbie
Joined
Nov 22, 2023
Messages
2
Trophies
0
Age
39
XP
25
Country
Mexico
Last attempt at this I guess. The audio mixing of the PC port is so bad. I'm going to assume this was due to reliance on how consoles mixed audio and the game likely being designed for 7.1 surround sound? This is a hack that adjusts the dB->gain conversion to be louder. The individual dB specified for each audio source/sound file(?) are just wrong.

I found where the menu music gets set to -8dB explicitly and the sfx to -3dB, matching the tables I found above.

The sfx are still a bit weird, with some being too quiet while others are fine.

At this point I just recommend going back to emulating the PS3 version if you have it (the switch version might be ok? idk). It's a shame because the music on the PC port is uncompressed PCM too.
Does the last patch works on the ubi store release or is steam only?
 

ZedHqX4

New Member
Newbie
Joined
Nov 22, 2023
Messages
2
Trophies
0
Age
39
XP
25
Country
Mexico
First post in the thread is Ubi store, scroll down for Steam.


Ok, so the ubi store has only one fix and the steam 2? or what difference is there between the steam patches you posted on Jan 5 and the one on Jan 10?

Last attempt at this I guess. The audio mixing of the PC port is so bad. I'm going to assume this was due to reliance on how consoles mixed audio and the game likely being designed for 7.1 surround sound? This is a hack that adjusts the dB->gain conversion to be louder. The individual dB specified for each audio source/sound file(?) are just wrong.

I found where the menu music gets set to -8dB explicitly and the sfx to -3dB, matching the tables I found above.

The sfx are still a bit weird, with some being too quiet while others are fine.

At this point I just recommend going back to emulating the PS3 version if you have it (the switch version might be ok? idk). It's a shame because the music on the PC port is uncompressed PCM too.
 

bobmcjr

Well-Known Member
OP
Member
Joined
Apr 26, 2013
Messages
1,156
Trophies
1
XP
3,279
Country
United States
Ok, so the ubi store has only one fix and the steam 2? or what difference is there between the steam patches you posted on Jan 5 and the one on Jan 10?
Oh right I forgot about the Jan 10th attempt.

Ubisoft store only has the patches in x64dbg .1337 format, while the Steam version has them in .1337 and xdelta3. Besides that the 2021 Ubi and Jan 5 Steam patches should be the same.

The January 10th patch was another attempt at messing with the volume more on the Steam version.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    BigOnYa @ BigOnYa: Alright @SylverReZ you win, lets go double or nothing.