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 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 14 matching lines...) Expand all Loading... |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #include "config.h" | 29 #include "config.h" |
30 | 30 |
31 #if ENABLE(WEB_AUDIO) | 31 #if ENABLE(WEB_AUDIO) |
32 | 32 |
33 #include "platform/audio/HRTFDatabase.h" | 33 #include "platform/audio/HRTFDatabase.h" |
34 | 34 |
35 | |
36 using namespace std; | |
37 | |
38 namespace blink { | 35 namespace blink { |
39 | 36 |
40 const int HRTFDatabase::MinElevation = -45; | 37 const int HRTFDatabase::MinElevation = -45; |
41 const int HRTFDatabase::MaxElevation = 90; | 38 const int HRTFDatabase::MaxElevation = 90; |
42 const unsigned HRTFDatabase::RawElevationAngleSpacing = 15; | 39 const unsigned HRTFDatabase::RawElevationAngleSpacing = 15; |
43 const unsigned HRTFDatabase::NumberOfRawElevations = 10; // -45 -> +90 (each 15
degrees) | 40 const unsigned HRTFDatabase::NumberOfRawElevations = 10; // -45 -> +90 (each 15
degrees) |
44 const unsigned HRTFDatabase::InterpolationFactor = 1; | 41 const unsigned HRTFDatabase::InterpolationFactor = 1; |
45 const unsigned HRTFDatabase::NumberOfTotalElevations = NumberOfRawElevations * I
nterpolationFactor; | 42 const unsigned HRTFDatabase::NumberOfTotalElevations = NumberOfRawElevations * I
nterpolationFactor; |
46 | 43 |
47 PassOwnPtr<HRTFDatabase> HRTFDatabase::create(float sampleRate) | 44 PassOwnPtr<HRTFDatabase> HRTFDatabase::create(float sampleRate) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 kernelR = 0; | 101 kernelR = 0; |
105 return; | 102 return; |
106 } | 103 } |
107 | 104 |
108 hrtfElevation->getKernelsFromAzimuth(azimuthBlend, azimuthIndex, kernelL, ke
rnelR, frameDelayL, frameDelayR); | 105 hrtfElevation->getKernelsFromAzimuth(azimuthBlend, azimuthIndex, kernelL, ke
rnelR, frameDelayL, frameDelayR); |
109 } | 106 } |
110 | 107 |
111 unsigned HRTFDatabase::indexFromElevationAngle(double elevationAngle) | 108 unsigned HRTFDatabase::indexFromElevationAngle(double elevationAngle) |
112 { | 109 { |
113 // Clamp to allowed range. | 110 // Clamp to allowed range. |
114 elevationAngle = max(static_cast<double>(MinElevation), elevationAngle); | 111 elevationAngle = std::max(static_cast<double>(MinElevation), elevationAngle)
; |
115 elevationAngle = min(static_cast<double>(MaxElevation), elevationAngle); | 112 elevationAngle = std::min(static_cast<double>(MaxElevation), elevationAngle)
; |
116 | 113 |
117 unsigned elevationIndex = static_cast<int>(InterpolationFactor * (elevationA
ngle - MinElevation) / RawElevationAngleSpacing); | 114 unsigned elevationIndex = static_cast<int>(InterpolationFactor * (elevationA
ngle - MinElevation) / RawElevationAngleSpacing); |
118 return elevationIndex; | 115 return elevationIndex; |
119 } | 116 } |
120 | 117 |
121 } // namespace blink | 118 } // namespace blink |
122 | 119 |
123 #endif // ENABLE(WEB_AUDIO) | 120 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |