Skip to content

Instantly share code, notes, and snippets.

@deckarep
Created June 28, 2024 17:34
Show Gist options
  • Save deckarep/d6e0f0884a22c8a4a4b9392155f9dad0 to your computer and use it in GitHub Desktop.
Save deckarep/d6e0f0884a22c8a4a4b9392155f9dad0 to your computer and use it in GitHub Desktop.
Extracts all .wav audio from Leisure Suit Larry Casino - originally written by @Doomlazer
# Original credit: @doomlazer
# https://github.com/Doomlazer/TrivialQuest/blob/main/audio/jokes/ExtractWavs.py
# Extract wav files from Larry's Casino audio.vol
# Sound effects can also be dumped from resources.vol
# jokes are 71.wav - 183.wav
#
# command to convert wav to mp3:
# for f in *.wav; do ffmpeg -i "$f" "${f%.wav}.mp3"; done
import struct
AUDIO_DEST_FOLDER = "extracted_audio/"
def dump_audio(from_file):
fnum = 0
with open(from_file, "rb") as f:
while (byte := f.read(1)):
if byte == b'\x52' and f.read(1) == b'\x49' and f.read(1) == b'\x46' and f.read(1) == b'\x46':
print("Found RIFF starting at: ", f.tell()-4)
size = struct.unpack('<i', f.read(4))[0]
print("wav size: ", size)
f.seek(-8, 1)
wav = f.read(size+8)
s = AUDIO_DEST_FOLDER + str(fnum) + "_" + from_file + ".wav"
fnum=fnum+1
nf = open(s, 'bw+')
nf.write(wav)
nf.close()
# Extract music + sfx.
dump_audio("resource.vol")
# Extract cast voice audio.
dump_audio("audio.vol")
@Doomlazer
Copy link

Doomlazer commented Jul 20, 2024

Grats, that's awesome! I'm excited to see the RLE algorithm.

You have to list yourself first in the credits for finally breaking it.

@deckarep
Copy link
Author

Thanks, here's the not-so-secret-sauce: https://github.com/deckarep/laffer-casino-extractor

@deckarep
Copy link
Author

@Doomlazer - would you be okay with also getting your .wav/jokes extractor in this repo for completion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment