Music/Sound Hacking

Jul 5, 2006 at 2:11 AM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
I found out something. Turns out each *channel* is 0x70 bytes in length, not each sound. This means it's impossible to add channels to a sound without altering the pointers I mentionned in my first post. A bit of a bummer, but most sounds use 2 channels anyhow.

So! At the bottom of the pxt file, there are 4 rows of values between curly brackets. This is the data for each of the 4 channels. Each value in a channel is converted in-game to a 4-byte value (except for floating point numerals; those 0.50 or 2.00 things.) Floating point numerals, I'm not quite sure yet. 5.00 is 00 00 00 00 00 00 00 00 00 00 14 40, for instance. Exactly how it gets to that, I dunno.

Also, the final 32 bit value is padded with 0.

I tried that, and now it works fine. ;)

(for those of you looking for a pointer table, I'll have one in a few moments...)

Edit
ID 0x01 [1 channel(s)]: 0x00907b0
ID 0x02 [1 channel(s)]: 0x00909e0
ID 0x03 [1 channel(s)]: 0x00934c0
ID 0x04 [1 channel(s)]: 0x0090890
ID 0x05 [1 channel(s)]: 0x0090660
ID 0x06 [1 channel(s)]: 0x0093530
ID 0x07 [1 channel(s)]: 0x00935a0
ID 0x0b [1 channel(s)]: 0x0090740
ID 0x0c [2 channel(s)]: 0x0090c80
ID 0x0e [1 channel(s)]: 0x0090a50
ID 0x0f [1 channel(s)]: 0x008fbe0
ID 0x10 [2 channel(s)]: 0x0090350
ID 0x11 [3 channel(s)]: 0x0090430
ID 0x12 [1 channel(s)]: 0x0090820
ID 0x14 [2 channel(s)]: 0x0090900
ID 0x15 [1 channel(s)]: 0x0090c10
ID 0x16 [1 channel(s)]: 0x00906d0
ID 0x17 [1 channel(s)]: 0x008fcc0
ID 0x18 [1 channel(s)]: 0x008fc50
ID 0x19 [2 channel(s)]: 0x0090d60
ID 0x1a [2 channel(s)]: 0x0090b30
ID 0x1b [1 channel(s)]: 0x0090e40
ID 0x1c [2 channel(s)]: 0x00910e0
ID 0x1d [1 channel(s)]: 0x00911c0
ID 0x1e [1 channel(s)]: 0x0091ee0
ID 0x1f [1 channel(s)]: 0x0091310
ID 0x20 [2 channel(s)]: 0x008f940
ID 0x21 [2 channel(s)]: 0x008fa20
ID 0x22 [2 channel(s)]: 0x008fb00
ID 0x23 [3 channel(s)]: 0x0090eb0
ID 0x25 [2 channel(s)]: 0x0092810
ID 0x26 [2 channel(s)]: 0x0091230
ID 0x27 [3 channel(s)]: 0x0091000
ID 0x28 [2 channel(s)]: 0x0092730
ID 0x29 [2 channel(s)]: 0x0092730
ID 0x2a [1 channel(s)]: 0x0091380
ID 0x2b [1 channel(s)]: 0x00913f0
ID 0x2c [3 channel(s)]: 0x0091460
ID 0x2d [1 channel(s)]: 0x00915b0
ID 0x2e [1 channel(s)]: 0x0091620
ID 0x2f [1 channel(s)]: 0x0091700
ID 0x30 [1 channel(s)]: 0x0091770
ID 0x31 [2 channel(s)]: 0x00917e0
ID 0x32 [2 channel(s)]: 0x008fd30
ID 0x33 [2 channel(s)]: 0x008fe10
ID 0x34 [2 channel(s)]: 0x008fef0
ID 0x35 [2 channel(s)]: 0x0090580
ID 0x36 [2 channel(s)]: 0x0091a80
ID 0x37 [2 channel(s)]: 0x0092ea0
ID 0x38 [2 channel(s)]: 0x0092650
ID 0x39 [2 channel(s)]: 0x00928f0
ID 0x3a [2 channel(s)]: 0x0092dc0
ID 0x3b [1 channel(s)]: 0x0093060
ID 0x3c [1 channel(s)]: 0x00930d0
ID 0x3d [1 channel(s)]: 0x0093140
ID 0x3e [2 channel(s)]: 0x00931b0
ID 0x3f [2 channel(s)]: 0x0093290
ID 0x40 [2 channel(s)]: 0x0093370
ID 0x41 [1 channel(s)]: 0x0093450
ID 0x46 [2 channel(s)]: 0x008ffd0
ID 0x47 [2 channel(s)]: 0x00900b0
ID 0x48 [2 channel(s)]: 0x0090190
ID 0x64 [1 channel(s)]: 0x00918c0
ID 0x65 [3 channel(s)]: 0x0091930
ID 0x66 [2 channel(s)]: 0x0091b60
ID 0x67 [2 channel(s)]: 0x0091c40
ID 0x68 [1 channel(s)]: 0x0091cb0
ID 0x68 [1 channel(s)]: 0x0092c00
ID 0x69 [1 channel(s)]: 0x0091d20
ID 0x6a [2 channel(s)]: 0x0091d90
ID 0x6b [1 channel(s)]: 0x0091e70
ID 0x6c [1 channel(s)]: 0x0091f50
ID 0x6d [1 channel(s)]: 0x0091fc0
ID 0x6e [1 channel(s)]: 0x0092030
ID 0x6f [1 channel(s)]: 0x00920a0
ID 0x70 [1 channel(s)]: 0x0092110
ID 0x71 [1 channel(s)]: 0x0092180
ID 0x72 [2 channel(s)]: 0x00921f0
ID 0x73 [3 channel(s)]: 0x0092ab0
ID 0x74 [3 channel(s)]: 0x0092c70
ID 0x75 [2 channel(s)]: 0x0092f80
ID 0x96 [2 channel(s)]: 0x00922d0
ID 0x97 [2 channel(s)]: 0x00923b0
ID 0x98 [1 channel(s)]: 0x0092490
ID 0x99 [1 channel(s)]: 0x0092500
ID 0x9a [2 channel(s)]: 0x0092570
ID 0x9b [2 channel(s)]: 0x00929d0

These are also all of the existing sounds in the game - other sounds may either crash or do nothing. The current listing of sounds in... tsc.txt I think? is incomplete and doesn't include instruments (the last numbers.) These are in hex and not in decimal, so please adjust accordingly.
 
Jul 5, 2006 at 5:59 PM
Hoxtilicious
"Life begins and ends with Nu."
Join Date: Dec 30, 2005
Location: Germany
Posts: 3218
Age: 32
Well, but Cave Story is incompatible with some points of the new Version
 
Jul 5, 2006 at 6:41 PM
Been here way too long...
"..."
Join Date: Jun 25, 2005
Location:
Posts: 372
The only thing I've been able to see that would make OrgMaker 2.0.5 incompatible is the new drums. Unless it saves them differently...

I've more or less got a handle on the program. There's two options, however, which I have yet to figure out - one that's in the File menu that does the exact same thing as the normal open command, but is labeled (P). The other is in the "Effects" menu that is a checkable option. It's right above Copy and Group Copy.

Anyone know of any program that would let me go into OrgMaker and change the captions? Changing everything to English and including a help file would probably be the best thing for me to do with this, rather than writing a guide.
 
Jul 5, 2006 at 6:43 PM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
Osmose said:
The only thing I've been able to see that would make OrgMaker 2.0.5 incompatible is the new drums. Unless it saves them differently...
I've noticed that some of the later sounds are drums. I haven't experimented with changing them, but it seems the game may store them directly as sounds.

Dunno if that's any informative.
 
Jul 5, 2006 at 6:46 PM
Been here way too long...
"..."
Join Date: Jun 25, 2005
Location:
Posts: 372
It doesn't really apply to me, although I'm curious as to whether the game plays music seperately as sounds or in the same way.
 
Jul 5, 2006 at 6:53 PM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
Osmose said:
I'm curious as to whether the game plays music seperately as sounds or in the same way.
I haven't noticed any additional instruments while poking about.

If you meant the technical aspect, the game uses DirectSound to play its music and sounds. This means everything is given a channel on the sound card and gets uploaded or streamed into it as uncompressed WAV data. (Ie, there's no distinction between music and sound effects.)
 
Jul 6, 2006 at 12:51 AM
Been here way too long...
"..."
Join Date: Jun 25, 2005
Location:
Posts: 372
Bah to you! I am not so dumb as to need an explanation of DirectSound! I am insulted! ;)

No, as in are sounds and music handled by the program in the same way or differently. I'd assume differently, but the mention of drums as sounds intrigued me. You'll probably figure out when you find music.
 
Jul 6, 2006 at 1:33 AM
Junior Member
"Fresh from the Bakery"
Join Date: Jul 4, 2006
Location:
Posts: 19
Orgs saved by Org 2.0.5 are backwards compatible, as long as you don't use any drum instruments that go past the end of Org 1.3's list (Bass04 and onward).

Also, if you choose the first option of the last menu, it'll show a dialog with selectable text. You can read it by copying it into a text file, opening it using Shift_JIS encoding (I think), and running it through a translator. From what I can remember, it's a sort of "readme" for the program, and includes, among other things, a list of keyboard shortcuts.

Also, I was able to track down the post, and credit goes to Quois for the .zip of SFX files.
 
Jul 6, 2006 at 1:53 AM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
Osmose said:
No, as in are sounds and music handled by the program in the same way or differently. I'd assume differently, but the mention of drums as sounds intrigued me. You'll probably figure out when you find music.
I know where music is stored - it's definately a different thing than sounds are. But what it seems to do (I'm a little iffy on that code since I only briefly skimmed through it) is play "instruments" as sounds from a pre-generated alterable (seems to be..) bank of sounds.

From what I understand so far, it loads a series of "sounds" in a bank, the song itself, and fiddles around with the sound bank as needed.

I'll give it a more in-depth look when I get a chance. Right now I'm very iffy on the details because I never bothered too much with the music. ;)
 
Jul 6, 2006 at 2:44 AM
Been here way too long...
"..."
Join Date: Jun 25, 2005
Location:
Posts: 372
Snarwin said:
Orgs saved by Org 2.0.5 are backwards compatible, as long as you don't use any drum instruments that go past the end of Org 1.3's list (Bass04 and onward).

Also, if you choose the first option of the last menu, it'll show a dialog with selectable text. You can read it by copying it into a text file, opening it using Shift_JIS encoding (I think), and running it through a translator. From what I can remember, it's a sort of "readme" for the program, and includes, among other things, a list of keyboard shortcuts.

Also, I was able to track down the post, and credit goes to Quois for the .zip of SFX files.

I've got a friend (my grandfather, actually) who can speak and read pretty good japanese (he was principle of a japanese school in California) and he's agreed to see what he can translate of the program - I'm hoping this will let me figure out a lot of the new options in the new OrgMaker - there's a whole menu full of commands that do, as far as I can tell, absolutely nothing. Once he does that I'm going to either:

1.Translate the program itself and include a help file for English speakers.
2.Write another guide like the one I did for 1.3.4 and submit it to the website.

Either way I'm dead set on figuring this out and sharing with others. ;)
 
Aug 7, 2006 at 8:08 PM
Neophyte Member
"Fresh from the Bakery"
Join Date: Jul 19, 2006
Location: Victoria, B.C., Canada
Posts: 8
Age: 34
RuneLancer said:
I know where music is stored - it's definately a different thing than sounds are. But what it seems to do (I'm a little iffy on that code since I only briefly skimmed through it) is play "instruments" as sounds from a pre-generated alterable (seems to be..) bank of sounds.

From what I understand so far, it loads a series of "sounds" in a bank, the song itself, and fiddles around with the sound bank as needed.

I'll give it a more in-depth look when I get a chance. Right now I'm very iffy on the details because I never bothered too much with the music. ;)

Sorry to dig up a month old topic, but I would really like to know where those instruments are stored and possibly the code which manipulates the sound bank.
 
Aug 7, 2006 at 8:23 PM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
I never really gave this much of a look, nor do I have any intentions of doing so in the near future. Music hacking isn't really much of a part of my plans at the moment and I have too little information on it to find anything relevant without rolling up my sleeves and getting serious with the music-related code.

I'll give the executable a quick look to see if I can find anything tonight, regardless, and I'll post my findings if it turns up anything tomorrow.
 
Aug 8, 2006 at 1:06 AM
Been here way too long...
"..."
Join Date: Jun 25, 2005
Location:
Posts: 372
I'd expect sounds to probably be stored in the same format that Pxtone stores them in - from observation I'm coming to the guess that OrgMaker's samples were made with it and the editor was streamlined for CS.
 
Aug 11, 2006 at 6:06 PM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
Pxtone's format is the standard sound format Cave Story uses. It's what I use to create my sounds - converting the values to hex is necessary of course but that's essentially all there is to it. The last 1-4 pairs of brackets each contain one of the 4 channels the sound can use.

As far as I can tell, instruments use this format. I haven't gotten around to finding where they're stored yet but I did find some music-related junk so it's probably just around the corner.

One thing that worries me is that the sound-loader is only called from one function, and that function doesn't seem to load instruments as part of its sounds. Hrm.
 
Aug 22, 2006 at 6:02 AM
Senior Member
"Fly, Fly, Fly!"
Join Date: May 19, 2006
Location: Irvine, CA.
Posts: 142
Age: 34
So if I went into the .exe, and replaced all instances of 0x0008F940 with 0x00000000 Cave Story would have no sound?
Hmm.. I can't find the 0x0008F940 with my hex editor?
Is it in the main exe?
 
Aug 22, 2006 at 5:43 PM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
That's because it's an offset in program space, not in the file. What you really want is 0x0048F940. Only it'll be stored as 40 F9 48 00.

You can NOT replace something by 0 and expect it to vanish. It doesn't work that way, and it's a mindset a lot of people have that should be dropped as soon as possible. Changing a pointer to 00000000 just means it now points to 00000000, not that it vanishes entirely. I'm sure you can imagine the problems this would cause. :D

If you want to remove sounds, it would be much safer (and efficient) to force the DirectSound instance to fail on creation by replacing the call to it with a simple xor eax,eax. Or muting the sound, really...
 
Aug 22, 2006 at 7:01 PM
Senior Member
"Fly, Fly, Fly!"
Join Date: May 19, 2006
Location: Irvine, CA.
Posts: 142
Age: 34
So how do I force the direct sound to fail on creation?
What do I have to change in the exe?
I can't just mute the speakers, because sometimes I want to listen to other things at the same time.
Also, what program are you using to edit the exe? It doesn't appear to be a normal hex editor.
Thanks for the information.
 
Aug 23, 2006 at 12:41 AM
The Bartender
"All your forum are belong to us!"
Join Date: Jun 18, 2006
Location: Montreal, Canada
Posts: 581
Age: 39
It works with any hex editor.

What you have to do to force Direct Sound is to simply NOP out all PUSH instructions before the call to the creation of Direct Sound (since they won't be needed) and the changes to the ebp register after the call. The call you can just replace with xor eax,eax and NOP out the rest.

Unfortunately I don't have access to internet at home so I can't provide the offset the function starts at.

The other option is just to activate the debug mode and, in the sound options, deactivate all 8 channels. That shouldn't be too hard to pull off, but it will require you to uncheck all eight boxes everytime. The activation of the debug mode is described in another thread in the hacking section. It's a relatively simple process.
 
Aug 23, 2006 at 2:19 AM
Senior Member
"Fly, Fly, Fly!"
Join Date: May 19, 2006
Location: Irvine, CA.
Posts: 142
Age: 34
Bah! My hex editor only displays sets of 2 numbers and or letters.
Kinda like this, but on and on.
Code:
8b 48 78 83|c1 01 8b 95|
I was able to use it to edit my weapons and health, but apparently this is over my head, thanks for trying to help though. :D
 
Aug 23, 2006 at 5:39 AM
Neophyte Member
"Fresh from the Bakery"
Join Date: Jul 19, 2006
Location: Victoria, B.C., Canada
Posts: 8
Age: 34
Daniel G said:
Bah! My hex editor only displays sets of 2 numbers and or letters.
Kinda like this, but on and on.
Code:
8b 48 78 83|c1 01 8b 95|
I was able to use it to edit my weapons and health, but apparently this is over my head, thanks for trying to help though. :D

If you really can't get it working via ASM (AKA the good way). You could zero out all the sounds (see earlier in this thread for the addresses). And then replace all of the ORG's (using reshack) with an empty ORG file.

EDIT:
I have made such a file here (made with a hex editor and untested but should be right): GONE NOW SORRY
 
Top