how to implement a sound blaster 16?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

how to implement a sound blaster 16?

Post 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.
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: how to implement a sound blaster 16?

Post 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
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: how to implement a sound blaster 16?

Post 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();

}
Post Reply