How to program your SoundBlaster board

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

Chapter 3 - Mixer Chip Programming

In this chapter I'm going to explain how can you program the mixer chip, a component built in your SB Pro o later models. With this chip you can change the volumes and the pannings of the sound sources of your soundboard. The mixer chip has several internal registers and, for programming them, you must access them via the SoundBlaster Mixer Adress I/O port and the Mixer Data I/O port. The first is a write-only port where you will put the index of the mixer internal register that you want to access, the second is the port where you will put values into or read from. Referring to the SB base port setting, here are the two relative adresses:

SB I/O port (base +) Meaning
__________________ _________________________________________
04h Mixer Adress register I/O port (Write-only)
05h Mixer Data register I/O port (R/W)
__________________ _________________________________________

There are mainly two volume levels that we wish to control: the DAC level (the volume of the DAC sound source) and the Master level (the volume of all the sound sources mixed - like the DAC, the FM chip, the CD). You know that if one of this two levels is zeroed, you won't hear your sample.

The Master volume register is number 22h, and you can set a value between 0 and 7 to each of the two (left and right, I mean) channels independently. So the data byte you'll write in the data register will be the join of the two nibbles, right channel volume as MS nibble, left channel level as LS nibble. If the soundboard is a SB16 or later you can set the value via the same I/O port but you can set 16 different values (from 0 to 15) for each channel in the same way we've seen.

The DAC level register is number 04h, and it works the same way as the Master volume register.

Another very important register is the Reset register (00h). With this register you can reset the values of the whole mixer to a standard values. Just write 0 into the data register after selecting this index.

In the chapter number two I've said that you can't play stereo samples without using the mixer if you owe a SB Pro or a SB Pro2. If you would to play in stereo, just use the mixer register Stereo Select (0Eh); writing 33h into the data port you will get stereo sound, writing 31h you will get mono sound. Changing data bit number 5 you can also switch on and off an output filter: 0 stands for On and 1 for Off. This mode of making stereo sounds is the only on a SB Pro or Pro2 but it won't work on a SB 16 or later. SB 16 has a totally different way to do that.

Note that for having a DAC stereo reproduction you must modify the DSP's time constant value by doubling it. For example, if you want to play in stereo at 8000 Hz, say the DSP you're going to play in mono at 16000Hz; this is the only way on a SB Pro - Pro2.

SoundBlaster 16 has many registers more. It has two separate register for the Master volume (30h for left channel, 31h for right channel; values from 0 to 31), two for DAC level (32h for left, 33h for right; 32 level values).

As I've said in the second chapter, it's possible, via the SB 16 Mixer chip, discover (and even change) the IRQ and the DMA settings for the soundboard. You can know which is the selected IRQ just reading the IRQ Select register (index 80h). Each bit of the LS nibble say if the IRQ is enabled: 1 stand for enabled, 0 for disabled; bit 0 is IRQ 2, bit 1 is IRQ 5, bit 2 is IRQ 7, bit 3 is IRQ 10. You can also enable multiple IRQ, but I don't know why you would do such a stupid thing. The DMA select register (81h) will give you the informations about the DMA channels used. Each bit of the data byte will say if the DMA is enabled: 1 means enabled, 0 means disabled; 0 is DMA 0, 1 is DMA 1 and so on. Remember that DMA 2 and 4 are reserved (0). It's better to enable only one 8 bit DMA channel and one 16 bit DMA channel.

You can also discover if your SB 16 has an IRQ pending (is waiting for an acknowledge). Just read the IRQ Status Register (82h), bit 0 reflects 8-bit IRQ pending status (generated by an 8-bit DMA transfer, 1 stand for true), bit 1 reflects 16-bit IRQ pending status; again 1 means IRQ pending.

At last, but not at least, the SB 16 mixer give you also the capability of changing the sound quality in terms of bass and treble settings. You can change the treble for the left channel via the Treble Left Register (44h); you must set the MS nibble to a value between 0h and Fh (the LS nibble is reserved and must be set to 0). So, for example, a byte value like 00h means -14dB, F0h means +14dB, 80h means 0dB. The same for the Treble Right Register (45h). Same again for Bass Left (46h) and Right (47h) Registers. This settings apply on all the sounds produced by the board.

That's all about this chip: here's a little table with all the registers we've used in this chapter.  

Mixer Register Meaning
______________ _______________________________________
00h Reset Mixer Chip
04h DAC level
22h Master level
30h Master level left (SB 16 or later models)
31h Master level right (SB 16 or later models)
32h DAC level left (SB 16 or later models)
33h DAC level right (SB 16 or later models)
44h Treble Left (SB 16 or later models)
45h Treble Right (SB 16 or later models)
46h Bass Left (SB 16 or later models)
47h Bass Right (SB 16 or later models)
0Eh Stereo Select (SB Pro - SB Pro2 only)
80h IRQ Select (SB 16 or later models)
81h DMA Select (SB 16 or later models)
82h IRQ Status (SB 16 or later - read only)
______________ _______________________________________

In the next chapter I'll give you all the information for programming a generic 8-or-16-bit, mono or stereo, Auto-Initialize or Single Cycle DMA transfer, via the most powerful SB 16 DSP command.

Stay tuned!

Sverx, 01 / 06 / 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 - Back to Chapter 2 - Go to Chapter 4 - Back to Home Page ]

1