Music/Sound Hacking

Jun 29, 2006 at 6:29 AM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
So I just stumbled on sounds.

Code
0x0008F940 is where sound is loaded. A CALL is made to a function which loads sounds and a few parameters are pushed on the stack. Each call pushes (in order) the sound ID, the length (multiplied by 0x70; this is usually 1 or 2), and the offset in the executable where to load the sound from.

Data
Tracing the offset back to its source, we find neat little blocks of data 0x70 and 0xE0 bytes in length. I'm not sure what format they're in, but a bit of poking around can turn up some interesting findings. They always start by the same 4-byte header, then the rest, I dunno. Seems like simple PCM sound.

I've managed to give my new weapon a sizzling after-sound. Knock yourselves out. I'm gonna give the function CALLed by 8F940 a look and see what it does. Might give some insight on what's what...
 
Jun 29, 2006 at 9:26 PM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
From what I gather, sounds are 0x70 bytes in length and contain a series of informations related to their lengths, the type of wave (square, sine, sawtooth...) to use, the amplitude, and a bunch of things like that.

I'll attempt to produce a guide, but don't keep your fingers crossed. Byte 0x08 seems to be the most interesting one to mess around with, taking a value between 0 and 5 and probably managing the wave type. Bytes 0x16, 0x17, 0x18, and 0x19 have REALLY interesting effects (pitch, reverb, volume, so forth.) Still not 100% clear on their uses though.
 
Jun 29, 2006 at 9:42 PM
Hoxtilicious
"Life begins and ends with Nu."
Join Date: Dec 30, 2005
Location: Germany
Posts: 3218
Age: 32
WEll, all of them are:
Sine Wave
Square Wave
Saw Wave
Triangle Wave
Absolute Sine Wave

Well willl you post as public? when finished?
 
Jun 29, 2006 at 11:59 PM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
ShInInG PhAnToM said:
WEll, all of them are:
Sine Wave
Square Wave
Saw Wave
Triangle Wave
Absolute Sine Wave
I'm curious where you get this information. Is it just an educated guess, or do you have code to back it up? Just wondering, because I haven't seen anything that pertains to this so far... I'm not interested in offsets or whatnot, just curious where you get your info from. I'd feel rather dumb if this is a common format and not something specific to the game. :)
 
Jun 30, 2006 at 4:47 AM
Hoxtilicious
"Life begins and ends with Nu."
Join Date: Dec 30, 2005
Location: Germany
Posts: 3218
Age: 32
Well, these are just basic sounds...
But i don't think pixel use a Absolute Sine Wave...
 
Jun 30, 2006 at 8:47 AM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
I see.

One of them appears to be a sawtooth wave, though. I'd be surprised if any of this is conventional either way. The function to load them is at 0x000207E0, if you're interested in picking at it to figure out what waveforms are created.
 
Jun 30, 2006 at 11:30 AM
Hoxtilicious
"Life begins and ends with Nu."
Join Date: Dec 30, 2005
Location: Germany
Posts: 3218
Age: 32
Sure Rune!
But i must work on my mod and so i haven'T much time, and iam not good at asembly code, but i want to know how to exe hack, the talent what i have is logical thinking...
 
Jun 30, 2006 at 1:34 PM
Been here way too long...
"..."
Join Date: Jun 25, 2005
Location:
Posts: 372
RuneLancer said:
From what I gather, sounds are 0x70 bytes in length and contain a series of informations related to their lengths, the type of wave (square, sine, sawtooth...) to use, the amplitude, and a bunch of things like that.

I'll attempt to produce a guide, but don't keep your fingers crossed. Byte 0x08 seems to be the most interesting one to mess around with, taking a value between 0 and 5 and probably managing the wave type. Bytes 0x16, 0x17, 0x18, and 0x19 have REALLY interesting effects (pitch, reverb, volume, so forth.) Still not 100% clear on their uses though.

Could those be the different settings for .ORGs? It seems that if Pixel went to all the trouble of making his own midi-esque format he'd be dumb to convert it to straight-up wave/PCM in the final product, when he could save space by simply integrating the .orgs and their samples in the executable.
 
Jul 1, 2006 at 2:42 AM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
Osmose said:
It seems that if Pixel went to all the trouble of making his own midi-esque format he'd be dumb to convert it to straight-up wave/PCM in the final product, when he could save space by simply integrating the .orgs and their samples in the executable.
That's a good guess. I haven't had a look at the ORG files packed in the executable, but there could be similarities.

However these are sounds, so I doubt they would be an identical format. From what I gather, a few of the bytes in that little 0x70 chunk are actual instructions (ie, play a sine wav for 'x' ms at pitch 'y') but there's definately a small header in there.

More research will be necessary in order to figure this out with any certainty. It's a damned good guess though... :eek:
 
Jul 1, 2006 at 3:10 AM
Been here way too long...
"..."
Join Date: Jun 25, 2005
Location:
Posts: 372
Whoops. Sounds, not music. My bad. *blush* Still...

I've been wondering when someone would look at .ORGs. I'd have thought an ORG to MIDI converter would've been out already.
 
Jul 1, 2006 at 3:40 AM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
A midi to org converter is what I'm after - there are a few songs I've love to import into my hack (not being a composer and all that - I wouldn't be able to use Pixel's little editor thingie. :eek:)
 
Jul 1, 2006 at 4:11 AM
Been here way too long...
"..."
Join Date: Jun 25, 2005
Location:
Posts: 372
You could just do it by hand, it's not that hard. :eek:

Check the website, I wrote a guide explaining what everything does and how it works. That'd probably be faster, although less helpful to those like me who want to midify orgs. :p
 
Jul 4, 2006 at 8:23 PM
Been here way too long...
"..."
Join Date: Jun 25, 2005
Location:
Posts: 372
Bump - You said you have a few Midi's you want to make into ORGs? Link me to some of them and I'll see what I can do.
 
Jul 4, 2006 at 8:47 PM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
That's a very generous offer of you, and I'm greatful, but I'm moving back to my appartment tonight and I won't have internet access for a few weeks so I wouldn't be able to deal with anything for a little while.

I'll see what's what once I get my internet access back though. :p
 
Jul 4, 2006 at 10:24 PM
Been here way too long...
"..."
Join Date: Jun 25, 2005
Location:
Posts: 372
That's exactly why you should just post a few for me to do - no deals or anything, I'm just bored. :p
 
Jul 4, 2006 at 11:31 PM
Junior Member
"Fresh from the Bakery"
Join Date: Jul 4, 2006
Location:
Posts: 19
Cave Story SFX

Included are all of the sounds from Cave Story, in their native format, as well as the program used to create/edit them. You can open the .pxt files with Notepad to see their inner workings.

I found this at PisColla, a Japanese BBS site that Pixel frequents.

Also, on a somewhat related note, one of Pixel's associates has made an updated version of OrgMaker. It's in Japanese, but if you're familiar with the original, it shouldn't be too hard to figure out.

Edit: Fixed a broken link.
 
Jul 4, 2006 at 11:39 PM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
Some of these seem to be the instruments used by Cave Story. Very nice find, nevertheless.

Regardless, the small chunk of data at the end seems to match up with what I found (size-wise, at least) so this could help figure out what's what in sounds. I'll post my findings if I find anything interesting about what's in the exe before I move back to my appartment. :p

Edit: Didn't take too long. The files contain a chunk of data at the end (around a dozen values between brackets, for about 4 lines.) This is the actual file. You take this stuff, convert it value by value into hex, and insert it into the exe (see my first post for the offsets.) Each value is a fully-fledged 32 bit value, so {1, 10000} will be 01 00 00 00 10 27 00 00.

Edit 2: Not quite... gonna update in a sec...
 
Jul 4, 2006 at 11:43 PM
Been here way too long...
"..."
Join Date: Jun 25, 2005
Location:
Posts: 372
That is a SEXY looking Org Maker. Downloading....

What about those midis you wanted, Rune? :p
 
Jul 5, 2006 at 12:07 AM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
Seems I'll be here a little longer than expected. Legal crap. I could get into it, but it's not a very cave story related thing, so I won't. ;)

Frankly I haven't actually decided on any midis in particular for this, I figured they'd be a bit of a spur of the moment thing. But I can upload a few good ones somewhere and I'll use those. You will, of course, get full credit for converting them (and Snarwin as well for his little discovery - it allowed me to figure out how those things were stored after a wee bit of experimenting.)

By the by, I can come up with an exact mapping of each value in the exe's sounds if anyone needs it. But I think the easiest way to edit sounds is to use the program Snarwin found and to copy the values it saves to the offsets I found in my first post. A little tedious, but it beats tweaking repeatedly. :p
 
Jul 5, 2006 at 12:44 AM
Been here way too long...
"..."
Join Date: Jun 25, 2005
Location:
Posts: 372
Well, I'll say one thing - there's A LOT more options in this version. Wonder if I'll be able to write a guide for this one... It'll definately be a little more required for this one.
 
Top