Skip to content

Instantly share code, notes, and snippets.

@paulguy
Last active March 6, 2023 23:10
Show Gist options
  • Select an option

  • Save paulguy/95d318de70b1ead191978f571d94fed9 to your computer and use it in GitHub Desktop.

Select an option

Save paulguy/95d318de70b1ead191978f571d94fed9 to your computer and use it in GitHub Desktop.
Troubled Souls music converter
#!/usr/bin/env python
import io
import struct
intstruct = struct.Struct('>I')
buffers = []
editlist = None
endFound = False
with open("Music.rsrc", 'rb') as infile:
infile.seek(0x14B, io.SEEK_SET)
while True:
size = intstruct.unpack(infile.read(4))[0]
print(size)
if size < 1024:
if not endFound:
infile.seek(size, io.SEEK_CUR)
endFound = True
continue
else:
editlist = infile.read(size)
break
infile.seek(42, io.SEEK_CUR)
buffers.append(infile.read(size-42))
with open("Music.pcm", 'wb') as outfile:
for item in editlist[1:]:
item = item - ord('A')
print(item)
outfile.write(buffers[item])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment