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.

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. This file format can be converted to WAV by sox for example.

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, 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. A future version might have selectable 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_C is the name of the class used as the "default" sound driver for output. 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:

        bx_sound_linux_c    for output to /dev/dsp and /dev/midi00 on Linux,
                            FreeBSD and maybe other OSes that use the OSS driver.
        bx_sound_windows_c  for output to the midi and wave mapper of
                            Windows 3.1 and higher.
        bx_sound_alsa_c     for output to the default ALSA PCM device and the
                            default ALSA sequencer.
        bx_sound_osx_c      for output on Mac OS 9 and Mac OSX.
        bx_sound_sdl_c      for wave output on platforms supported by SDL.
        bx_sound_output_c   for no output at all.

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.