Author Topic: Music Extraction/packaging  (Read 2871 times)

Offline thojoh370

  • Newbie
  • *
  • Posts: 5
Music Extraction/packaging
« on: July 26, 2007, 05:13:23 AM »
I want to unpack the op2.clm file, change the soundtracks, and then re-package them into the clm file again. Is it possible?

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Music Extraction/packaging
« Reply #1 on: July 26, 2007, 01:12:46 PM »
Yes.

I think the editor should be able to do it. Even the old revolver could do it (I think), although I think you needed to work with wave files without headers on them. With the editor (or at least the code in it) I'm pretty sure you can use just regular wave files, as long as they are the correct sound format. I don't remember what that format is, but if you extract the files from the clm first into wave, you can check what format they are, and then just use those settings.

If the editor can't do it, then the code from OP2Editor.dll can be called from any language that supports COM, such as VB, or just from something like C++. It takes a page of code to do what you want. I can probably help if it comes to that.

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Music Extraction/packaging
« Reply #2 on: July 26, 2007, 11:12:14 PM »
I think Arklon told me he already did this... Maybe not, but ask him just in case.
Either he did or he was going to because he's tired of the Outpost 2 music.
Blasphemy!
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Arklon

  • Administrator
  • Hero Member
  • *****
  • Posts: 1269
Music Extraction/packaging
« Reply #3 on: July 27, 2007, 12:02:38 AM »
I used GoldWave to convert the music I wanted into the format OP2 needs them in, and then I used ReVOLver to pack them into the CLM file. ReVOLver's apparently a flawed program, I'm wondering if that's the reason for the music acting slightly odd when a new track is played (it'll play around half a second of one song then play the one it's supposed to).
« Last Edit: July 27, 2007, 12:04:53 AM by Arklon »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Music Extraction/packaging
« Reply #4 on: July 29, 2007, 04:26:03 PM »
Quote
it'll play around half a second of one song then play the one it's supposed to

Make sure the length of the song (the actual wav data) is a multiple of 32768 bytes (0x8000). Output 2 fills the music buffer in chunks that large, and doesn't zero fill if a chunk (at the end of a file) is too short. So you'll get a bit of garbage data played before it switches to the next track. Just zero pad your file to bring it up to the right size.

All the music that comes with Outpost 2 in the CLM file is a multiple of 32768 bytes.



Edit: Actually, all the music is in the CLM file is a multiple of 65536 bytes. (Double the previous value I gave). This is the size of the music buffer. But you can't overwrite the data that's currently playing without causing glitches, so it only fills half the buffer at a time. Hence the previously suggested alignment value of 32768 is sufficient to prevent glitches during track changes.

Also, Outpost 2 will try to initialize the primary sound buffer in the following order:
 1) Frequency = 22050 Hz, Channels = 2 (Stereo), BitsPerSample = 16
 2) Frequency = 22050 Hz, Channels = 2 (Stereo), BitsPerSample = 8
 3) Frequency = 22050 Hz, Channels = 1 (Mono), BitsPerSample = 8
If it fails, it tries the next one in the list.

The format of the CLM data must however be:
 A) Frequency = 22050 Hz, Channels = 1 (Mono), BitsPerSample = 16

The CLM file must also contain the following internal files:
 0) "EDEN11"
 1) "EDEN21"
 2) "EDEN22"
 3) "EDEN31"
 4) "EDEN32"
 5) "EDEN33"
 6) "EP41"
 7) "EP42"
 8 ) "EP43"
 9) "EP51"
 10) "EP52"
 11) "EP61"
 12) "EP62"
 13) "EP63"
 14) "PLYMTH11"
 15) "PLYMTH12"
 16) "PLYMTH21"
 17) "PLYMTH22"
 18) "PLYMTH31"
 19) "PLYMTH32"
 20) "PLYMTH33"
 21) "STATIC01"
 22) "STATIC02"
 23) "STATIC03"
 24) "STATIC04"
 25) "STATIC05"

Extra files can probably be added just fine, but they might not be accessible. If any of the above files are missing, the CLM load is aborted.
« Last Edit: August 22, 2017, 02:04:11 AM by Hooman »

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Music Extraction/packaging
« Reply #5 on: July 29, 2007, 08:17:52 PM »
Interesting...
I'd use this information to make a new .CLM, but I like the normal music.
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials