RavEngine
Loading...
Searching...
No Matches
acoustic_listener.h
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_GEOMETRICAL_ACOUSTICS_ACOUSTIC_LISTENER_H_
18#define RESONANCE_AUDIO_GEOMETRICAL_ACOUSTICS_ACOUSTIC_LISTENER_H_
19
20#include <array>
21#include <cstddef>
22#include <vector>
23
24#include "Eigen/Core"
25#include "base/constants_and_types.h"
26
27namespace vraudio {
29 // Constructor.
30 //
31 // @param listener_position Position of the listener.
32 // @param impulse_response_length Number of samples in the energy impulse
33 // response for each frequency band.
34 AcousticListener(const Eigen::Vector3f& listener_position,
35 size_t impulse_response_length)
36 : position(listener_position) {
37 for (size_t i = 0; i < kNumReverbOctaveBands; ++i) {
38 energy_impulse_responses[i] =
39 std::vector<float>(impulse_response_length, 0.0f);
40 }
41 }
42
43 const Eigen::Vector3f position;
44
45 // Impulse responses in terms of energies for all frequency bands.
46 // Need to take square roots before applying it to an input signal, which
47 // models pressure. The reason we store response in energy instead of in
48 // pressure is because the geometrical acoustics computation is energy-based,
49 // and the following kind of operations are performed extensively:
50 // energy_impulse_responses[i][t] += <energy contribution from a ray>.
51 std::array<std::vector<float>, kNumReverbOctaveBands>
52 energy_impulse_responses;
53};
54
55} // namespace vraudio
56
57#endif // RESONANCE_AUDIO_GEOMETRICAL_ACOUSTICS_ACOUSTIC_LISTENER_H_
Definition acoustic_listener.h:28