Archived

This topic is now archived and is closed to further replies.

VyvyanBasterd

DirectSound and .XM/.MOD files...

Recommended Posts

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

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
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.



Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites