Page 1 of 1

how to implement a sound blaster 16?

Posted: Sat Apr 21, 2018 9:40 am
by Klakap
Good day! I would like to implement a Sound Blaster 16 in my operating system but I don't know how do I do it. Page https://wiki.osdev.org/Sound_Blaster_16 me didn't help because I don't know how I have to play the sound. I tried to send to port 0x0C command 0xE1 I found the version Sound Blaster but on port 0x0A no output. Please where do I get information or code how to implement a sound blaster 16?

//edit: I use Qemu.

Re: how to implement a sound blaster 16?

Posted: Wed Apr 25, 2018 4:58 pm
by BenLunt
Hi,

The Sound Blaster hardware is actually quite out of date, though if you wish to, it is still enjoyable to program them. However, it will be hard pressed to find a physical machine with one still present. In fact, if you do, depending on the model, they are quite the collectors item.

I have a simple detection routine at http://www.fysnet.net/detectsb.htm that shows how to detect it in DOS, and then some simple code to play a .WAV file at http://www.fysnet.net/playwav.htm. Please note that they assume you are in a TRUE DOS environment.

Later hardware now uses more modern ways of playing sound. Quoted from this forums wiki (which is a good place to go for more information): "In 1997 Intel specified a new standard, AC97 (short for Audio Codec 1997), that virtually replaced the Sound Blaster standard by specifying higher quality sampling."

Ben
- http://www.fysnet.net/input_and_output_devices.htm

Re: how to implement a sound blaster 16?

Posted: Mon May 07, 2018 7:24 am
by Klakap
Thank you, I managed to detect the Sound Blaster 16. If someone had a similar problem, here is the code in C:

Code: Select all

#define DSP_RESET 0x226
#define DSP_READ 0x22A
#define DSP_WRITE 0x22C
#define DSP_BUFFER 0x22E
#define DSP_INTERRUPT 0x22F

void reset_DSP(void);
void write_DSP(int value);
int read_DSP(void);
void init_SB16(void);

uint sound_blaster=FALSE;
uint sb16_version_major=FALSE;
uint sb16_version_minor=FALSE;

void reset_DSP(void) {
          outb(DSP_RESET, 1);
          wait(1);
          outb(DSP_RESET, 0);
          wait(1);

          if(inb(DSP_READ)==0xAA) { 
                    sound_blaster=TRUE; 
          }
}

void write_DSP(int value) {
          uint status=0;
          status=inb(DSP_WRITE);

          outb(DSP_WRITE, value);
} 

int read_DSP(void) {
          return inb(DSP_READ);
} 

void init_SB16(void) {
          reset_DSP();

          if(sound_blaster==FALSE) {
                    return;
          }

          write_DSP(0xE1);
          sb16_version_major=read_DSP();
          sb16_version_minor=read_DSP();

}