Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: Source/modules/webaudio/PannerNode.h

Issue 393363002: Move handle of HRTFDatabaseLoader to AudioListener. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update as review. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 10 matching lines...) Expand all
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24 24
25 #ifndef PannerNode_h 25 #ifndef PannerNode_h
26 #define PannerNode_h 26 #define PannerNode_h
27 27
28 #include "platform/audio/AudioBus.h" 28 #include "platform/audio/AudioBus.h"
29 #include "platform/audio/Cone.h" 29 #include "platform/audio/Cone.h"
30 #include "platform/audio/Distance.h" 30 #include "platform/audio/Distance.h"
31 #include "platform/audio/HRTFDatabaseLoader.h"
32 #include "platform/audio/Panner.h" 31 #include "platform/audio/Panner.h"
33 #include "modules/webaudio/AudioListener.h" 32 #include "modules/webaudio/AudioListener.h"
34 #include "modules/webaudio/AudioNode.h" 33 #include "modules/webaudio/AudioNode.h"
35 #include "platform/geometry/FloatPoint3D.h" 34 #include "platform/geometry/FloatPoint3D.h"
36 #include "wtf/HashMap.h" 35 #include "wtf/HashMap.h"
37 #include "wtf/OwnPtr.h" 36 #include "wtf/OwnPtr.h"
38 37
39 namespace WebCore { 38 namespace WebCore {
40 39
40 class HRTFDatabaseLoader;
41
41 // PannerNode is an AudioNode with one input and one output. 42 // PannerNode is an AudioNode with one input and one output.
42 // It positions a sound in 3D space, with the exact effect dependent on the pann ing model. 43 // It positions a sound in 3D space, with the exact effect dependent on the pann ing model.
43 // It has a position and an orientation in 3D space which is relative to the pos ition and orientation of the context's AudioListener. 44 // It has a position and an orientation in 3D space which is relative to the pos ition and orientation of the context's AudioListener.
44 // A distance effect will attenuate the gain as the position moves away from the listener. 45 // A distance effect will attenuate the gain as the position moves away from the listener.
45 // A cone effect will attenuate the gain as the orientation moves away from the listener. 46 // A cone effect will attenuate the gain as the orientation moves away from the listener.
46 // All of these effects follow the OpenAL specification very closely. 47 // All of these effects follow the OpenAL specification very closely.
47 48
48 class PannerNode FINAL : public AudioNode { 49 class PannerNode FINAL : public AudioNode {
49 public: 50 public:
50 // These enums are used to distinguish what cached values of panner are dirt y. 51 // These enums are used to distinguish what cached values of panner are dirt y.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 double dopplerRate(); 106 double dopplerRate();
106 107
107 virtual double tailTime() const OVERRIDE { return m_panner ? m_panner->tailT ime() : 0; } 108 virtual double tailTime() const OVERRIDE { return m_panner ? m_panner->tailT ime() : 0; }
108 virtual double latencyTime() const OVERRIDE { return m_panner ? m_panner->la tencyTime() : 0; } 109 virtual double latencyTime() const OVERRIDE { return m_panner ? m_panner->la tencyTime() : 0; }
109 110
110 private: 111 private:
111 PannerNode(AudioContext*, float sampleRate); 112 PannerNode(AudioContext*, float sampleRate);
112 113
113 // AudioContext's listener 114 // AudioContext's listener
114 AudioListener* listener(); 115 AudioListener* listener();
116 HRTFDatabaseLoader* hrtfDatabaseLoader() { return listener()->hrtfDatabaseLo ader(); }
115 117
116 bool setPanningModel(unsigned); // Returns true on success. 118 bool setPanningModel(unsigned); // Returns true on success.
117 bool setDistanceModel(unsigned); // Returns true on success. 119 bool setDistanceModel(unsigned); // Returns true on success.
118 120
119 void calculateAzimuthElevation(double* outAzimuth, double* outElevation); 121 void calculateAzimuthElevation(double* outAzimuth, double* outElevation);
120 float calculateDistanceConeGain(); // Returns the combined distance and cone gain attenuation. 122 float calculateDistanceConeGain(); // Returns the combined distance and cone gain attenuation.
121 double calculateDopplerRate(); 123 double calculateDopplerRate();
122 124
123 void azimuthElevation(double* outAzimuth, double* outElevation); 125 void azimuthElevation(double* outAzimuth, double* outElevation);
124 float distanceConeGain(); 126 float distanceConeGain();
(...skipping 23 matching lines...) Expand all
148 DistanceEffect m_distanceEffect; 150 DistanceEffect m_distanceEffect;
149 ConeEffect m_coneEffect; 151 ConeEffect m_coneEffect;
150 float m_lastGain; 152 float m_lastGain;
151 153
152 // Cached values 154 // Cached values
153 double m_cachedAzimuth; 155 double m_cachedAzimuth;
154 double m_cachedElevation; 156 double m_cachedElevation;
155 float m_cachedDistanceConeGain; 157 float m_cachedDistanceConeGain;
156 double m_cachedDopplerRate; 158 double m_cachedDopplerRate;
157 159
158 RefPtr<HRTFDatabaseLoader> m_hrtfDatabaseLoader;
159
160 // AudioContext's connection count 160 // AudioContext's connection count
161 unsigned m_connectionCount; 161 unsigned m_connectionCount;
162 162
163 // Synchronize process() with setting of the panning model, source's locatio n information, listener, distance parameters and sound cones. 163 // Synchronize process() with setting of the panning model, source's locatio n information, listener, distance parameters and sound cones.
164 mutable Mutex m_processLock; 164 mutable Mutex m_processLock;
165 }; 165 };
166 166
167 } // namespace WebCore 167 } // namespace WebCore
168 168
169 #endif // PannerNode_h 169 #endif // PannerNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698