Platform-specific Settings§

AsioSettings

ASIO-specific input/output settings.

CoreAudioSettings

Mac Core Audio-specific input/output settings.

WasapiSettings

WASAPI-specific input/output settings.

class sounddevice.AsioSettings(channel_selectors)[source]§

ASIO-specific input/output settings.

Objects of this class can be used as extra_settings argument to Stream() (and variants) or as default.extra_settings.

Parameters

channel_selectors (list of int) – Support for opening only specific channels of an ASIO device. channel_selectors is a list of integers specifying the (zero-based) channel numbers to use. The length of channel_selectors must match the corresponding channels parameter of Stream() (or variants), otherwise a crash may result. The values in the channel_selectors array must specify channels within the range of supported channels.

Examples

Setting output channels when calling play():

>>> import sounddevice as sd
>>> asio_out = sd.AsioSettings(channel_selectors=[12, 13])
>>> sd.play(..., extra_settings=asio_out)

Setting default output channels:

>>> sd.default.extra_settings = asio_out
>>> sd.play(...)

Setting input channels as well:

>>> asio_in = sd.AsioSettings(channel_selectors=[8])
>>> sd.default.extra_settings = asio_in, asio_out
>>> sd.playrec(..., channels=1, ...)
class sounddevice.CoreAudioSettings(channel_map=None, change_device_parameters=False, fail_if_conversion_required=False, conversion_quality='max')[source]§

Mac Core Audio-specific input/output settings.

Objects of this class can be used as extra_settings argument to Stream() (and variants) or as default.extra_settings.

Parameters
  • channel_map (sequence of int, optional) – Support for opening only specific channels of a Core Audio device. Note that channel_map is treated differently between input and output channels.

    For input devices, channel_map is a list of integers specifying the (zero-based) channel numbers to use.

    For output devices, channel_map must have the same length as the number of output channels of the device. Specify unused channels with -1, and a 0-based index for any desired channels.

    See the example below. For additional information, see the PortAudio documentation.

  • change_device_parameters (bool, optional) – If True, allows PortAudio to change things like the device’s frame size, which allows for much lower latency, but might disrupt the device if other programs are using it, even when you are just querying the device. False is the default.

  • fail_if_conversion_required (bool, optional) – In combination with the above flag, True causes the stream opening to fail, unless the exact sample rates are supported by the device.

  • conversion_quality ({‘min’, ‘low’, ‘medium’, ‘high’, ‘max’}, optional) – This sets Core Audio’s sample rate conversion quality. 'max' is the default.

Example

This example assumes a device having 6 input and 6 output channels. Input is from the second and fourth channels, and output is to the device’s third and fifth channels:

>>> import sounddevice as sd
>>> ca_in = sd.CoreAudioSettings(channel_map=[1, 3])
>>> ca_out = sd.CoreAudioSettings(channel_map=[-1, -1, 0, -1, 1, -1])
>>> sd.playrec(..., channels=2, extra_settings=(ca_in, ca_out))
class sounddevice.WasapiSettings(exclusive=False)[source]§

WASAPI-specific input/output settings.

Objects of this class can be used as extra_settings argument to Stream() (and variants) or as default.extra_settings. They can also be used in check_input_settings() and check_output_settings().

Parameters

exclusive (bool) – Exclusive mode allows to deliver audio data directly to hardware bypassing software mixing.

Examples

Setting exclusive mode when calling play():

>>> import sounddevice as sd
>>> wasapi_exclusive = sd.WasapiSettings(exclusive=True)
>>> sd.play(..., extra_settings=wasapi_exclusive)

Setting exclusive mode as default:

>>> sd.default.extra_settings = wasapi_exclusive
>>> sd.play(...)