This is a set of C++ source code to allow PC programmers to make use of the Sound Blaster card, in particular the digitised sample recording and playback modes. It uses classes so that your code can be independent of the particular sound driver being used; the only driver included is for the SB card but it is easy to add others. The driver supports version 2.0 of the Sound Blaster, meaning that you can achieve a 44kHz playback rate and can record at 15kHz. A feature of the software is that it supports double-buffered DMA routines implemented within a single memory area - basically this means you can have continuous playback (or recording) while doing something else, (accessing the disk, updating the screen, etc). The device-independent class is called SoundDevice. As well as providing virtual functions for access to derived classes, it contains two useful functions of its own. The first is file_dma, which lets you play sound files of unlimited length straight from the hard disk. This makes full use of the double buffering, and also keeps statistics on the length of time needed to access the disk so that you can keep an eye on its progress and see how much time is spare. The other function is monitor_input, which displays a bar graph along the top of the screen representing the input levels coming from the Sound Blaster. If it reaches 80 characters then you know that you've hit the maximum input level (255). The SB-specific class is called SbDevice. It is derived from SoundDevice, so you don't need to call it directly. If you are simply looking for information about the details of programming the SB card, you will find everything in there. If you intend to use the class you might want to modify some of the functions, particularly process_keys which defines what action is taken if a key is pressed during the DMA wait. Two demonstration programs are provided. The first is play_rec.exe which will play/record sample files through the Sound Blaster using the file_dma function. You can select any sample rate using the "-s" option. Note that this isn't a proper .voc or .wav file player. It doesn't read any specific file format headers - it just plays the whole file, so you might hear some strange noise at the beginning if you're not playing a raw sound file. The second program is monitor.exe, which (you guessed it) just uses the SoundDevice monitor_input function to give you a real-time display of your sound input. Note that you can also set the sampling rate in this program, which will change the rate of update of the display. Acknowledgements Much of the specific SB programming details (and some of the code) came from the Sound Blaster Freedom Project, available as /pub/msdos/sound/sbf?.zip (where ? is the version number). In particular the dma_code.asm file originated from there (although I have since modified it) and a few parts of SbDevice.cpp contain SBF code. You might like to take a look at the SBF package as a source of further information about the Sound Blaster. Distribution policy You may freely examine/use/modify/distribute this software, as long as you leave all attributions intact (ie you can't replace my name with yours and redistribute it). If you release any software which is based on (or uses ideas from) my code, please include an acknowledgement either in the documentation, or the program itself. File contents readme You're reading it sounddev.cpp SoundDevice class sbdevice.cpp SbDevice class sndclass.h Definitions for all the sound class functions dma_code.asm Assembly code for the DMA controller play_rec.cpp Source file for play_rec.exe play_rec.exe The first demo program monitor.cpp Source for monitor.exe monitor.exe The second demo program makefile How to rebuild the software The programs are designed for use with Borland C++. If you're using another compiler you might have to make a few changes. Note that dma_code.asm uses the "Ideal" mode of TASM, which won't go down too well with MASM. The tab size is meant to be set to something small (eg 2 or 4). Also, make sure you select a far data pointer model such as compact or large. Author Christopher M. Box Computer Science Department University of Warwick, England. From October 1993 until July 1996, you should be able to contact me indirectly by sending mail to 'J.M.Box@warwick.ac.uk', who will know my current address.