Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquick3daudiolistener.cpp
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-3.0-only
3#include <qquick3daudiolistener_p.h>
4#include <qquick3dspatialsound_p.h>
5#include <qquick3daudioengine_p.h>
6
8
9/*!
10 \qmltype AudioListener
11 \inqmlmodule QtQuick3D.SpatialAudio
12 \ingroup quick3d_spatialaudio
13 \ingroup multimedia_audio_qml
14
15 \brief defines the position and orientation of the person listening to a sound field
16 defined by a AudioEngine.
17
18 A AudioEngine can have exactly one listener, that defines the position and orientation
19 of the person listening to the sounds defined by the objects placed within the audio engine.
20
21 In most cases, the AudioListener should simply be a child of the Camera element in QtQuick3D.
22 This will ensure that the sound experience is aligned with the visual rendering of the scene.
23 */
24
25QQuick3DAudioListener::QQuick3DAudioListener()
26{
27 m_listener = new QAudioListener(QQuick3DAudioEngine::getEngine());
28 connect(this, &QQuick3DNode::scenePositionChanged, this, &QQuick3DAudioListener::updatePosition);
29 connect(this, &QQuick3DNode::sceneRotationChanged, this, &QQuick3DAudioListener::updateRotation);
30 updatePosition();
31 updateRotation();
32}
33
35{
36 delete m_listener;
37}
38
39void QQuick3DAudioListener::updatePosition()
40{
41 m_listener->setPosition(scenePosition());
42}
43
45{
46 m_listener->setRotation(sceneRotation());
47}
48
49QT_END_NAMESPACE