DirectSound and .XM/.MOD files...

Started by
6 comments, last by VyvyanBasterd 23 years, 5 months ago
I was wondering if anyone could point me in the proper direction of finding some information on loading/playing .XM or .MOD files through DirectSound. As audio is the next step in my project, I want to find out what''s out there. I''d rather not use a library, like BASS; I''d rather write my own. Any worthwhile links? Vyvyan
Advertisement
Do a search for MikMod or something similar. There should be plenty of source for that lying around the net somewhere.


Steve 'Sly' Williams
Tools Developer
Krome Studios
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
wotsit.org has a few docs detailing the file structures for both MODs an XMs (along with all the others, like it, s3m, etc). Thats probably your best bet if you want to write a player from scratch. As the above post said, there should be lots of source out on the net (where to find it is another matter entirely ).. hornet.org might yeild some code... I know they''ve been down for a while, but there might be some stuff there (or not, I''ve never really kept up on it <=/ )


I tried to write a mod player once... I got as far as loading the file then gave up.. maybe I''ll return to it sometime..
Unfortunately directsound is not very MOD- or especially XM- friendly system, as I came to realize. Even basic ''chorus'', which is widely used in MODs (that is, same instrument playing on many channels simultaneously) is hard to implement properly and/or efficiently with DS buffers. You''ll want to write your custom mixer.

Wotsit is a fairly good source of information. I have used three or four MOD documents as source as I developed my player, as any single documentation does not cover the whole topic and some information holes need to be filled.

I''d still recommend that you start with mixer - when the mixer is up and running - even a basic one - testing MODplayer is far easier.

Some random tips that come in mind;
Use 16-bit mixing, even if you plan using 8-bit output.
When mixing, sum all channels together and clip to min/max. Use sample attenuation to avoid clipping.
Implementing interpolation later on IS worth the trouble - sound quality improvement is clearly audible! It isn''t even that expensive, I think that in my player penalty is about 20-30%... (no MMX or other such techiques implemented)
If you plan to play multiple formats, decode mods in loadtime to player''s internal format. Use XM as basis if this format, expanding a modplayer to support xm is not easy, other way around it''s trivial.



~~~ "'impossible' is a word in the dictonary of fools" --Napoleon
Hway, would it be simpler to simply convert from .XM to something easily streamable, say, simply a WAVE?

Vyvyan
If you mean that you are willing to store your music in wav''s, go ahead. They''ll take a lot of space, however.
If you mean decoding them to wavs runtime, that is exactly what the mixer would be doing. After mixing you just stream them out by using dsound interface.

If you want to keep your music as mods, I''d recommend for example S3M format. It has more features than basic MOD, and is - as a file format - somewhat easier to handle. XM is fairly complex format, and I never got my XM-player to run properly (however, I didn''t focus on that much either).

Personally, I think that I''ll be using MP3 as music format in future. You just can''t get as good-sounding music with MODs as with MP3, unless you use megs and megs of samples - by which point MP3 will result a smaller file anyway.
If you mean that you are willing to store your music in wav''s, go ahead. They''ll take a lot of space, however.
If you mean decoding them to wavs runtime, that is exactly what the mixer would be doing. After mixing you just stream them out by using dsound interface.

If you want to keep your music as mods, I''d recommend for example S3M format. It has more features than basic MOD, and is - as a file format - somewhat easier to handle. XM is fairly complex format, and I never got my XM-player to run properly (however, I didn''t focus on that much either).

Personally, I think that I''ll be using MP3 as music format in future. You just can''t get as good-sounding music with MODs as with MP3, unless you use megs and megs of samples - by which point MP3 will result a smaller file anyway.
~~~ "'impossible' is a word in the dictonary of fools" --Napoleon
Thanks for the tips!

Vyvyan

This topic is closed to new replies.

Advertisement