class QAudioEngine#

QAudioEngine manages a three dimensional sound field. More

Inheritance diagram of PySide6.QtSpatialAudio.QAudioEngine

Synopsis#

Properties#

Methods#

Slots#

Signals#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

You can use an instance of QAudioEngine to manage a sound field in three dimensions. A sound field is defined by several QSpatialSound objects that define a sound at a specified location in 3D space. You can also add stereo overlays using QAmbientSound .

You can use QAudioListener to define the position of the person listening to the sound field relative to the sound sources. Sound sources will be less audible if the listener is further away from source. They will also get mapped to the corresponding loudspeakers depending on the direction between listener and source.

QAudioEngine offers two output modes. The first mode renders the sound field to a set of speakers, either a stereo speaker pair or a surround configuration. The second mode provides an immersive 3D sound experience when using headphones.

Perception of sound localization is driven mainly by two factors. The first factor is timing differences of the sound waves between left and right ear. The second factor comes from various ways how sounds coming from different direcations create different types of reflections from our ears and heads. See https://en.wikipedia.org/wiki/Sound_localization for more details.

The spatial audio engine emulates those timing differences and reflections through Head related transfer functions (HRTF, see https://en.wikipedia.org/wiki/Head-related_transfer_function). The functions used emulates those effects for an average persons ears and head. It provides a good and immersive 3D sound localization experience for most persons when using headphones.

The engine is rather versatile allowing you to define room properties and reverb settings to emulate different types of rooms.

Sound sources can also be occluded dampening the sound coming from those sources.

The audio engine uses a coordinate system that is in centimeters by default. The axes are aligned with the typical coordinate system used in 3D. Positive x points to the right, positive y points up and positive z points backwards.

class OutputMode#

Constant

Description

QAudioEngine.Surround

Map the sounds to the loudspeaker configuration of the output device. This is normally a stereo or surround speaker setup.

QAudioEngine.Stereo

Map the sounds to the stereo loudspeaker configuration of the output device. This will ignore any additional speakers and only use the left and right channels to create a stero rendering of the sound field.

QAudioEngine.Headphone

Use Headphone spatialization to create a 3D audio effect when listening to the sound field through headphones

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property distanceScaleᅟ: float#

Defines the scale of the coordinate system being used by the spatial audio engine. By default, all units are in centimeters, in line with the default units being used by Qt Quick 3D.

Set the distance scale to QAudioEngine::DistanceScaleMeter to get units in meters.

Access functions:
property masterVolumeᅟ: float#

Sets or returns volume being used to render the sound field.

Access functions:
property outputDeviceᅟ: QAudioDevice#

Sets or returns the device that is being used for playing the sound field.

Access functions:
property outputModeᅟ: QAudioEngine.OutputMode#

Sets or retrieves the current output mode of the engine.

See also

OutputMode

Access functions:
property pausedᅟ: bool#

Pauses the spatial audio engine.

Access functions:
PySide6.QtSpatialAudio.QAudioEngine.DistanceScaleCentimeter#
PySide6.QtSpatialAudio.QAudioEngine.DistanceScaleMeter#
__init__(parent)#
Parameters:

parentQObject

__init__(sampleRate[, parent=None])
Parameters:
  • sampleRate – int

  • parentQObject

__init__()
distanceScale()#
Return type:

float

Getter of property distanceScaleᅟ .

distanceScaleChanged()#

Notification signal of property distanceScaleᅟ .

masterVolume()#
Return type:

float

Getter of property masterVolumeᅟ .

masterVolumeChanged()#

Notification signal of property masterVolumeᅟ .

outputDevice()#
Return type:

QAudioDevice

Getter of property outputDeviceᅟ .

outputDeviceChanged()#

Notification signal of property outputDeviceᅟ .

outputMode()#
Return type:

OutputMode

See also

setOutputMode()

Getter of property outputModeᅟ .

outputModeChanged()#

Notification signal of property outputModeᅟ .

pause()#

Pauses playback.

paused()#
Return type:

bool

See also

setPaused()

Getter of property pausedᅟ .

pausedChanged()#

Notification signal of property pausedᅟ .

resume()#

Resumes playback.

roomEffectsEnabled()#
Return type:

bool

Returns true if room effects are enabled.

sampleRate()#
Return type:

int

Returns the sample rate the engine has been configured with.

setDistanceScale(scale)#
Parameters:

scale – float

See also

distanceScale()

Setter of property distanceScaleᅟ .

setMasterVolume(volume)#
Parameters:

volume – float

See also

masterVolume()

Setter of property masterVolumeᅟ .

setOutputDevice(device)#
Parameters:

deviceQAudioDevice

See also

outputDevice()

Setter of property outputDeviceᅟ .

setOutputMode(mode)#
Parameters:

modeOutputMode

See also

outputMode()

Setter of property outputModeᅟ .

setPaused(paused)#
Parameters:

paused – bool

See also

paused()

Setter of property pausedᅟ .

setRoomEffectsEnabled(enabled)#
Parameters:

enabled – bool

Enables room effects such as echos and reverb.

Enables room effects if enabled is true. Room effects will only apply if you create one or more QAudioRoom objects and the listener is inside at least one of the rooms. If the listener is inside multiple rooms, the room with the smallest volume will be used.

start()#

Starts the engine.

stop()#

Stops the engine.