Skip to main content
GameDev.net gamedev.net
🔒 Locked

What sound format should I use for sound effects for my MS-DOS game?

Started by yaboiryan May 23, 2021 at 5:58 AM 22 replies 34.6k views
Original Post
yaboiryan
yaboiryan

A few months ago, I started a new game project in MS DOS and C. I wanted to make a 3D Wolfenstein-like FPS game, so I got the graphical aspect of the game engine already made. I am only struggling with one last thing: sound.

What I have so far:

I was wondering whether I could just use .MOD files somehow since I have found several libraries that I can use to implement .MOD files, but I have not found .MOD files to be a very feasible option, as, in many ways, they are like .MIDI files in many ways, so I cant just play the sound alone very efficiently.

What are the sound formats that MS-DOS developers used, and are there any libraries I can use (that are for Watcom C) that will do the loading for me?

-Thanks,

-Ryan

a light breeze
a light breeze

Depends on the hardware you are targetting.

For uncompressed digitized audio, .wav is the de-facto standard. Compressed digitized audio is probably overkill for a DOS game.

If you are targetting sound cards without digitized audio like AdLib, look into FM synthesis. I don't think that there's a standard file format.

If you are targetting the PC speaker, you're on your own.

.mod is a music file format, not suitable for sound effects. It requires a sound card that is capable of digitized audio.

yaboiryan
yaboiryan

@a light breeze Thank you for responding to my post! I am targetting digitized audio cards because I am using a SoundBlaster on my Windows 95 and a SoundBlaster on DosBOX.

I havent seen any DOS programs that can successfully do .WAV files. The only thing I see anywhere is .MIDI files and .MOD files, and since they are both just music filetypes, I cant really use them for things like gunshots. However, I was maybe thinking perhaps I could use .aiff files, since I used those when I was messing with N64 game development (well,they started off as .aiff files, but then they were converted to a file type that the N64 could read). Everywhere I look just says .WAV files, and I had a feeling that .WAV files wouldn't work with DOS applications. But I have seen games like Doom and Wolfenstein and Duke3D and Nitemare3D and they all have sound effects that play when you do things like shoot a gun or open a door. I am having trouble finding information about how the developers were able to implement such files because most internet sources typically dont show how to do things in MS-DOS, let alone the Watcom compiler (I dont need the code to be for the Watcom compiler because I can just convert the Borland functions to Watcom if need be, though it would be very convenient if they were for the Watcom compiler).

-Ryan

SyncViews
SyncViews

Not sure if the earlier games uses files at all for such things. Might just have been frequency+duration directly in the code for many of the simple effects? Also wouldn't surprise me if they made their own minimal file/embedded format if not directly coded.

With the entire program being less than a floppy disk and little memory on many systems, even something like a 8bit 8kHz mono wav is pretty big

yaboiryan
yaboiryan

@undefined Really? So Wolfenstein 3D's gunshot sound effect is just a frequency thing? I always thought they loaded in some kind of sound file that played.

Juliean
Juliean

I cannot speak for DOS specifically, but it is kind of true that old systems used a quite different way of storing sounds. I've been working deeply with emulating sounds from the SNES, and their sound-files are essentially just telling the sound-chip what “instrument” to play at what time - resulting in very small files, we're talking KBs compared to the same file as an MP3 having at least a few MBs. Check out https://de.wikipedia.org/wiki/SPC700​ - I'm sure you could find similar documentation to what formats were available for DOS back in the days.

a light breeze
a light breeze

Pretty much any library that handles digitized audio files at all will have .wav loading code. I know SDL does.

a light breeze
a light breeze

I assumed you would write your own loading code instead of relying on a third-party library. Why target DOS if not for the do-it-yourself ethos?

Anyway, there's libwav, or if you're going to use a third-party library anyway, you might as well go for compressed audio and use the Opus codec.

SillyCow
SillyCow

Back in the DOS days, many games used 3rd party sound libraries (not SDL) specifically because each sound card required a different interface (especially for music [as opposed to SFX] ).
I suggest you select your sound file format based on the library you want to use.

If you want to code your own (which will require alot of effort) , then I suggest you target a single mainstream card (like sound-blaster), and code your own. Then create a convertor which will convert a popular format into your old DOS format. I did this for my DOS games for 3D models: Model in 3D studio -→ export to my custom DOS optimized model format. I would follow the same workflow for sound. However take into consideration, that rolling your own sound “engine” will be very fun, but will possibly be more work than your actual game :-) .

So it really depends on how much time you have, and where you want to spend it. Coding low level engines is fun! But it will take up time you can spend working on your actual game.

If you simply want to copy ID-Software code, have a look at: https://github.com/id-Software/DOOM/blob/master/sndserv/soundsrv.c

My Oculus Rift Game: RaiderV My Android VR games: Time-Rider& Dozer Driver My browser game: 
yaboiryan
yaboiryan

@SillyCow Where might I find these audio formats, and where might I also find these libraries that can implement these sound formats?

yaboiryan
yaboiryan

@undefined I have already programmed a (mostly) working 3D FPS Game Engine in C with DOS. I dont really want to convert the ENTIRE project into Windows at the moment.

Geri
Geri

22050 hz mono wav for sound effects, mid for music. should be compatible, and should give good results.

yaboiryan
yaboiryan

@Geri Okay so now I just created a new library made from some copied functions from Varmint (which is a sound library for Watcom) and I am trying to use it now, but only a few of the sounds actually work, and setting the Bit Resoution to 22050 and mono makes the sound play even less correct than it was already playing.

Oh, and quick update, I got the .wav files from this link to work just fine, but I cant figure out what the wav files in this link have that the ones I am making dont have…

yaboiryan
yaboiryan

@sillycow I found a sound library that is freeware and I started building on that, and I got some .wav files to work. Specifically the ones that came with the library in the demo folder and the ones that come from the link I mentioned in the post above (here). THe other ones sound incredibly weird and distorted, so I went and tested them with the normal game library from which I had based my own game functions and I got the same result. So I then went and tested it with another DOS sound library demo and that one gave me the same distortion issue.

However, when I tried a sound player called “Plany.exe," the sound worked flawlessly without any type of errors or sound distortion, which gives me hope, but at the same time, I honestly don't know enough about .wav files to know what went wrong.

SillyCow
SillyCow

If it were me, I would just reverse engineer the file format of the files that you have working well. It would be much easier to find an external program to convert your audio samples into that same file format which you allready have working, then to reengineer the code to play arbitrary formats and bitrates

My Oculus Rift Game: RaiderV My Android VR games: Time-Rider& Dozer Driver My browser game: 
yaboiryan
yaboiryan

@SillyCow Thats the issue. I dont have one that works well enough to use other .MOD files, and that is only for music.

Geri
Geri

probably the wav files you used was stored with some non-standard strides, or used a non-standard word type. just re-save them with windows sound recorder in win98 or something, it should work. please note that randomly downloading code snippets for 30 year old sound apis and combining them with wave files recorded with phones made two months ago is not going to magically work, no matter how hard you google it.

yaboiryan
yaboiryan

@Geri and @silly cow I tried that yesterday, and that still did not work. So I ditched implementing .WAV files, although they can still be implemented if I want, but I stopped using them. I am not testing out .VOC files. I am using an earlier and open source version of the Miles Sound System (the game engine Empire Earth used). I am now having another issue. Only half of the file plays correctly (which is an upgrade from the .wav file that would not really play at all). And the good part about this is that with each .VOC file I have tried, I have gotten at least half of the file working correctly. Now I need to figure out what is going on with the other half of the file.

This is not only happening in the game itself, but this happens with all of the demo .VOC files that John Miles provided. The demo also plays these strangely when I compile it. But oddly enough, the example demo that John Miles provided plays the .VOC sounds perfectly, which leads me to believe that there is an error in my compilation. I sent an email to Mr. Miles, and I will keep all of you updated about how that is going.

Here are two possible solutions I am thinking about using:

I can edit the file and make it where the bulk of the sound happens in the second half of the file.

I can recompile the .obj file that is provided (which I have not yet successfully done) and then just try it out with that file, although the one that Miles provided in the source does not work.

What do you all think I should do?

Also, this doesn't really have any significance, but I am using SoundBlaster as my sound card.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.