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 sb16 option.
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.
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.
Output is supported on Windows, Linux, FreeBSD, MacOS 9 and MacOSX at the moment.
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 wave device is set to alsa, Bochs uses it's default PCM output device instead of an OSS device.
On Windows, midi and (wave) output go to the midi mapper and the wave mapper, respectively. A future version might have selectable output devices.
A wavetable synthesizer on /dev/midi00 and a working /dev/dsp if you want real time music and sound, otherwise output to midi and wave files is also possible. Optionally, you can use a software midi interpreter, such as the midid program from the DosEmu project instead of /dev/midi00.
You need to configure Bochs using the
There are a few values in config.h that are relevant to the sound functions.
Edit config.h after running configure, but before compiling.
BX_USE_SB16_SMF should be 1 unless you intend to have several sound cards running at the same time.
BX_SOUND_OUTPUT_C is the name of the class used for output. The default is to have no output functions, so you need to change this if you want any sound. 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_output_c for no output at all.
Setup the SB16 emulation in your bochsrc, according to instructions in that file (see sb16 option).
The source for the SB16CTRL program that is used to modify the runtime behavior of the SB16 emulation is included in misc/sb16/. It is a C program that can be run from inside the emulation.
It currently supports the following commands:
Table 4-5. Supported options for sb16ctl
|Show the selected emulator info string, e.g. sb16ctrl -i 3 to show how many patch translations are active.|
|Load a translation into the translation table. The numbers are: "OldBankMSB,OldBankLSB,OldProgram,NewBankMSB,NewBankLSB,NewProgram". All values can be 0..127 or 255. 255 for "Old" values means match any and for "New" values means don't change, e.g. sb16ctrl -t 255,255,0,255,255,32 to change patch 0 (Piano) to patch 32 (Acoustic Bass).|
|Reset the patch translation table e.g. sb16ctrl -r.|
|Upload the given numbers to the midi output device. Note that it should be a complete midi message, and also that it is subject to patch translation, e.g. sb16ctrl -m 0x80,64,0 to send a note-off message to channel 0.|
|Read in a file and execute the commands in it. These have the same format as the above commands, except that they don't have the dash "-" in front of them. Comment lines are supported and start with a hash sign "#".|
|Show a brief summary of the commands.|
All numbers can be valid parameters to the
strtol() function, so hex and
octal notation is fine. They have to be delimited by either commas "," or
slashes "/", spaces are not allowed.
The command line can have any number of commands. However, if none are given, "-f -" is assumed, which means commands are taken from stdin.
Port it to more OS's.
Finish the OPL3 FM emulation by translating the music to midi data.