OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 16 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE |
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 23 * DAMAGE. |
23 */ | 24 */ |
24 | 25 |
25 #ifndef HRTFPanner_h | 26 #ifndef HRTFPanner_h |
26 #define HRTFPanner_h | 27 #define HRTFPanner_h |
27 | 28 |
28 #include "platform/audio/AudioDelayDSPKernel.h" | 29 #include "platform/audio/AudioDelayDSPKernel.h" |
29 #include "platform/audio/FFTConvolver.h" | 30 #include "platform/audio/FFTConvolver.h" |
30 #include "platform/audio/HRTFDatabaseLoader.h" | 31 #include "platform/audio/HRTFDatabaseLoader.h" |
31 #include "platform/audio/Panner.h" | 32 #include "platform/audio/Panner.h" |
32 | 33 |
(...skipping 22 matching lines...) Expand all Loading... |
55 | 56 |
56 size_t fftSize() const { return fftSizeForSampleRate(m_sampleRate); } | 57 size_t fftSize() const { return fftSizeForSampleRate(m_sampleRate); } |
57 static size_t fftSizeForSampleRate(float sampleRate); | 58 static size_t fftSizeForSampleRate(float sampleRate); |
58 | 59 |
59 float sampleRate() const { return m_sampleRate; } | 60 float sampleRate() const { return m_sampleRate; } |
60 | 61 |
61 double tailTime() const override; | 62 double tailTime() const override; |
62 double latencyTime() const override; | 63 double latencyTime() const override; |
63 | 64 |
64 private: | 65 private: |
65 // Given an azimuth angle in the range -180 -> +180, returns the corresponding
azimuth index for the database, | 66 // Given an azimuth angle in the range -180 -> +180, returns the corresponding |
66 // and azimuthBlend which is an interpolation value from 0 -> 1. | 67 // azimuth index for the database, and azimuthBlend which is an interpolation |
| 68 // value from 0 -> 1. |
67 int calculateDesiredAzimuthIndexAndBlend(double azimuth, | 69 int calculateDesiredAzimuthIndexAndBlend(double azimuth, |
68 double& azimuthBlend); | 70 double& azimuthBlend); |
69 | 71 |
70 RefPtr<HRTFDatabaseLoader> m_databaseLoader; | 72 RefPtr<HRTFDatabaseLoader> m_databaseLoader; |
71 | 73 |
72 float m_sampleRate; | 74 float m_sampleRate; |
73 | 75 |
74 // We maintain two sets of convolvers for smooth cross-faded interpolations wh
en | 76 // We maintain two sets of convolvers for smooth cross-faded interpolations |
75 // then azimuth and elevation are dynamically changing. | 77 // when then azimuth and elevation are dynamically changing. When the |
76 // When the azimuth and elevation are not changing, we simply process with one
of the two sets. | 78 // azimuth and elevation are not changing, we simply process with one |
77 // Initially we use CrossfadeSelection1 corresponding to m_convolverL1 and m_c
onvolverR1. | 79 // of the two sets. Initially we use CrossfadeSelection1 corresponding to |
78 // Whenever the azimuth or elevation changes, a crossfade is initiated to tran
sition | 80 // m_convolverL1 and m_convolverR1. Whenever the azimuth or elevation |
79 // to the new position. So if we're currently processing with CrossfadeSelecti
on1, then | 81 // changes, a crossfade is initiated to transition to the new position. So if |
80 // we transition to CrossfadeSelection2 (and vice versa). | 82 // we're currently processing with CrossfadeSelection1, then we transition to |
81 // If we're in the middle of a transition, then we wait until it is complete b
efore | 83 // CrossfadeSelection2 (and vice versa). If we're in the middle of a |
82 // initiating a new transition. | 84 // transition, then we wait until it is complete before initiating a new |
| 85 // transition. |
83 | 86 |
84 // Selects either the convolver set (m_convolverL1, m_convolverR1) or (m_convo
lverL2, m_convolverR2). | 87 // Selects either the convolver set (m_convolverL1, m_convolverR1) or |
| 88 // (m_convolverL2, m_convolverR2). |
85 enum CrossfadeSelection { CrossfadeSelection1, CrossfadeSelection2 }; | 89 enum CrossfadeSelection { CrossfadeSelection1, CrossfadeSelection2 }; |
86 | 90 |
87 CrossfadeSelection m_crossfadeSelection; | 91 CrossfadeSelection m_crossfadeSelection; |
88 | 92 |
89 // azimuth/elevation for CrossfadeSelection1. | 93 // azimuth/elevation for CrossfadeSelection1. |
90 int m_azimuthIndex1; | 94 int m_azimuthIndex1; |
91 double m_elevation1; | 95 double m_elevation1; |
92 | 96 |
93 // azimuth/elevation for CrossfadeSelection2. | 97 // azimuth/elevation for CrossfadeSelection2. |
94 int m_azimuthIndex2; | 98 int m_azimuthIndex2; |
(...skipping 15 matching lines...) Expand all Loading... |
110 | 114 |
111 AudioFloatArray m_tempL1; | 115 AudioFloatArray m_tempL1; |
112 AudioFloatArray m_tempR1; | 116 AudioFloatArray m_tempR1; |
113 AudioFloatArray m_tempL2; | 117 AudioFloatArray m_tempL2; |
114 AudioFloatArray m_tempR2; | 118 AudioFloatArray m_tempR2; |
115 }; | 119 }; |
116 | 120 |
117 } // namespace blink | 121 } // namespace blink |
118 | 122 |
119 #endif // HRTFPanner_h | 123 #endif // HRTFPanner_h |
OLD | NEW |