1 | /* |
2 | Copyright 2018 Google Inc. All Rights Reserved. |
3 | |
4 | Licensed under the Apache License, Version 2.0 (the "License"); |
5 | you may not use this file except in compliance with the License. |
6 | You may obtain a copy of the License at |
7 | |
8 | http://www.apache.org/licenses/LICENSE-2.0 |
9 | |
10 | Unless required by applicable law or agreed to in writing, software |
11 | distributed under the License is distributed on an "AS-IS" BASIS, |
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | See the License for the specific language governing permissions and |
14 | limitations under the License. |
15 | */ |
16 | |
17 | #ifndef RESONANCE_AUDIO_DSP_SH_HRIR_CREATOR_H_ |
18 | #define RESONANCE_AUDIO_DSP_SH_HRIR_CREATOR_H_ |
19 | |
20 | #include "base/audio_buffer.h" |
21 | #include "dsp/resampler.h" |
22 | #include "utils/wav.h" |
23 | |
24 | namespace vraudio { |
25 | |
26 | // Creates a multichannel audio buffer of Spherical Harmonic-encoded Head |
27 | // Related Impulse Responses (SH HRIRs) from Wav SH HRIR assets. It also |
28 | // checks if the channel count of the SH HRIR file is correct and resamples the |
29 | // SH HRIRs if necessary to match the system (target) sampling rate. |
30 | // |
31 | // @param wav |Wav| instance that contains SH HRIRs. |
32 | // @param target_sample_rate_hz Target sampling rate in Hertz. |
33 | // @param resampler Pointer to a resampler used to convert HRIRs to the system |
34 | // rate, |
35 | // (This resampler's internal state will be reset on each function call). |
36 | // @return Unique pointer to |AudioBuffer| where the SH HRIRs will be written. |
37 | std::unique_ptr<AudioBuffer> CreateShHrirsFromWav(const Wav& wav, |
38 | int target_sample_rate_hz, |
39 | Resampler* resampler); |
40 | |
41 | // Creates a SH HRIR multichannel audio buffer from assets. |
42 | // |
43 | // @param filename Name of the Wav file that contains SH HRIRs. |
44 | // @param target_sample_rate_hz Target sampling rate in Hertz. |
45 | // @param resampler Pointer to a resampler used to convert HRIRs to the system |
46 | // rate. |
47 | // @return Unique pointer to |AudioBuffer| where the SH HRIRs will be written. |
48 | std::unique_ptr<AudioBuffer> CreateShHrirsFromAssets( |
49 | const std::string& filename, int target_sample_rate_hz, |
50 | Resampler* resampler); |
51 | |
52 | } // namespace vraudio |
53 | |
54 | #endif // RESONANCE_AUDIO_DSP_SH_HRIR_CREATOR_H_ |
55 | |