Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Blastfrog

Would it be possible to convert the PSX Doom music to module format?

Recommended Posts

If I understand correctly, PSX Doom's music is basically just a bunch of modules, because they use samples being played back at different rates in a sequence. Is enough known about the format that it could be converted into something like an XM? I'd really like to take a look at the music in a module editor.

Share this post


Link to post

I'm not sure. If it's anything like how Doom 64's music is stored, we still don't really have a full enough understanding of how the format works to be able to convert it into anything else.

Share this post


Link to post

Well, chances are, it's not the same music format as Doom 64's is. If I remember correctly, Doom 64's music format was a format made by Nintendo for the N64 specifically, so it wouldn't be in any PSX games.

Share this post


Link to post

Doom 64 has a format similar to MIDI. PSX on the other hand is about the same as a .MOD. The format for the PSX music stuff is more known and documented and with enough patience, the format can be converted.

Problem is who here understands the format well and who will even bother to do it for us?

Share this post


Link to post

I poked around the DOOM+DOOM2 cd a bit. The following folders\files seem relevant:

CDAUDIO\
seven .RAW files. pretty big, presumably the seven cd audio tracks

MUSIC\
DOOMSND.WMD
DOOMSFX.LCD
MUSLEV1.LCD - MUSLEV20.LCD

SNDMAPS1\
MAP01.LCD - MAP20.LCD

SNDMAPS2\
MAP21.LCD - MAP40.LCD

SNDMAPS3\
MAP41.LCD - MAP60.LCD



LCD files are generally about 64k to 250k. They have a simple header:

u16le numentries;
u16le id[numentries];

followed by a bunch of padding zeroes and then the actual sfx data. I don't know the format of the sfx data; the only thing that popped out in the hex editor is that it's in groups of 16 bytes, of which the first two have very predictable values, which makes me immediately think "packets" of (compressed?) audio data being sent to a hardware decoding engine, so the next step would be to know something about the PSX's audio decoding facilities.

FWIW, DOOMSFX.LCD has 33 (dec) entries. i did a partial survey of the other files; the MUSLEV* files have 1-3 entries or so, and the MAP* entires have about 30 or so entries.

The entry ids are all small numbers, less than 128 in all cases I think, but they're not contiguous or ordered, which suggests general MIDI patch numbers or sfx IDs or similar.

DOOMSND.WMD is a highly structured file; might even be a WAD file. It starts with a list of entries, then possibly offsets, then highly structured data, which on first glance appears to be some sort of sequencer format. I doubt it would be at all tough to crack.


Anyone have a link to any good programmer's information about the PSX sound hardware?

Share this post


Link to post
natt said:

I poked around the DOOM+DOOM2 cd a bit. The following folders\files seem relevant:

CDAUDIO\
seven .RAW files. pretty big, presumably the seven cd audio tracks

MUSIC\
DOOMSND.WMD
DOOMSFX.LCD
MUSLEV1.LCD - MUSLEV20.LCD

SNDMAPS1\
MAP01.LCD - MAP20.LCD

SNDMAPS2\
MAP21.LCD - MAP40.LCD

SNDMAPS3\
MAP41.LCD - MAP60.LCD



LCD files are generally about 64k to 250k. They have a simple header:

u16le numentries;
u16le id[numentries];

followed by a bunch of padding zeroes and then the actual sfx data. I don't know the format of the sfx data; the only thing that popped out in the hex editor is that it's in groups of 16 bytes, of which the first two have very predictable values, which makes me immediately think "packets" of (compressed?) audio data being sent to a hardware decoding engine, so the next step would be to know something about the PSX's audio decoding facilities.

FWIW, DOOMSFX.LCD has 33 (dec) entries. i did a partial survey of the other files; the MUSLEV* files have 1-3 entries or so, and the MAP* entires have about 30 or so entries.

The entry ids are all small numbers, less than 128 in all cases I think, but they're not contiguous or ordered, which suggests general MIDI patch numbers or sfx IDs or similar.

DOOMSND.WMD is a highly structured file; might even be a WAD file. It starts with a list of entries, then possibly offsets, then highly structured data, which on first glance appears to be some sort of sequencer format. I doubt it would be at all tough to crack.


Anyone have a link to any good programmer's information about the PSX sound hardware?


The MUSLEV##.LCD files contains the instruments that makes up the ambiance while DOOMSFX.LCD contains all of the sounds. The Map-specific .LCD files contains sounds that are used in that level. More likely that was to speed up caching of the sounds.

Share this post


Link to post
Kaiser said:

The Map-specific .LCD files contains sounds that are used in that level. More likely that was to speed up caching of the sounds.


I've seen that sort of thing in other PSX games; data on disk is arranged into "loading units" which contain all of the data that is to be loaded in for that "unit" (here, a level).

This causes in some cases gross duplication of data, but the PSX had lots of cd space to spare; the load times were the premium.


But then why do the files in MUSIC/ exist on the final release CD? Except for DOOMSND.WMD, they seem completely redundant.


I found a good source for the format of the audio data.

http://code.google.com/p/psxjin/source/browse/trunk/psxjin/spu/spu.cpp

see function SPU_chan::decodeBRR

I was right; the data in the files is raw data for the sound engine (probably copied directly to spu memory by dumb DMA). It's a simple dpcm format; I can make a basic decoder no problem.



I get this nagging feeling though that someone somewhere must have done all this before. But where? This is the sort of thing that the "rom hackers scene" does, but it's hard to ever extract any useful information from those idiots. Google search reveals several "psx format converter" type utilities, all with no source code and no format documentation.

Share this post


Link to post

LCD

http://pastebin.com/wn6PFSDG


each entry number, followed by raw length of entry data in bytes, then kilobytes, followed by a list of every file which contains that entry.

notes:

80h-83h are arbitrary IDs that I assigned; MUSLEV2 and MUSLEV10 each contain 2 more sfx than their header indicates. dunno what's going on there.

in every single case, the actual sfx data matches up to the byte from file to file, so when you see multiple files listed for a single sfx, they don't just match in ID, they're the same audio data. Clearly, the data was compiled as one single repository which was then split up into individual loading units.

it will be easier to understand the data organization once I write a bit of code so you can hear the audio samples.

Share this post


Link to post

I am impressed. But anyways MUSLEV2 contains about three 'instruments' which makes up the ambiance. Each MUSLEV## has at least 3 or 2 sound data embedded. There is a utility called 'PSound' which will identify and extract all sounds from the .LCD files. Unfortunately the source code for that doesn't exist.

Share this post


Link to post
Kaiser said:

I am impressed. But anyways MUSLEV2 contains about three 'instruments' which makes up the ambiance. Each MUSLEV## has at least 3 or 2 sound data embedded. There is a utility called 'PSound' which will identify and extract all sounds from the .LCD files. Unfortunately the source code for that doesn't exist.


Yeah, when the utility has no source code and no documentation of the underlying file format it's converting, it can be pretty useless. I wonder why people write such things.

As far as MUSLEV2 goes, the header indicates 3 sounds, but there's definitely 5 in the file; I just listened to them.

They could be left over cruft; I'll know more when I look at the sequencer format.

Share this post


Link to post

(warning: 500kB pastebin)

http://pastebin.com/7kfQSwJ9

This isn't any fun. It's not even music, just some ambient crap.

I'm not sure why; I'm absolutely certain the PSX could have done a reasonable rendition of the original doom soundtrack; it would sound "different", but no more different than the difference between say, a gus and an adlib.


All I need to do now is bs the pitch values, guess the meaning of a few stray midi events, and then learn the specs of some tracker format to dump it all to. Anyone have a favorite tracker format?

Share this post


Link to post

Most people would prefer modtrack I think. Its a widely supported format and can also allow users to see how the ambiance is constructed when they open it in a modtrack editor.

By the way, do you plan on releasing any docs regarding to your findings? I am interested to know how this works.

Share this post


Link to post
Kaiser said:

Most people would prefer modtrack I think. Its a widely supported format and can also allow users to see how the ambiance is constructed when they open it in a modtrack editor.

By the way, do you plan on releasing any docs regarding to your findings? I am interested to know how this works.


I am absolutely going to release the source code of my conversion utility (modified BSD license), and the notes I've written during the conversion process. No guarantees that any of it will be easy to read though.

Share this post


Link to post
natt said:

Anyone have a favorite tracker format?

XM, because it's simple, but has more channels than a regular MOD file. Speaking of which, how many channels did the PSX music have at maximum?

I kinda like the ambient music, granted, it can be boring sometimes, but it can really add a ton of atmosphere to a map, even more than actual music.

Share this post


Link to post
Sodaholic said:

XM, because it's simple, but has more channels than a regular MOD file. Speaking of which, how many channels did the PSX music have at maximum?

I kinda like the ambient music, granted, it can be boring sometimes, but it can really add a ton of atmosphere to a map, even more than actual music.


The PSX has 24 hardware sound channels. In Doom, they're shared between the "music" and the SFX. The most being used at once by the music is 10, but most of the songs use 6 or less. The sound engine does some smart channel allocation though, so if you got over 24 at any point it wouldn't necessarily be the end of the world.

I took a quick look through the MOD and XM formats, and honestly neither seems well suited to the task. What I really want is a format with a non-pattern-based mode. Because the input format is pseudo-midi, which has an extremely flexible pattern-free timesystem, the end result from conversion would simply be patterns which are each used once in order.

Share this post


Link to post

I had a feeling that PSX/N64 versions of Doom didn't use patterns in their MIDI. It clearly shows after I tried to recreate the music in Doom64 by using the modtrack format.

Share this post


Link to post
Sodaholic said:

Huh, crap. Maybe midi with soundfonts for each song?


soundfonts are a pain in the ass, although that honestly sounds like the best way to accurately replicate what's on the CD. I think a conversion to Impulse Tracker would be workable, but the result would be something so ugly you'd never want to actually edit it, and so I wonder what the point of the entire exercise would be. soundfont+midi can easily be played by timidity, fluidsynth, and many other synths, and can be edited easily by any of a bazillion score editing programs.

Kaiser said:

I had a feeling that PSX/N64 versions of Doom didn't use patterns in their MIDI. It clearly shows after I tried to recreate the music in Doom64 by using the modtrack format.


If you want to waste your time reading a long, horrible, unintelligible document, give http://www.assemblergames.com/forums/archive/index.php/t-10146.html a look. It's a rip of the official manual for one of the PSX SDK sound creation utilities. In short, what it can do as far as music goes is take input MIDI file, sound samples, and parameters (attack/release time, etc) and make a "PSX song" out of it, which is the samples in a DPCM format that the sound chip can read natively (along with parameters) and the song in an "imitation MIDI" format.

Share this post


Link to post

Huh, considering how close it is to midi, what if somebody tried to put the PC version music in PSX Doom?

Share this post


Link to post
Sodaholic said:

Huh, considering how close it is to midi, what if somebody tried to put the PC version music in PSX Doom?


You'd have to rework the sample handling code a bit I think, because you'd run out of id numbers with the setup as it is now (since there'd be more than two or three "instruments" per map). You also might run into other "artificial limits" depending on how the particulars of PSXDOOM's sound code play out. But make no mistake, the PSX is certainly completely capable of rendering moderate quality renditions of general MIDI music; I think there are a decent number of commercial titles out there that attest to that.

Share this post


Link to post

I actually wouldn't mind it being split into patterns that much. Yeah, it would look like crap, but it would give me enough information for what I want to do.

Perhaps you could try it as a test before moving onto the soundfont version?

EDIT: Yeah, nevermind. It would be best to start with midi.

Share this post


Link to post
natt said:

I'm not sure why; I'm absolutely certain the PSX could have done a reasonable rendition of the original doom soundtrack

I heard somewhere (someone from these forums, but I can't remember who) that for some reason they couldn't use any of Bobby Prince's stuff, so they had to replace the sound effects and music. They probably decided to do ambient sounds from there in a design decision (probably to fit better with the modded darker, more atmospheric levels)

Does anyone that knows more about this have a source of this info?

Share this post


Link to post
Sodaholic said:

I actually wouldn't mind it being split into patterns that much. Yeah, it would look like crap, but it would give me enough information for what I want to do.

Perhaps you could try it as a test before moving onto the soundfont version?

EDIT: Yeah, nevermind. It would be best to start with midi.


I've decided to drop the mod conversion idea entirely.

Not because I think it's bad, but because such a creation would have 80% of the complexity of a full-fledged midi->mod converter and 2% of the utility.

I'd rather write a full-fledged midi->mod converter (which takes arbitrary midi files as input) than write something specifically for this task.

====

I installed myself a soundfont editor (Vienna), imported the wav samples in, and manually typed in the loop points. Quicker than making a program that writes the behemoth that is the sf2 format.

There's still some stuff missing; a few unknown midi events, and envelope parameters (attack/decay/sustain/release) aren't set up yet (I can't find them in the WMD =/), and probably bugs ahoy, but some of it sounds ok. I've been listening to a few of em on my emu 10k1.


http://www.mediafire.com/?pyd5a4xw0avur1x


If you have no hardware soundfont-based midi capability, something like fluidsynth can play them.

Share this post


Link to post
Sodaholic said:

Awesome work, I like what you're doing. :D


So did you listen to any of them? Do they sound alright?

Share this post


Link to post
natt said:

So did you listen to any of them? Do they sound alright?

They are clearly incomplete (notes cut off instead of fade out like the PSX), but it's a very good start, and it's impressive that you even got that far. I also feel that I should let you know that sample 86 is missing from the soundfont. (I couldn't listen to 01.mid properly because it used that sample)

Share this post


Link to post
Sodaholic said:

They are clearly incomplete (notes cut off instead of fade out like the PSX), but it's a very good start, and it's impressive that you even got that far. I also feel that I should let you know that sample 86 is missing from the soundfont. (I couldn't listen to 01.mid properly because it used that sample)


Nothing should be missing, I'll have to double check some stuff...

As far as the cutoffs go, yeah, I know what the problem is. I've watched the sound debug output on PSX emulator and it extensively uses large ADSR envelopes to provide fade in and fade out effects. I just haven't found where in the .WMD the ADSR coefficients are stored yet.

Share this post


Link to post

Thank you, thank you, thank you for doing this! I reassembled some the songs in FL Studio using the built in SoundFont player and summed out to Sonar with Rewire and mixed with the waves mastering bundle .. mmmm delicious. With a few tweaks, I had them sounding damn close to the original but mixed quite a bit better.

Share this post


Link to post

Btw, natt, you're doing really awesome work and I am thankful that someone is stepping up to tackle this. I've been trying to convert the PSX/N64 music myself on and off over the years but can never fully understand the system. Once you find a suitable format, will you be willing to make a conversion tool?

I am also willing to help out writing the utility if you ever need help.

Share this post


Link to post

I've been scratching my head a bunch over voice selection. I can't seem to quite figure out how it is determined which voice is played on which track... the fact that some tracks sound ok on the mid+sf2 I posted before seems to be the combination of multiple bugs working against eachother.

Maybe this sounds better?

http://www.mediafire.com/?cpkwhyxxxp6l6y5

(Note that if a staff uses program 0 here, it means I have no idea what program to assign it.)

I'm going to clean up what I've done a bit and then release it for others to look at, because quite frankly, everything I haven't figured out yet, I'm stumped on. Most importantly, there are bunches of tables and headers in DOOMSND.WMD that I don't understand.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×