News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Megaman X4 PC Voice Mod help  (Read 3241 times)

Tetsuo

  • Newbie
  • *
  • Posts: 2
    • View Profile
Megaman X4 PC Voice Mod help
« on: November 23, 2015, 03:25:42 am »
Hey guys, I'm new here, but I saw a topic with the same question I had here: http://www.romhacking.net/forum/index.php/topic,18400.msg266183.html#msg266183

I have a hex editor (HxD) which is what I read is needed to edit the voices, as well as the sound file I want to edit "VO_PL01.SEZ"
Here is the file I want to edit: https://mega.nz/#!wttlSagK!tI5jxV33R1Ev_O2yN1D6jCKZVeLfMZG6YJXcpB9C0G4

How would I go about using a hex editor to replace the in-game voices with the .wav files I have.

For example, in the hex data of the file I want to edit, I see the list of wav files:


and when I open the wav file I want to use, I see:


How would I go about inserting my .wav file into the .sez file? Sorry, I am really at a loss. :( I appreciate any help!
« Last Edit: November 23, 2015, 03:31:52 am by Tetsuo »

Jorpho

  • Hero Member
  • *****
  • Posts: 4763
  • The cat screams with the voice of a man.
    • View Profile
Re: Megaman X4 PC Voice Mod help
« Reply #1 on: November 23, 2015, 09:35:03 am »
I remember that thread.  (You probably could have just bumped it instead of starting a new thread.)  Everything you need to know is already there in the post I made.  Is there something specific you would like clarified?

I could try to knock together some Python code to automate the process, but I have a busy week ahead of me.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

Tetsuo

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Megaman X4 PC Voice Mod help
« Reply #2 on: November 24, 2015, 02:41:19 am »
Hey Jorpho, thanks for the reply!

I guess I just don't understand how to transfer the data from my .wav files to the .sez file. (I've never used a hex editor before)

My wav file begins with RIFF, I'm unsure what exactly I'm supposed to copy and if I'm supposed to just paste the text from my wav file into the .sez file. For example, should I copy the first line of my .wav file and replace that with the first line of the sez file?

Jorpho

  • Hero Member
  • *****
  • Posts: 4763
  • The cat screams with the voice of a man.
    • View Profile
Re: Megaman X4 PC Voice Mod help
« Reply #3 on: November 24, 2015, 09:48:39 am »
My wav file begins with RIFF
Yes, every .wav file always begins with RIFF.  The .sez file is just a bunch of .wav files stuck together end-to-end.  At the start of the .sez file (before the first occurrence of RIFF) is a section with the file names and the size of each .wav file.

Quote
I'm unsure what exactly I'm supposed to copy and if I'm supposed to just paste the text from my wav file into the .sez file.
That will only work if your .wav file is exactly the same size as the file in the .sez file.  Otherwise, you will have to update the file sizes at the start of the .sez file.

Quote
For example, should I copy the first line of my .wav file and replace that with the first line of the sez file?
What gave you that idea..?

November 27, 2015, 10:52:57 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
All right, finished!

I tested this with both the .SEZ file you created and the .SEZ file from the other thread.  I have no idea if it will work with other .SEZ files, or even if it will work with the game.

Save this file as a Python script in an empty folder containing nothing but a .SEZ file, and it will produce the .WAV files inside.  Edit them however you wish.  (Remember, they must be uncompressed 8-bit 22050 Hz Mono.)

Code: [Select]
import sys
import os

mycwd = os.path.dirname(os.path.realpath(sys.argv[0])) #get directory of script

for sezname in os.listdir(mycwd):
    if (sezname[-4:] == '.SEZ') and (sezname != 'OUT.SEZ'):
        break

sez = open(os.path.join(mycwd,sezname),'rb')
sezdata = sez.read()
sez.close()

fname = []
i = 8
j = 1

#for n in range(1,13):
while True:
    j = sezdata.find('.WAV',i)
    if j < 0:
        break
    fname.append(sezdata[i:j+4])
    i = i+17

k = 0

for fn in fname:
    f = open(os.path.join(mycwd,fn),'wb')
    m = sezdata.find('RIFF',k)
    p = sezdata.find('RIFF',m+4)
    if p < 0:
        p = len(sezdata)
    f.write(sezdata[m:p])
    f.close()
    k = p

Afterwards, run this script from the same directory and it should produce a new file, OUT.SEZ, with your modifications.

Code: [Select]
import os
import sys

mycwd = os.path.dirname(os.path.realpath(sys.argv[0])) #get directory of script

for sezname in os.listdir(mycwd):
    if (sezname[-4:] == '.SEZ') and (sezname != 'OUT.SEZ'):
        break

sez = open(os.path.join(mycwd,sezname),'rb')
sezdata = sez.read()
sez.close()

fname = []
i = 8

while True:
    j = sezdata.find('.WAV',i)
    if j < 0:
        break
    fname.append(sezdata[i:j+4])
    i = i+17

startoffs = sezdata.find('RIFF')
print startoffs
offs = startoffs
newsezhead = sezdata[0:offs]
newsezwav = ''
sizes = []

for fn in fname:
    f = open(os.path.join(mycwd,fn),'rb')
    wav = f.read()
    f.close()
    offs = offs + len(wav)
    offshex = hex(offs)[2:]
    sizes.append(hex(offs)[2:].zfill(8).decode('hex')[::-1])
    newsezwav = newsezwav + wav
    print fn + ' ' + str(len(newsezwav))

k = 21

for thing in sizes:
    newsezhead = newsezhead[:k] + thing + newsezhead[k+len(thing):]
    k = k + 17
    print k

flen = hex(len(newsezwav) + startoffs)[2:].zfill(8).decode('hex')[::-1]
   
newsezhead = newsezhead[:(startoffs - 17)] + flen + newsezhead[(startoffs - 17 + len(flen)):]

sezout = open(os.path.join(mycwd,'OUT.SEZ'),'wb')
sezout.write(newsezhead + newsezwav)
sezout.close()
« Last Edit: December 01, 2015, 09:25:35 am by Jorpho »
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

Jorpho

  • Hero Member
  • *****
  • Posts: 4763
  • The cat screams with the voice of a man.
    • View Profile
Re: Megaman X4 PC Voice Mod help
« Reply #4 on: December 01, 2015, 11:31:03 pm »
Look!  I MADE A THING
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

SunGodPortal

  • Hero Member
  • *****
  • Posts: 2927
  • 2 + 2 = 5
    • View Profile
Re: Megaman X4 PC Voice Mod help
« Reply #5 on: December 01, 2015, 11:44:58 pm »
Quote
Look!  I MADE A THING

Oh yeah? I don't see anything.
Cigarettes, ice-cream, figurines of the Virgin Mary...

Jorpho

  • Hero Member
  • *****
  • Posts: 4763
  • The cat screams with the voice of a man.
    • View Profile
Re: Megaman X4 PC Voice Mod help
« Reply #6 on: December 02, 2015, 12:26:40 am »
I meant the scripts in my previous post, which was unbumpable until today.

(It's probably reasonable to assume that the .SEZ header has a consistent format of 17-byte fields each containing an offset and a filename, which would have simplified things somewhat – but I felt safer working with other assumptions.)
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

SunGodPortal

  • Hero Member
  • *****
  • Posts: 2927
  • 2 + 2 = 5
    • View Profile
Re: Megaman X4 PC Voice Mod help
« Reply #7 on: December 02, 2015, 12:59:40 am »
Quote
I meant the scripts in my previous post, which was unbumpable until today.

So it was all a trick... :-[
Cigarettes, ice-cream, figurines of the Virgin Mary...