How to program your SoundBlaster board

(see at the end of document for Copyrights and Warranties)

Chapter 0 - SoundBoard Introduction

Ok, this is the first chapter, so I'll show you the basis. Your SoundBlaster board is made up with, at least, two components: the FM generator and the DSP chip. The first is the piece that generates those sintetic sounds you hear in some games, or if you told the game you have an Ad-lib board. This chip isn't easy to program (nor the DSP, but you'll get more satisfied!) and I won't say anything more ... yust remember that there's in.

The DSP (digital signal (or sound) processor) is the responsible of making good sound, effects, voices, coming out from your speakers. It can reproduce digitalized audio ranging from 4K to 44.1K samples/sec, mono or stereo, at 8 or 16 bit quality. But the DSPs aren't the same in every SoundBlaster, and in SB models prior to the SB16, you'll not get the 16 bit quality. In older SB you will not get the stereo too! So here is a little table explaining the reproduction capabilities of every SB model.

SB Model Samples/sec Stereo? Quality
________________________ _______________ ____________ _____________________
SB 1.0, SB 1.5 4K to 22.05K NO  8 bit only
SB 2.0 4K to 44.1K NO 8 bit only
SB Pro, SB Pro2 4K to 44.1K YES(*) 8 bit only
SB 16 4K to 44.1K YES 8 and 16 bit
SB AWE32, 64, GOLD 5K to 44.1K YES 8 and 16 bit

(*) SB Pro and SB Pro2 can play in stereo at 22.05K Samples/sec max.

Well, we want now discover if the computer on which our games is running has a SB board installed and, if a SB is present, which capabilities have. It's not so easy as it seems, because there's not a really safe way to do that. You'll understand why.

To program the SB we need to communicate with it, and we can do that only knowing its base adress port, its IRQ and DMA channel(s). To do that some games prompt the player for this values. I think not all the people who use a computer know its BIOS revision date, so why they must know an exadecimal I/O port number, an IRQ number, one or two DMA channel(s) number? The way should be another.

Many games rely upon the dos environment variable 'BLASTER', which tell the game "where" the board is located. That's better but, what happens if the variable is not set? If its settings are wrong? If a SB is not onto the system or is broken and the variable is present?

The third way is to check all the possible I/O port, IRQ, DMA chn, until we find the SB or until we can absolutly say that a SB in not onboard. Or until the computer hangs. That could happen, for example, if another component of our system is mapped onto the I/O port we put values into.

So, how we can manage that? My answer is not ever correct, but it works fine in most cases. Just use a combination of all the three possibilities we have seen. First: if a 'BLASTER' variable is present, read it, it contains the first values we will try. Second: if 'BLASTER' variable isn't present or isn't correct, try scanning all the possibly I/O ports starting from the most commonly used to the less. When you get the SB I/O port you've done the harder work.

If the computer hangs you've got a problem. In a help file coming with your game say something like "If the computer hangs do that ..." and ask for correct 'BLASTER' variable settings, or command line parameters or something like that. Remember also that the SB may be hanged, or broken. This is not our problem, as programmers we assume that all the hardware is working fine.

Now I will explain the environment variable 'BLASTER'. Tipically it's like:

BLASTER = Appp Ii Dd Hh Tt (other may follow)

where ppp is a three digit number that mean the I/O port adress in hexadecimal value, i is the IRQ number, d the 8 bit DMA channel, h the 16 bit DMA channel (on SB16 or later models), t the type. Other adresses (like the MPU chip adress (not discussed) may follow). Note that the 16 bit DMA channel apply only when you have an SB 16 or later, so, on earlier models, this value isn't there.

Now it's time I start to give you some values. Possible values for the 'ppp' parameter are: 210h, 220h, 230h, 240h, 250h, 260h, 280h (h at the end means hexadecimal value). Possible IRQ numbers are 2, 3, 5, 7, 10. The 8 bit DMA channel can be 0, 1, 3; the 16 bit channel can be 5, 6, 7. I think it's better override the T parameter as we will identify the board ourself, but here are the value, just for be complete: 1 means SB 1.0 or SB 1.5, 2 means SB Pro, 3 means SB 2.0, 4 means SB Pro2, 5 is SB Pro MCV (works like the SB Pro), 6 means SB 16 or AWE 32. Some text files I've read says it's not as I explained, but many says it's.

This explanation needs some hints. First, the base I/O port can be:

SB Model Possible I/O values
__________________________ ______________________________
SB 1.0, SB 1.5 210h, 220h, 230h, 240h, 250h, 260h
SB 2.0, SB Pro, SB Pro2 220h, 240h
SB 16, SB AWE 32 220h, 240h, 260h, 280h

so the I/O base port search order can be something like 220h, 240h, 260h, 280h, 210h, 230h, 250h, as, you know, it's hard to find an SB 1.0 or 1.5 yet installed.

Second hint: the IRQ is almost ever '5' ('2' is used for the cascaded second PIC (programmable interrupt controller) in the AT computer (286 and forth), '3' is reserved for COM2 (and COM4, of course), '7' is reserved for LPT1 (altought printing doesn't require an IRQ, so this IRQ may be free even if there is a printer attached at LPT1), '10' is reserved from the IDE controller and is used by some CD-ROM drives, but I know some people that have their SB hooked at IRQ 10 and it works. I think you know that IRQ 10 is available only on AT computers).

I think the best search order is 5, 7, 10, 3, 2. I don't know if IRQ 2 can be redirected on IRQ 9 on ATs and it works, let me know if you heard someone tryied it.

Now about the DMA channels: usually they are '1' and '5'. I know '3' is used by some -very- old HD controllers. The other values may be correct as well without special notes.

This '0' chapter stops here. Just remember that before you can use your soundboard, you must reset its DSP. You can do that while you're detecting the board, and it's a good general rule. Ok, get ready for the first chapter: 'Basis of DSP Programming' where I will explain you how to reset the soundboard, how to turn on and off the speakers and how make your own first sample coming out! Stay tuned!

Sverx, 23 / 05 / 98 __________________________________________________________________

Warranty and Copyright Policy

This document is provided on an "as-is" basis, and its author makes no warranty or representation, express or implied, with respect to its quality performance or fitness for a particular purpose. In no event will the author of this document be liable for direct, indirect, special, incidental, or consequential damages arising out of the use or inability to use the information contained within. Use of this document is at your own risk.

This file may be used and copied freely so long as the applicable copyright notices are retained, and no modifications are made to the text of the document. No money shall be charged for its distribution beyond reasonable shipping, handling and duplication costs, nor shall proprietary changes be made to this document so that it cannot be distributed freely. This document may not be included in published material or commercial packages without the written consent of its author.

ALL COPYRIGHTS AND TRADEMARKS BELONG TO THEIR RESPECTIVE OWNERS.

__________________________________________________________________

[Back to Main Programming Page - Go to Chapter 1 - Back to Home Page ]

1