News:

11 March 2016 - Forum Rules

Main Menu

Megaman X4 PC Voice Mod help

Started by Tetsuo, November 23, 2015, 03:25:42 AM

Previous topic - Next topic

Tetsuo

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!

Jorpho

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 devisut by Satan. Go ahead dauntlessly! Make rapid progres!

Tetsuo

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

#3
Quote from: Tetsuo on November 24, 2015, 02:41:19 AMMy 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.

QuoteI'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.

QuoteFor 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.)

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.

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()
This signature is an illusion and is a trap devisut by Satan. Go ahead dauntlessly! Make rapid progres!

Jorpho

This signature is an illusion and is a trap devisut by Satan. Go ahead dauntlessly! Make rapid progres!

SunGodPortal

QuoteLook!  I MADE A THING

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

Jorpho

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 devisut by Satan. Go ahead dauntlessly! Make rapid progres!

SunGodPortal

QuoteI 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...

Blakey!

Quote from: Jorpho on November 24, 2015, 09:48:39 AM
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.
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.
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.)

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.

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()

Hello friend. I know it is 7 years late, but I can't seem to get your python script working. I try to run the first one to extract the WAV files from the .SEZ and I get this error.



If you could help I would be happy. I'm trying to make a mod of this game for my friend's birthday and it is coming up in 2 days. Thank you.  :banghead: :angel:

KingMike

I'm not familiar with Python, but I can't imagine in seven years there hasn't been an update to Python.
Not seeing old code able to work anymore with new compilers is what made me go "I give up".
"My watch says 30 chickens" Google, 2018

Jorpho

Yes, you'll probably want to try it with Python 2 for starters and not Python 3. (Python 3 made some huge changes, but Python 2 is still so widely-used that it only just got its final update.)
This signature is an illusion and is a trap devisut by Satan. Go ahead dauntlessly! Make rapid progres!

Blakey!

Downloading Python 2 was the trick! Thank you so much! :angel: