ossaudiodev.rst 17.1 KB

:mod:`ossaudiodev` --- Access to OSS-compatible audio devices

This module allows you to access the OSS (Open Sound System) audio interface. OSS is available for a wide range of open-source and commercial Unices, and is the standard audio interface for Linux and recent versions of FreeBSD.

:mod:`ossaudiodev` defines the following variables and functions:

Audio Device Objects

Before you can write to or read from an audio device, you must call three methods in the correct order:

  1. :meth:`setfmt` to set the output format
  2. :meth:`channels` to set the number of channels
  3. :meth:`speed` to set the sample rate

Alternately, you can use the :meth:`setparameters` method to set all three audio parameters at once. This is more convenient, but may not be as flexible in all cases.

The audio device objects returned by :func:`.open` define the following methods and (read-only) attributes:

The following methods each map to exactly one :func:`ioctl` system call. The correspondence is obvious: for example, :meth:`setfmt` corresponds to the SNDCTL_DSP_SETFMT ioctl, and :meth:`sync` to SNDCTL_DSP_SYNC (this can be useful when consulting the OSS documentation). If the underlying :func:`ioctl` fails, they all raise :exc:`IOError`.

The following convenience methods combine several ioctls, or one ioctl and some simple calculations.

Audio device objects also support several read-only attributes:

Mixer Device Objects

The mixer object provides two file-like methods:

The remaining methods are specific to audio mixing: