Audio Devices

Device-Dependent Utilities

class palace.Device

Audio mix output, via either a system stream or a hardware port.

This can be used as a context manager that calls close upon completion of the block, even if an error occurs.

Parameters
  • name (str, optional) – The name of the playback device.

  • fallback (Iterable[str], optional) – Device names to fallback to, default to an empty tuple.

Raises

RuntimeError – If device creation fails.

Warns

RuntimeWarning – Before each fallback.

See also

device_names

Available device names

property alc_version

ALC version supported by this device.

property basic_name

Basic name of the device.

property clock_time

Current clock time for the device.

Note

This starts relative to the device being opened, and does not increment while there are no contexts nor while processing is paused. Currently, this may not exactly match the rate that sources play at. In the future it may utilize an OpenAL extension to retrieve the audio device’s real clock.

close()None

Close and free the device.

All previously-created contexts must first be destroyed.

property current_hrtf

Name of the HRTF currently being used by this device.

If HRTF is not currently enabled, this will be None.

property efx_version

EFX version supported by this device.

If ALC_EXT_EFX extension is unsupported, this will be (0, 0).

property frequency

Playback frequency in hertz.

property hrtf_enabled

Whether HRTF is enabled on the device.

If ALC_SOFT_HRTF extension is unavailable, this will return False although there could still be HRTF applied at a lower hardware level.

property hrtf_names

List of available HRTF names.

The order is retained from OpenAL, such that the index of a given name is the ID to use with ALC_HRTF_ID_SOFT.

If ALC_SOFT_HRTF extension is unavailable, this will be an empty list.

property max_auxiliary_sends

Maximum number of auxiliary source sends.

If ALC_EXT_EFX is unsupported, this will be 0.

property name

Name of the device.

pause_dsp()None

Pause device processing and stop contexts’ updates.

Multiple calls are allowed but it is not reference counted, so the device will resume after one resume_dsp call.

This requires ALC_SOFT_pause_device extension.

query_extension(name: str)bool

Return if an ALC extension exists on this device.

See also

query_extension

Query non-device-specific ALC extension

reset(attrs: Dict[int, int])None

Reset the device, using the specified attributes.

If ALC_SOFT_HRTF extension is unavailable, this will be a no-op.

resume_dsp()None

Resume device processing and restart contexts’ updates.

Multiple calls are allowed and will no-op.

Device-Independent Utilities

palace.device_names: DeviceNames

Read-only namespace of device names by category (basic, full and capture), as tuples of strings whose first item being the default.

palace.query_extension(name: str)bool

Return if a non-device-specific ALC extension exists.

See also

Device.query_extension

Query ALC extension on a device