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#ifndef QAMBISONICDECODER_P_H
4#define QAMBISONICDECODER_P_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17#include <qtspatialaudioglobal_p.h>
18#include <qaudioformat.h>
19
20QT_BEGIN_NAMESPACE
21
22struct QAmbisonicDecoderData;
23class QAmbisonicDecoderFilter;
24
25class QAmbisonicDecoder
26{
27public:
28 enum AmbisonicLevel
29 {
30 AmbisonicLevel1 = 1,
31 LowQuality = AmbisonicLevel1,
32 AmbisonicLevel2 = 2,
33 MediumQuality = AmbisonicLevel2,
34 AmbisonicLevel3 = 3,
35 HighQuality = AmbisonicLevel3
36 };
37 QAmbisonicDecoder(AmbisonicLevel ambisonicLevel, const QAudioFormat &format);
38 ~QAmbisonicDecoder();
39
40 bool hasValidConfig() const { return outputChannels > 0; }
41
42 int nInputChannels() const { return inputChannels; }
43 int nOutputChannels() const { return outputChannels; }
44
45 int outputSize(int nSamples) const { return outputChannels * nSamples; }
46
47 // input is planar, output interleaved
48 void processBuffer(const float *input[], float *output, int nSamples);
49 void processBuffer(const float *input[], short *output, int nSamples);
50
51 void processBufferWithReverb(const float *input[], const float *reverb[2], short *output, int nSamples);
52
53 static constexpr int maxAmbisonicChannels = 16;
54 static constexpr int maxAmbisonicLevel = 3;
55private:
56 QAudioFormat::ChannelConfig channelConfig;
57 AmbisonicLevel level = AmbisonicLevel1;
58 int inputChannels = 0;
59 int outputChannels = 0;
60 const QAmbisonicDecoderData *decoderData = nullptr;
61 QAmbisonicDecoderFilter *filters = nullptr;
62 float *simpleDecoderFactors = nullptr;
63 const float *reverbFactors = nullptr;
64};
65
66
67QT_END_NAMESPACE
68
69#endif
70

source code of qtmultimedia/src/spatialaudio/qambisonicdecoder_p.h