diff options
author | Lars Knoll <lars.knoll@qt.io> | 2022-04-25 19:14:20 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2022-05-11 08:23:54 +0200 |
commit | e610585d68b3ec6d655335fbf29eaafc94a6fbf8 (patch) | |
tree | 5d611f7ccf915695d9b5283c00508692d7791e5c /src/resonance-audio | |
parent | b1b8e01954934a866a7fd765fc0ae91993c64329 (diff) |
Hook up the ambisonic decoder to the spatial audio module
This should give us proper 5.1/7.1 audio output for spatial audio.
Partly untested, as I do not have a 5.1/7.1 system I can test with.
Change-Id: Idad969641eb798607dc949e13908502b9afaf645
Reviewed-by: Rafael Roquetto <rafael.roquetto@qt.io>
Diffstat (limited to 'src/resonance-audio')
-rw-r--r-- | src/resonance-audio/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/resonance-audio/resonance_audio_api_extensions.cpp | 58 | ||||
-rw-r--r-- | src/resonance-audio/resonance_audio_api_extensions.h | 49 |
3 files changed, 108 insertions, 0 deletions
diff --git a/src/resonance-audio/CMakeLists.txt b/src/resonance-audio/CMakeLists.txt index 291b136df..cee0b980c 100644 --- a/src/resonance-audio/CMakeLists.txt +++ b/src/resonance-audio/CMakeLists.txt @@ -203,6 +203,7 @@ qt_internal_add_3rdparty_library(BundledResonanceAudio ${RA_SOURCES} ${PFFFT_SOURCE} ${SADIE_HRTFS_SOURCE} + resonance_audio_api_extensions.h resonance_audio_api_extensions.cpp INCLUDE_DIRECTORIES ${RA_TOPLEVEL_DIR} ${RA_SOURCE_DIR} diff --git a/src/resonance-audio/resonance_audio_api_extensions.cpp b/src/resonance-audio/resonance_audio_api_extensions.cpp new file mode 100644 index 000000000..46009f64b --- /dev/null +++ b/src/resonance-audio/resonance_audio_api_extensions.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Spatial Audio module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL-NOGPL2$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "resonance_audio_api_extensions.h" +#include "graph/resonance_audio_api_impl.h" + +namespace vraudio +{ + +int getAmbisonicOutput(ResonanceAudioApi *api, const float *buffers[], int nChannels) +{ + ResonanceAudioApiImpl *impl = static_cast<ResonanceAudioApiImpl *>(api); + + impl->ProcessNextBuffer(); + auto *buffer = impl->GetAmbisonicOutputBuffer(); + if (nChannels != buffer->num_channels()) + return -1; + + for (int i = 0; i < nChannels; ++i) { + buffers[i] = buffer->begin()[i].begin(); + } + return buffer->num_frames(); +} + +} diff --git a/src/resonance-audio/resonance_audio_api_extensions.h b/src/resonance-audio/resonance_audio_api_extensions.h new file mode 100644 index 000000000..2c26c0911 --- /dev/null +++ b/src/resonance-audio/resonance_audio_api_extensions.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Spatial Audio module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL-NOGPL2$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef RESONANCE_AUDIO_API_EXTENSIONS_H +#define RESONANCE_AUDIO_API_EXTENSIONS_H + +#include <api/resonance_audio_api.h> + +namespace vraudio +{ + +EXPORT_API int getAmbisonicOutput(ResonanceAudioApi *api, const float *buffers[], int nChannels); + +} + +#endif |