SpatialSound QML Type

A sound object in 3D space. More...

Import Statement: import QtQuick3D.SpatialAudio

Properties

Methods

Detailed Description

A SpatialSound represents an audible object in 3D space. You can define it's position and orientation in space, set the sound it is playing and define a volume for the object.

The object can have different attenuation behavior, emit sound mainly in one direction or spherically, and behave as if occluded by some other object.

Property Documentation

autoPlay : bool

Determines whether the sound should automatically start playing when a source gets specified.

The default value is true.


directivity : float

Defines the directivity of the sound source. A value of 0 implies that the sound is emitted equally in all directions, while a value of 1 implies that the source mainly emits sound in the forward direction.

Valid values are between 0 and 1, the default is 0.


directivityOrder : float

Defines the order of the directivity of the sound source. A higher order implies a sharper localization of the sound cone.

The minimum value and default for this property is 1.


distanceCutoff : float

Defines a distance beyond which sound coming from the source will cutoff. If the listener is further away from the sound object than the cutoff distance it won't be audible anymore.


distanceModel : enumeration

Defines how the volume of the sound scales with distance to the listener. The volume starts scaling down from size to distanceCutoff. The volume is constant for distances smaller than size and zero for distances larger than the cutoff distance.

Property valueDescription
LogarithmicVolume decreases logarithmically with distance.
LinearVolume decreases linearly with distance.
ManualAttenuationAttenuation is defined manually using the manualAttenuation property.

loops : int

Determines how often the sound is played before the player stops. Set to SpatialSound::Infinite to loop the current sound forever.

The default value is 1.


manualAttenuation : float

Defines a manual attenuation factor if distanceModel is set to SpatialSound.ManualAttenuation.


nearFieldGain : float

Defines the near field gain for the sound source. Valid values are between 0 and 1. A near field gain of 1 will raise the volume of the sound signal by approx 20 dB for distances very close to the listener.


occlusionIntensity : float

Defines how much the object is occluded. 0 implies the object is not occluded at all, while a large number implies a large occlusion.

The default is 0.


size : float

Defines the size of the sound source. If the listener is closer to the sound object than the size, volume will stay constant. The size is also used to for occlusion calculations, where large sources can be partially occluded by a wall.


source : url

The source file for the sound to be played.


volume : float

Defines an overall volume for this sound source.

Values between 0 and 1 will attenuate the sound, while values above 1 provide an additional gain boost.


Method Documentation

pause()

Pauses sound playback at the current position. Calling play() will continue playback.


play()

Starts playing back the sound. Does nothing if the sound is already playing.


stop()

Stops sound playback and resets the current position and loop count to 0. Calling play() will begin playback at the beginning of the sound file.


© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.