| 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 22 matching lines...) Expand all Loading... |
| 33 #include "wtf/Allocator.h" | 33 #include "wtf/Allocator.h" |
| 34 #include "wtf/Noncopyable.h" | 34 #include "wtf/Noncopyable.h" |
| 35 #include "wtf/PassRefPtr.h" | 35 #include "wtf/PassRefPtr.h" |
| 36 #include "wtf/RefPtr.h" | 36 #include "wtf/RefPtr.h" |
| 37 #include "wtf/text/CString.h" | 37 #include "wtf/text/CString.h" |
| 38 #include "wtf/text/WTFString.h" | 38 #include "wtf/text/WTFString.h" |
| 39 #include <memory> | 39 #include <memory> |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 // HRTFElevation contains all of the HRTFKernels (one left ear and one right ear
per azimuth angle) for a particular elevation. | 43 // HRTFElevation contains all of the HRTFKernels (one left ear and one right ear |
| 44 // per azimuth angle) for a particular elevation. |
| 44 | 45 |
| 45 class PLATFORM_EXPORT HRTFElevation { | 46 class PLATFORM_EXPORT HRTFElevation { |
| 46 USING_FAST_MALLOC(HRTFElevation); | 47 USING_FAST_MALLOC(HRTFElevation); |
| 47 WTF_MAKE_NONCOPYABLE(HRTFElevation); | 48 WTF_MAKE_NONCOPYABLE(HRTFElevation); |
| 48 | 49 |
| 49 public: | 50 public: |
| 50 // Loads and returns an HRTFElevation with the given HRTF database subject nam
e and elevation from browser (or WebKit.framework) resources. | 51 // Loads and returns an HRTFElevation with the given HRTF database subject |
| 51 // Normally, there will only be a single HRTF database set, but this API suppo
rts the possibility of multiple ones with different names. | 52 // name and elevation from browser (or WebKit.framework) resources. |
| 53 // Normally, there will only be a single HRTF database set, but this API |
| 54 // supports the possibility of multiple ones with different names. |
| 52 // Interpolated azimuths will be generated based on InterpolationFactor. | 55 // Interpolated azimuths will be generated based on InterpolationFactor. |
| 53 // Valid values for elevation are -45 -> +90 in 15 degree increments. | 56 // Valid values for elevation are -45 -> +90 in 15 degree increments. |
| 54 static std::unique_ptr<HRTFElevation> | 57 static std::unique_ptr<HRTFElevation> |
| 55 createForSubject(const String& subjectName, int elevation, float sampleRate); | 58 createForSubject(const String& subjectName, int elevation, float sampleRate); |
| 56 | 59 |
| 57 // Given two HRTFElevations, and an interpolation factor x: 0 -> 1, returns an
interpolated HRTFElevation. | 60 // Given two HRTFElevations, and an interpolation factor x: 0 -> 1, returns an |
| 61 // interpolated HRTFElevation. |
| 58 static std::unique_ptr<HRTFElevation> createByInterpolatingSlices( | 62 static std::unique_ptr<HRTFElevation> createByInterpolatingSlices( |
| 59 HRTFElevation* hrtfElevation1, | 63 HRTFElevation* hrtfElevation1, |
| 60 HRTFElevation* hrtfElevation2, | 64 HRTFElevation* hrtfElevation2, |
| 61 float x, | 65 float x, |
| 62 float sampleRate); | 66 float sampleRate); |
| 63 | 67 |
| 64 // Returns the list of left or right ear HRTFKernels for all the azimuths goin
g from 0 to 360 degrees. | 68 // Returns the list of left or right ear HRTFKernels for all the azimuths |
| 69 // going from 0 to 360 degrees. |
| 65 HRTFKernelList* kernelListL() { return m_kernelListL.get(); } | 70 HRTFKernelList* kernelListL() { return m_kernelListL.get(); } |
| 66 HRTFKernelList* kernelListR() { return m_kernelListR.get(); } | 71 HRTFKernelList* kernelListR() { return m_kernelListR.get(); } |
| 67 | 72 |
| 68 double elevationAngle() const { return m_elevationAngle; } | 73 double elevationAngle() const { return m_elevationAngle; } |
| 69 unsigned numberOfAzimuths() const { return NumberOfTotalAzimuths; } | 74 unsigned numberOfAzimuths() const { return NumberOfTotalAzimuths; } |
| 70 float sampleRate() const { return m_sampleRate; } | 75 float sampleRate() const { return m_sampleRate; } |
| 71 | 76 |
| 72 // Returns the left and right kernels for the given azimuth index. | 77 // Returns the left and right kernels for the given azimuth index. |
| 73 // The interpolated delays based on azimuthBlend: 0 -> 1 are returned in frame
DelayL and frameDelayR. | 78 // The interpolated delays based on azimuthBlend: 0 -> 1 are returned in |
| 79 // frameDelayL and frameDelayR. |
| 74 void getKernelsFromAzimuth(double azimuthBlend, | 80 void getKernelsFromAzimuth(double azimuthBlend, |
| 75 unsigned azimuthIndex, | 81 unsigned azimuthIndex, |
| 76 HRTFKernel*& kernelL, | 82 HRTFKernel*& kernelL, |
| 77 HRTFKernel*& kernelR, | 83 HRTFKernel*& kernelR, |
| 78 double& frameDelayL, | 84 double& frameDelayL, |
| 79 double& frameDelayR); | 85 double& frameDelayR); |
| 80 | 86 |
| 81 // Spacing, in degrees, between every azimuth loaded from resource. | 87 // Spacing, in degrees, between every azimuth loaded from resource. |
| 82 static const unsigned AzimuthSpacing; | 88 static const unsigned AzimuthSpacing; |
| 83 | 89 |
| 84 // Number of azimuths loaded from resource. | 90 // Number of azimuths loaded from resource. |
| 85 static const unsigned NumberOfRawAzimuths; | 91 static const unsigned NumberOfRawAzimuths; |
| 86 | 92 |
| 87 // Interpolates by this factor to get the total number of azimuths from every
azimuth loaded from resource. | 93 // Interpolates by this factor to get the total number of azimuths from every |
| 94 // azimuth loaded from resource. |
| 88 static const unsigned InterpolationFactor; | 95 static const unsigned InterpolationFactor; |
| 89 | 96 |
| 90 // Total number of azimuths after interpolation. | 97 // Total number of azimuths after interpolation. |
| 91 static const unsigned NumberOfTotalAzimuths; | 98 static const unsigned NumberOfTotalAzimuths; |
| 92 | 99 |
| 93 // Given a specific azimuth and elevation angle, returns the left and right HR
TFKernel. | 100 // Given a specific azimuth and elevation angle, returns the left and right |
| 101 // HRTFKernel. |
| 94 // Valid values for azimuth are 0 -> 345 in 15 degree increments. | 102 // Valid values for azimuth are 0 -> 345 in 15 degree increments. |
| 95 // Valid values for elevation are -45 -> +90 in 15 degree increments. | 103 // Valid values for elevation are -45 -> +90 in 15 degree increments. |
| 96 // Returns true on success. | 104 // Returns true on success. |
| 97 static bool calculateKernelsForAzimuthElevation( | 105 static bool calculateKernelsForAzimuthElevation( |
| 98 int azimuth, | 106 int azimuth, |
| 99 int elevation, | 107 int elevation, |
| 100 float sampleRate, | 108 float sampleRate, |
| 101 const String& subjectName, | 109 const String& subjectName, |
| 102 std::unique_ptr<HRTFKernel>& kernelL, | 110 std::unique_ptr<HRTFKernel>& kernelL, |
| 103 std::unique_ptr<HRTFKernel>& kernelR); | 111 std::unique_ptr<HRTFKernel>& kernelR); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 114 | 122 |
| 115 std::unique_ptr<HRTFKernelList> m_kernelListL; | 123 std::unique_ptr<HRTFKernelList> m_kernelListL; |
| 116 std::unique_ptr<HRTFKernelList> m_kernelListR; | 124 std::unique_ptr<HRTFKernelList> m_kernelListR; |
| 117 double m_elevationAngle; | 125 double m_elevationAngle; |
| 118 float m_sampleRate; | 126 float m_sampleRate; |
| 119 }; | 127 }; |
| 120 | 128 |
| 121 } // namespace blink | 129 } // namespace blink |
| 122 | 130 |
| 123 #endif // HRTFElevation_h | 131 #endif // HRTFElevation_h |
| OLD | NEW |