2.8. Sound Blaster 16 Emulation

This section is a detailed description for configuring Sound Blaster 16 from source. If you have a binary and all you want to know is what to put in your bochsrc file, see the sb16 bochsrc option in the user guide.

The original version of the Sound Blaster 16 (SB16) emulation for Bochs was written and donated by Josef Drexler. The entire set of his SB16 patches have been integrated into Bochs, however, so you can find everything you need here.

2.8.1. How well does it work?

Right now, MPU401 emulation is next to perfect. It supports UART and SBMIDI mode, because the SB16's MPU401 ports can't do anything else as well.

The digital audio basically works, but the emulation is too slow for fluent output unless the application doesn't do much in the background (or the foreground, really). The sound tends to looping or crackle on slower computer, but the emulation appears to be correct. Even a MOD player works, although only for lower sampling speeds.

The OPL3 chip now also produces output. The source code has been ported from DOSBox and the output data is polled from the mixer thread.

Also, the MIDI data running through the MPU401 ports can be written into a SMF, that is the standard midi file. The wave output can be written into a VOC file, which has a format defined by Creative Labs. Output to a WAV file and dual output (device and file at the same time) is now also supported.

2.8.2. Output to a sound card

Output to the host sound system is supported on Windows, Linux, FreeBSD, MacOS 9, MacOSX and platforms supported by SDL.

On Linux using OSS, the output goes to any file or device. If you have a wavetable synthesizer, midi can go to /dev/midi00, otherwise you may need a midi interpreter. For example, the midid program from the DosEmu project would work. Wave output should go to /dev/dsp. These devices are assumed to be OSS devices, if they're not some of the ioctl's might fail. If ALSA is present on Linux and the sound driver is set to alsa, Bochs uses it's default PCM output device and MIDI sequencer.

On Windows, midi and wave output go to the midi mapper and the wave mapper, respectively. The device ID for the midi is now selectable. A future version might also have selectable wave output devices.

See the next section for more information about the sound lowlevel interface.

2.8.3. Configuring Bochs

You need to configure Bochs using the --enable-sb16 option. There are a few values in config.h that are relevant to the sound functions. Editing config.h after running configure is usually not necessary, since it detects the available drivers and enables them for the compilation.

BX_USE_SB16_SMF should be 1 unless you intend to have several sound cards running at the same time.

BX_SOUND_LOWLEVEL_NAME is the name of the driver used as the "default" one for all features. The default value of this setting is the dummy driver with no output. The configure script usually changes this value. The following are supported at the moment:

    alsa   Output for Linux with ALSA PCM and sequencer interface
    oss    Output for Linux, to /dev/dsp and /dev/midi00
    osx    Output for MacOSX midi and wave device
    sdl    Wave output with SDL/SDL2
    win    Output for Windows midi and wave mappers
    file   Wave and midi output to file
    dummy  Dummy functions, no output

Setup the SB16 emulation in your bochsrc, according to instructions in that file (see sb16 option in the user guide).

2.8.4. Runtime configuration

The source and the DOS executable for the SB16CTRL program that is used to modify the runtime behaviour of the SB16 emulator is included in misc/sb16.

See the section SB16CTRL in the user documentation for information about the commands of SB16CTRL.