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 23 matching lines...) Expand all Loading... |
34 #include "wtf/Noncopyable.h" | 34 #include "wtf/Noncopyable.h" |
35 #include "wtf/PtrUtil.h" | 35 #include "wtf/PtrUtil.h" |
36 #include "wtf/Vector.h" | 36 #include "wtf/Vector.h" |
37 #include <memory> | 37 #include <memory> |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 class AudioChannel; | 41 class AudioChannel; |
42 | 42 |
43 // HRTF stands for Head-Related Transfer Function. | 43 // HRTF stands for Head-Related Transfer Function. |
44 // HRTFKernel is a frequency-domain representation of an impulse-response used a
s part of the spatialized panning system. | 44 // HRTFKernel is a frequency-domain representation of an impulse-response used |
45 // For a given azimuth / elevation angle there will be one HRTFKernel for the le
ft ear transfer function, and one for the right ear. | 45 // as part of the spatialized panning system. For a given azimuth / elevation |
46 // The leading delay (average group delay) for each impulse response is extracte
d: | 46 // angle there will be one HRTFKernel for the left ear transfer function, and |
47 // m_fftFrame is the frequency-domain representation of the impulse respons
e with the delay removed | 47 // one for the right ear. The leading delay (average group delay) for each |
| 48 // impulse response is extracted: |
| 49 // m_fftFrame is the frequency-domain representation of the impulse |
| 50 // response with the delay removed |
48 // m_frameDelay is the leading delay of the original impulse response. | 51 // m_frameDelay is the leading delay of the original impulse response. |
49 class PLATFORM_EXPORT HRTFKernel { | 52 class PLATFORM_EXPORT HRTFKernel { |
50 USING_FAST_MALLOC(HRTFKernel); | 53 USING_FAST_MALLOC(HRTFKernel); |
51 WTF_MAKE_NONCOPYABLE(HRTFKernel); | 54 WTF_MAKE_NONCOPYABLE(HRTFKernel); |
52 | 55 |
53 public: | 56 public: |
54 // Note: this is destructive on the passed in AudioChannel. | 57 // Note: this is destructive on the passed in AudioChannel. |
55 // The length of channel must be a power of two. | 58 // The length of channel must be a power of two. |
56 static std::unique_ptr<HRTFKernel> create(AudioChannel* channel, | 59 static std::unique_ptr<HRTFKernel> create(AudioChannel* channel, |
57 size_t fftSize, | 60 size_t fftSize, |
58 float sampleRate) { | 61 float sampleRate) { |
59 return wrapUnique(new HRTFKernel(channel, fftSize, sampleRate)); | 62 return wrapUnique(new HRTFKernel(channel, fftSize, sampleRate)); |
60 } | 63 } |
61 | 64 |
62 static std::unique_ptr<HRTFKernel> create(std::unique_ptr<FFTFrame> fftFrame, | 65 static std::unique_ptr<HRTFKernel> create(std::unique_ptr<FFTFrame> fftFrame, |
63 float frameDelay, | 66 float frameDelay, |
64 float sampleRate) { | 67 float sampleRate) { |
65 return wrapUnique( | 68 return wrapUnique( |
66 new HRTFKernel(std::move(fftFrame), frameDelay, sampleRate)); | 69 new HRTFKernel(std::move(fftFrame), frameDelay, sampleRate)); |
67 } | 70 } |
68 | 71 |
69 // Given two HRTFKernels, and an interpolation factor x: 0 -> 1, returns an in
terpolated HRTFKernel. | 72 // Given two HRTFKernels, and an interpolation factor x: 0 -> 1, returns an |
| 73 // interpolated HRTFKernel. |
70 static std::unique_ptr<HRTFKernel> | 74 static std::unique_ptr<HRTFKernel> |
71 createInterpolatedKernel(HRTFKernel* kernel1, HRTFKernel* kernel2, float x); | 75 createInterpolatedKernel(HRTFKernel* kernel1, HRTFKernel* kernel2, float x); |
72 | 76 |
73 FFTFrame* fftFrame() { return m_fftFrame.get(); } | 77 FFTFrame* fftFrame() { return m_fftFrame.get(); } |
74 | 78 |
75 size_t fftSize() const { return m_fftFrame->fftSize(); } | 79 size_t fftSize() const { return m_fftFrame->fftSize(); } |
76 float frameDelay() const { return m_frameDelay; } | 80 float frameDelay() const { return m_frameDelay; } |
77 | 81 |
78 float sampleRate() const { return m_sampleRate; } | 82 float sampleRate() const { return m_sampleRate; } |
79 double nyquist() const { return 0.5 * sampleRate(); } | 83 double nyquist() const { return 0.5 * sampleRate(); } |
(...skipping 15 matching lines...) Expand all Loading... |
95 std::unique_ptr<FFTFrame> m_fftFrame; | 99 std::unique_ptr<FFTFrame> m_fftFrame; |
96 float m_frameDelay; | 100 float m_frameDelay; |
97 float m_sampleRate; | 101 float m_sampleRate; |
98 }; | 102 }; |
99 | 103 |
100 typedef Vector<std::unique_ptr<HRTFKernel>> HRTFKernelList; | 104 typedef Vector<std::unique_ptr<HRTFKernel>> HRTFKernelList; |
101 | 105 |
102 } // namespace blink | 106 } // namespace blink |
103 | 107 |
104 #endif // HRTFKernel_h | 108 #endif // HRTFKernel_h |
OLD | NEW |