Artifact [793d7d6373]
Not logged in

Artifact 793d7d637312de541730f4b7b9d35c15823594cd:

Wiki page [QEMU audio] by vitus on 2015-12-18 10:02:35.
D 2015-12-18T10:02:35.785
L QEMU\saudio
N text/x-markdown
P 01d15c6a74c3fe268b4e67f4080927d736b226ee
U vitus
W 2992
Audio support in the QEMU has two dimensions:

1. Emulated audio devices in the virtual machine
2. Connecting QEMU audio with outer world

Emulated audio devices
======================

List of audio devices is controlled via QEMU commandline option -soundhw.
It should also have equivalent in the QEMU config, but as of version 2.1 hardware support in the config is incomplete and we do not use configs.

You can list possible emulated devices via 

    qemu-system-i386 -soundhw help

You can add to virtual machine multiple devices at once, separating them by comma

    qemu-system-i386 -soundhw sb16,adlib

Adds sound blaster 16 and adlib cards to the virtual machine.

Most of QEMU-emulated sound card are very-very outdated, from XX century.
For relatively new operation systems I recommend always use **hda**.

Connecting QEMU with real sound device
======================================

It is not enough to add virtual sound card to virtual machine. If you want to really hear sounds, you'll have also tell QEMU how to connect, and probably some other options.

These options are set via environment variables, which are not documented in the QEMU user guide. You have to start

    qemu-system-i386 -audio-help

To get brief list of those variables.

Main variable is QEMU\_AUDIO\_DRV, which allows to specify driver, which would be used to input/output sound from QEMU.

Useful drivers are:

*. **spice** - redirects audio to your spice client. Has one playback and one capture channel. Supports no options.

*. **pa** - uses pulseaudio. Supports following variables QEMU\_PA\_SAMPLES (size of buffer), QEMU\_PA\_SERVER - address of pulseaudio server, if non-default, QEMU\_PA\_SINK - name of audio output sink, QEMU\_PA\_SOURCE  name of audio input source.

*. **alsa** talks directly with linux kernel drivers. There is horde of options which I don't understand

Less useful drivers:

*. **sdl** - use sdl library to output audio. Doesn't support sound input.

*. **oss** - talks to oss kernel drivers. Anybody uses OSS in 2015?

*. **none** - disable sound altogether.

*. **wav** - write all sound output to the wav file specified by QEMU\_WAV\_PATH variable. You can set frequency format (i.e. bit per sample and signed unsigned) and number of channels. No support for sound input. You can get same functionality with any of other drivers, if you use [vws](wiki?name=vws) **record** (or **wavcapture** command in the QEMU monitor)

Recording sound from QEMU
=========================

QEMU provides ability to record sound into file. There is **wavcapture** command in the monitor which start recording into specified file and **stopcapture** respectively. You can start several captures into different files and stop them by their ids, found via **info capture**.

You need to specify full path to the capture file, otherwise it would be written into some strange place, if you got enough rights to write there.

Z b3bf5dac6bf2a50ba164bd0ce582717a