5.6. Using sound

5.6.1. Sound basics

Bochs supports two types of soundcards (SB16 ISA and ES1370 PCI) and the legacy PC speaker. The lowlevel sound interface provides a set of functions for wave (PCM) input / output and MIDI output using the host sound system. A driver must not implement all of these functions. The following table shows the supported drivers and their features.

Table 5-4. Sound lowlevel modules

NameDescriptionWave inputMIDI output
alsause the default ALSA PCM device and the default ALSA sequencer on LinuxYesYes
ossuse the Open Sound System on Linux and FreeBSDYesYes
osxfor output on Mac OS 9 and Mac OSXNoYes
sdlfor wave output on platforms supported by SDL (1.2.x or 2.x)NoNo
winfor output to the midi and wave mapper of WindowsYesYes

These special values are also valid for the sound driver:

When compiling Bochs, the lowlevel sound support is activated if one of the soundcards is enabled (--enable-sb16 or --enable-es1370). The configure script detects the available drivers and sets up a platform-default one.

At runtime the lowlevel sound module will be loaded automatically if one of the sound devices are enabled in the bochsrc file. The drivers and devices for wave input / output and MIDI output must be set up with the sound option.

5.6.2. The PC speaker

The PC speaker is connected to the PIT 8254 timer #2 and generates a square wave beep with a frequency depending on the timer value. In Bochs the speaker is a separate plugin that is controlled by the two events "beep on" and "beep off". The "beep on" event is also called when the frequency changes while turned on.

The destination for the speaker output can be selected with the mode parameter of the speaker option. Three choices are available:

5.6.3. SB16 runtime configuration

Most of the SB16 configuration parameters are available in the runtime configuration menu or dialog. In addition to this, there is a small program called SB16CTRL to change emulation settings from inside the simulation.

5.6.3.1. Runtime options

Unlike other devices, the SB16 emulation has its own logfile and a loglevel parameter to control what should be printed there. Both the log file and loglevel parameters can be changed at runtime. See the sb16 bochsrc option for details.

The output parameters midimode, midifile, wavemode and wavefile are also available at runtime.

The dmatimer parameter controls the DMA timing for wave (PCM) input and output. When you get non-continuous sound, this value can be ajusted to fix this. This needs a reasonably correct setting for the cpu: ips option.

5.6.3.2. SB16CTRL

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 5-5. Supported options for sb16ctrl

OptionDescription
-i number Show the selected emulator info string, e.g. sb16ctrl -i 3 to show how many patch translations are active.
-t six numbers 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).
-r Reset the patch translation table e.g. sb16ctrl -r.
-m some numbers 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.
-f filename 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 "#".
-h 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.