1/*
2Copyright 2018 Google Inc. All Rights Reserved.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS-IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17#ifndef RESONANCE_AUDIO_AMBISONICS_FOA_ROTATOR_H_
18#define RESONANCE_AUDIO_AMBISONICS_FOA_ROTATOR_H_
19
20#include "base/audio_buffer.h"
21#include "base/spherical_angle.h"
22
23namespace vraudio {
24
25// Rotator for first order ambisonic soundfields. It supports ACN channel
26// ordering and SN3D normalization (AmbiX).
27class FoaRotator {
28 public:
29 // @param target_rotation Target rotation to be applied to the input buffer.
30 // @param input First order soundfield input buffer to be rotated.
31 // @param output Pointer to output buffer.
32 // @return True if rotation has been applied.
33 bool Process(const WorldRotation& target_rotation, const AudioBuffer& input,
34 AudioBuffer* output);
35
36 private:
37 // Method which rotates a specified chunk of data in the AudioBuffer.
38 //
39 // @param target_rotation Target rotation to be applied to the soundfield.
40 // @param start_location Sample index in the soundfield where the rotation
41 // should begin.
42 // @param duration Number of samples in soundfield to be rotated.
43 // @param input First order soundfield input buffer to be rotated.
44 // @param output Pointer to output buffer.
45 void Rotate(const WorldRotation& target_rotation, size_t start_location,
46 size_t duration, const AudioBuffer& input, AudioBuffer* output);
47
48 // Current rotation which is used in the interpolation process in order to
49 // perform a smooth rotation. Initialized with an identity matrix.
50 WorldRotation current_rotation_;
51
52 // Preallocation of temporary variables used during rotation.
53 AudioPosition temp_audio_position_;
54 WorldPosition temp_world_position_;
55 AudioPosition temp_rotated_audio_position_;
56 WorldPosition temp_rotated_world_position_;
57};
58
59} // namespace vraudio
60
61#endif // RESONANCE_AUDIO_AMBISONICS_FOA_ROTATOR_H_
62

source code of qtmultimedia/src/3rdparty/resonance-audio/resonance_audio/ambisonics/foa_rotator.h