VOGONS


First post, by AllTinker

User metadata
Rank Newbie
Rank
Newbie

Hi folks, so as some of you know the talky version of Gabriel Knight 1 (up to and including the current GOG release) has an issue with the speech containing all sorts of clicks, pops and crackles.

I had a look into it and realised they'd never properly clamped their DPCM encoder - which thankfully isn't too difficult to repair after the fact, since the data is essentially all still "there". I'm now aware that others have discovered this previously, but I don't believe any full fix has ever been released. So to that end I've created a drop-in replacement RESOURCE.AUD file with the overflows repaired. The odd audio issue does still exist but these are unrelated to this particular issue.

I've tested the file in DOS and Windows using all released versions of the original CD I could find, and the current GOG version (ScummVM-based). I've done a quick playthrough and everything seemed OK.

EDIT - original raw file replaced with xdelta patch as discussed below - now available again here.

Last edited by AllTinker on 2024-11-30, 15:38. Edited 2 times in total.

itch / Bluesky / web

Reply 1 of 26, by jmarsh

User metadata
Rank Oldbie
Rank
Oldbie

As much as I admire the work, I don't think this is legal since the replacement RESOURCE.AUD is basically a copy of the game's asset containing all the speech.
Where exactly does the game's original DPCM decoder live? Could it be patched instead (or at the very least, inform ScummVM of the issue so they could modify their engine) ?

Reply 2 of 26, by AllTinker

User metadata
Rank Newbie
Rank
Newbie

Arguing hypothetical legal issues is beyond fruitless - if that were true, almost all mods which alter original data would be illegal. And heck, they probably are. Which is insane, but what else is new?

It's been a known issue for 30 years, the ScummVM developers are well aware of it. My fix worked for all versions, including ScummVM. No, modifying the DPCM decoder couldn't fix it, without insertion of lots of code which likely couldn't even be performant on target hardware.

Anyway it's gone now - I can't delete the post, so I'll have to wait for a moderator to do it. Sorry!

itch / Bluesky / web

Reply 5 of 26, by sunmax

User metadata
Rank Newbie
Rank
Newbie

Thanks for the fix AllTinker!

GK1 is one of the greatest adventures of all time, often ranking in the top 10, or even top 3.

If there was a binary patch for RESOURCE.AUD quite many players would enjoy the improved version.

Or if there is a tool that can be used to fix GK1 speech, maybe we can share it, as we did with the excellent SQ4 depop:

Space Quest IV CD-ROM audio

Most definitely this is work worthy to be preserved.

Reply 7 of 26, by Spikey

User metadata
Rank Oldbie
Rank
Oldbie
AllTinker wrote on 2024-11-28, 04:22:

Arguing hypothetical legal issues is beyond fruitless - if that were true, almost all mods which alter original data would be illegal. And heck, they probably are. Which is insane, but what else is new?

It's been a known issue for 30 years, the ScummVM developers are well aware of it. My fix worked for all versions, including ScummVM. No, modifying the DPCM decoder couldn't fix it, without insertion of lots of code which likely couldn't even be performant on target hardware.

Anyway it's gone now - I can't delete the post, so I'll have to wait for a moderator to do it. Sorry!

It is fruitless to debate old game copyright, I wholeheartedly agree and I'm sorry it's the first reply you got here. So, please reupload the file or post on the Internet Archive/etc! It's a worthy fix that should be out there. 😀

Good to see people working on this stuff after all this time, respect from another Aussie old gamer!

Reply 8 of 26, by DosFreak

User metadata
Rank l33t++
Rank
l33t++

I'm not sorry it was the first reply and in fact I'm glad to see fellow posters doing what they should be doing in a respectful way.
The willfull ignorance shown by other sites is not allowed here.
Don't upload the file here and don't link to it or hint on how to acquire it. Xdelta or a patch is the way and is acceptable.

How To Ask Questions The Smart Way
Make your games work offline

Reply 9 of 26, by jmarsh

User metadata
Rank Oldbie
Rank
Oldbie

I still think if it's known for sure that the problem is the original decoder not clamping its delta step, it would be fairly trivial to patch it. It's literally only three or four opcodes to clamp an integer.

Reply 10 of 26, by sunmax

User metadata
Rank Newbie
Rank
Newbie

According to the extensive study of tikalat on Sierra sound drivers, this type of issue cannot be fully addressed in the exe, and requires patching of the data. Results with patching the exe were suboptimal, and later replaced with RESOURCE.AUD patches (.ppf) for CD talkies. For reference:

Sierra/Dynamix sound driver hacking

"Switched tactics realizing it can't be done in EXE reliably. Looking at raw ADPCM files for 'peak overflows' - where they should've clipped the voice but allowed it to roll 32767 <--> -32768 (pretty bad pop). Then make a tool to reconnect the curve without overflow."

I recently had a long chat with ripsaw8080 (who coded the SQ4 depop) and also confirmed this.

Reply 12 of 26, by jmarsh

User metadata
Rank Oldbie
Rank
Oldbie
sunmax wrote on 2024-11-29, 07:25:
According to the extensive study of tikalat on Sierra sound drivers, this type of issue cannot be fully addressed in the exe, an […]
Show full quote

According to the extensive study of tikalat on Sierra sound drivers, this type of issue cannot be fully addressed in the exe, and requires patching of the data. Results with patching the exe were suboptimal, and later replaced with RESOURCE.AUD patches (.ppf) for CD talkies. For reference:

Sierra/Dynamix sound driver hacking

"Switched tactics realizing it can't be done in EXE reliably. Looking at raw ADPCM files for 'peak overflows' - where they should've clipped the voice but allowed it to roll 32767 <--> -32768 (pretty bad pop). Then make a tool to reconnect the curve without overflow."

I recently had a long chat with ripsaw8080 (who coded the SQ4 depop) and also confirmed this.

So it's not just applying clamping - it's basically remastering because they used a DPCM encoder that wasn't properly matched with the decoder.

Reply 13 of 26, by AllTinker

User metadata
Rank Newbie
Rank
Newbie
DosFreak wrote on 2024-11-29, 05:29:

Don't upload the file here and don't link to it or hint on how to acquire it. Xdelta or a patch is the way and is acceptable.

Yep, all good. There's nothing to even hint at.

The tool I developed is also disqualified - it's based on information/data extracted through direct disassembly & reverse engineering, and is thus almost certainly equally as legally problematic.

The xdelta route is probably the best overall option, for all its faults (e.g. requiring an exact source match, larger download, user difficulty). I might figure something out at some point when I have time.

jmarsh wrote on 2024-11-29, 07:42:

So it's not just applying clamping - it's basically remastering because they used a DPCM encoder that wasn't properly matched with the decoder.

Correct - the only way to do it in realtime would be to have fairly complex look-ahead algorithm which corrects the waveform. It's certainly possible; the overhead/latency would be fine on most modern PCs.

itch / Bluesky / web

Reply 14 of 26, by keropi

User metadata
Rank l33t++
Rank
l33t++

I hope a patch emerges eventually - always good to have fixed versions of old games it would be a shame this good work to go to waste 😀

🎵 🎧 PCMIDI MPU , OrpheusII , Action Rewind , Megacard and 🎶GoldLib soundcard website

Reply 15 of 26, by Palooka

User metadata
Rank Newbie
Rank
Newbie
AllTinker wrote on 2024-11-29, 08:12:

The tool I developed is also disqualified - it's based on information/data extracted through direct disassembly & reverse engineering, and is thus almost certainly equally as legally problematic.

The xdelta route is probably the best overall option, for all its faults (e.g. requiring an exact source match, larger download, user difficulty). I might figure something out at some point when I have time.

Surely it's fine as long as you still require the source files to create the repaired audio file?

I was sorta wondering myself if it would be that hard to just use a simple python DPCM decoder and a bit of scipy to do a similar thing... but maybe I'm trivialising how much work goes into it?

Would be keen to learn more.

Reply 16 of 26, by Palooka

User metadata
Rank Newbie
Rank
Newbie

I may have gotten a bit impatient and started looking into it myself - thankfully some of the old SCI tools still exist so it's relatively easy to decompress the .AUD file myself. Can I ask - did you descramble / decompress the file before you fixed the overflows?

Reply 17 of 26, by AllTinker

User metadata
Rank Newbie
Rank
Newbie

Alrighty, I evaluated a few different formats; LZMA-compressed xdelta with some tweaked window sizes won over everything else I tried. The patch (~181MB) is available here, and I used Delta Patcher to apply it as a test. I haven't tested the game again thoroughly but hopefully there aren't any issues. Let me know if you encounter any!

Enjoy! Apologies for the fuss.

Palooka wrote on 2024-11-30, 12:18:

Can I ask - did you descramble / decompress the file before you fixed the overflows?

I'm not sure what you mean by descramble, but yes, I decoded the container and the waveforms before processing. I personally didn't have any luck finding any existing tools which supported this particular AUD file/codec. In retrospect I probably should have just looked at the ScummVM source... Ah well. I prefer figuring this sort of stuff out myself anyway.

itch / Bluesky / web

Reply 19 of 26, by keropi

User metadata
Rank l33t++
Rank
l33t++
AllTinker wrote on 2024-11-30, 16:01:

Alrighty, I evaluated a few different formats; LZMA-compressed xdelta with some tweaked window sizes won over everything else I tried. The patch (~181MB) is available here, and I used Delta Patcher to apply it as a test. I haven't tested the game again thoroughly but hopefully there aren't any issues. Let me know if you encounter any!

Enjoy! Apologies for the fuss.

excellent, thanks!!!!

🎵 🎧 PCMIDI MPU , OrpheusII , Action Rewind , Megacard and 🎶GoldLib soundcard website