Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
spatialaudiooverview.qdoc
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4/*!
5\page spatialaudiooverview.html
6\title Spatial Audio Overview
7\brief Support for spatial audio.
8
9The Qt Spatial Audio API provides a number of classes that allow the creation of
10three dimensional sound scene. It is defined by objects located in 3D space
11that emit sound and surrounding geometry that can be modelled using
12one or several rooms. Finally a listener can be placed into this
13sound scene at a specified position and orientation.
14
15There are both C++ and QML APIs that can be used.
16
17\section1 Creating a sound scene
18
19To create the sound scene, one first instantiates a \l QAudioEngine. This engine
20processes input sound data and geometries to create a realistic
21representation of the sound scene as it would be experienced by a person placed
22at a specific location inside the scene.
23
24The \l QAudioEngine::OutputMode property can be used to optimize the output either
25for headphones using binaural (virtual 3D) rendering or for a stereo or surround speaker
26configuration.
27
28The output device can be selected using \l QAudioEngine::outputDevice property.
29
30Once the engine is set up, we can place various sound objects into the scene by creating
31\l QSpatialSound objects and specifying a url to a sound file using the \l
32QSpatialSound::source property.
33
34\l QAudioListener can be used to define the position and orientation of a person
35listening to the sound scene. At max one listener per engine can be used. If no listener
36is specified, the engine assumes that the listener is at the origin of the coordinate system
37facing into a positive z direction, with positive y pointing upwards.
38
39In addition to sound sources and a listener, you can define a geometry that influences how the
40sound is being experienced by the listener through a set of \l QAudioRoom objects. Rooms
41are rectangular and support a wide variety of materials for each wall giving a different experience
42with different sound reflections and reverb. Room effects will get applied if the listener is
43located inside one of the rooms. If he is inside multiple rooms, the room with the smallest
44geometrical volume will take precedence.
45
46If you need some stereo overlay that is independent of the position and orientation of
47the listener (such as background music or a voice-over), you can use
48\l QAmbientSound to create the sound overlay.
49
50For a small QWidget based example showcasing one audio source that can be moved around in a room, have
51a look at the \l {audiopanning}{Spacial Audio Panning Example}.
52
53\section1 Reference Documentation
54
55\section2 C++ Classes
56
57\annotatedlist spatialaudio
58
59\section2 QML Types
60
61\annotatedlist quick3d_spatialaudio
62
63*/