OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef StereoPanner_h | 5 #ifndef StereoPanner_h |
6 #define StereoPanner_h | 6 #define StereoPanner_h |
7 | 7 |
8 #include "platform/audio/Spatializer.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "wtf/Allocator.h" |
| 10 #include "wtf/Noncopyable.h" |
9 | 11 |
10 namespace blink { | 12 namespace blink { |
11 | 13 |
12 // Common type of stereo panner as found in normal audio mixing equipment. | 14 class AudioBus; |
13 // See: http://webaudio.github.io/web-audio-api/#the-stereopannernode-interface | |
14 | 15 |
15 class PLATFORM_EXPORT StereoPanner final : public Spatializer { | 16 // Implement the equal-power panning algorithm for mono or stereo input. See: |
| 17 // https://webaudio.github.io/web-audio-api/#Spatialzation-equal-power-panning |
| 18 |
| 19 class PLATFORM_EXPORT StereoPanner { |
| 20 USING_FAST_MALLOC(StereoPanner); |
| 21 WTF_MAKE_NONCOPYABLE(StereoPanner); |
| 22 |
16 public: | 23 public: |
| 24 static std::unique_ptr<StereoPanner> create(float sampleRate); |
| 25 ~StereoPanner() { }; |
| 26 |
| 27 void panWithSampleAccurateValues(const AudioBus* inputBus, AudioBus* outputB
us, const float* panValues, size_t framesToProcess); |
| 28 void panToTargetValue(const AudioBus* inputBus, AudioBus* outputBus, float p
anValue, size_t framesToProcess); |
| 29 |
| 30 private: |
17 explicit StereoPanner(float sampleRate); | 31 explicit StereoPanner(float sampleRate); |
18 | 32 |
19 void panWithSampleAccurateValues(const AudioBus* inputBus, AudioBus* outputB
uf, const float* panValues, size_t framesToProcess) override; | |
20 void panToTargetValue(const AudioBus* inputBus, AudioBus* outputBuf, float p
anValue, size_t framesToProcess) override; | |
21 | |
22 void reset() override { } | |
23 | |
24 double tailTime() const override { return 0; } | |
25 double latencyTime() const override { return 0; } | |
26 | |
27 private: | |
28 bool m_isFirstRender; | 33 bool m_isFirstRender; |
29 double m_smoothingConstant; | 34 double m_smoothingConstant; |
30 | 35 |
31 double m_pan; | 36 double m_pan; |
32 }; | 37 }; |
33 | 38 |
34 } // namespace blink | 39 } // namespace blink |
35 | 40 |
36 #endif // StereoPanner_h | 41 #endif // StereoPanner_h |
OLD | NEW |