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

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

Issue 189143010: Cache values for panning and spatialization effects to enhance performance on pannerNode. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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
« no previous file with comments | « no previous file | Source/modules/webaudio/PannerNode.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 virtual ~PannerNode(); 70 virtual ~PannerNode();
71 71
72 // AudioNode 72 // AudioNode
73 virtual void process(size_t framesToProcess) OVERRIDE; 73 virtual void process(size_t framesToProcess) OVERRIDE;
74 virtual void pullInputs(size_t framesToProcess) OVERRIDE; 74 virtual void pullInputs(size_t framesToProcess) OVERRIDE;
75 virtual void initialize() OVERRIDE; 75 virtual void initialize() OVERRIDE;
76 virtual void uninitialize() OVERRIDE; 76 virtual void uninitialize() OVERRIDE;
77 77
78 // Listener 78 // AudioContext's listener
79 AudioListener* listener(); 79 AudioListener* listener();
80 80
81 // Panning model 81 // Panning model
82 String panningModel() const; 82 String panningModel() const;
83 bool setPanningModel(unsigned); // Returns true on success. 83 bool setPanningModel(unsigned); // Returns true on success.
84 void setPanningModel(const String&); 84 void setPanningModel(const String&);
85 85
86 // Position 86 // Position
87 void setPosition(float x, float y, float z) { m_position = FloatPoint3D(x, y , z); } 87 void setPosition(float x, float y, float z);
88 88
89 // Orientation 89 // Orientation
90 void setOrientation(float x, float y, float z) { m_orientation = FloatPoint3 D(x, y, z); } 90 void setOrientation(float x, float y, float z);
91 91
92 // Velocity 92 // Velocity
93 void setVelocity(float x, float y, float z) { m_velocity = FloatPoint3D(x, y , z); } 93 void setVelocity(float x, float y, float z);
94 94
95 // Distance parameters 95 // Distance parameters
96 String distanceModel() const; 96 String distanceModel() const;
97 bool setDistanceModel(unsigned); // Returns true on success. 97 bool setDistanceModel(unsigned); // Returns true on success.
98 void setDistanceModel(const String&); 98 void setDistanceModel(const String&);
99 99
100 double refDistance() { return m_distanceEffect.refDistance(); } 100 double refDistance() { return m_distanceEffect.refDistance(); }
101 void setRefDistance(double refDistance) { m_distanceEffect.setRefDistance(re fDistance); } 101 void setRefDistance(double refDistance) { m_distanceEffect.setRefDistance(re fDistance); }
102 102
103 double maxDistance() { return m_distanceEffect.maxDistance(); } 103 double maxDistance() { return m_distanceEffect.maxDistance(); }
104 void setMaxDistance(double maxDistance) { m_distanceEffect.setMaxDistance(ma xDistance); } 104 void setMaxDistance(double maxDistance) { m_distanceEffect.setMaxDistance(ma xDistance); }
105 105
106 double rolloffFactor() { return m_distanceEffect.rolloffFactor(); } 106 double rolloffFactor() { return m_distanceEffect.rolloffFactor(); }
107 void setRolloffFactor(double rolloffFactor) { m_distanceEffect.setRolloffFac tor(rolloffFactor); } 107 void setRolloffFactor(double rolloffFactor) { m_distanceEffect.setRolloffFac tor(rolloffFactor); }
108 108
109 // Sound cones - angles in degrees 109 // Sound cones - angles in degrees
110 double coneInnerAngle() const { return m_coneEffect.innerAngle(); } 110 double coneInnerAngle() const { return m_coneEffect.innerAngle(); }
111 void setConeInnerAngle(double angle) { m_coneEffect.setInnerAngle(angle); } 111 void setConeInnerAngle(double angle) { m_coneEffect.setInnerAngle(angle); }
112 112
113 double coneOuterAngle() const { return m_coneEffect.outerAngle(); } 113 double coneOuterAngle() const { return m_coneEffect.outerAngle(); }
114 void setConeOuterAngle(double angle) { m_coneEffect.setOuterAngle(angle); } 114 void setConeOuterAngle(double angle) { m_coneEffect.setOuterAngle(angle); }
115 115
116 double coneOuterGain() const { return m_coneEffect.outerGain(); } 116 double coneOuterGain() const { return m_coneEffect.outerGain(); }
117 void setConeOuterGain(double angle) { m_coneEffect.setOuterGain(angle); } 117 void setConeOuterGain(double angle) { m_coneEffect.setOuterGain(angle); }
118 118
119 void getAzimuthElevation(double* outAzimuth, double* outElevation); 119 double dopplerRate();
120 float dopplerRate();
121 120
122 virtual double tailTime() const OVERRIDE { return m_panner ? m_panner->tailT ime() : 0; } 121 virtual double tailTime() const OVERRIDE { return m_panner ? m_panner->tailT ime() : 0; }
123 virtual double latencyTime() const OVERRIDE { return m_panner ? m_panner->la tencyTime() : 0; } 122 virtual double latencyTime() const OVERRIDE { return m_panner ? m_panner->la tencyTime() : 0; }
124 123
125 private: 124 private:
126 PannerNode(AudioContext*, float sampleRate); 125 PannerNode(AudioContext*, float sampleRate);
127 126
127 void calculateAzimuthElevation(double* outAzimuth, double* outElevation);
128 // Returns the combined distance and cone gain attenuation. 128 // Returns the combined distance and cone gain attenuation.
129 float calculateDistanceConeGain();
130 double calculateDopplerRate();
131
132 void azimuthElevation(double* outAzimuth, double* outElevation);
129 float distanceConeGain(); 133 float distanceConeGain();
130 134
135 bool isAzimuthElevationDirty();
136 bool isDistanceConeGainDirty();
137 bool isDopplerRateDirty();
138
131 // Notifies any AudioBufferSourceNodes connected to us either directly or in directly about our existence. 139 // Notifies any AudioBufferSourceNodes connected to us either directly or in directly about our existence.
132 // This is in order to handle the pitch change necessary for the doppler shi ft. 140 // This is in order to handle the pitch change necessary for the doppler shi ft.
133 void notifyAudioSourcesConnectedToNode(AudioNode*, HashMap<AudioNode*, bool> &visitedNodes); 141 void notifyAudioSourcesConnectedToNode(AudioNode*, HashMap<AudioNode*, bool> &visitedNodes);
134 142
143 void updateCachedListener();
144 void updateCachedSourceLocationInfo();
145
135 OwnPtr<Panner> m_panner; 146 OwnPtr<Panner> m_panner;
136 unsigned m_panningModel; 147 unsigned m_panningModel;
137 148
149 // Current source location information
138 FloatPoint3D m_position; 150 FloatPoint3D m_position;
139 FloatPoint3D m_orientation; 151 FloatPoint3D m_orientation;
140 FloatPoint3D m_velocity; 152 FloatPoint3D m_velocity;
141 153
154 // Cached source location information
155 FloatPoint3D m_cachedPosition;
156 FloatPoint3D m_cachedOrientation;
157 FloatPoint3D m_cachedVelocity;
158
142 // Gain 159 // Gain
143 RefPtr<AudioParam> m_distanceGain; 160 RefPtr<AudioParam> m_distanceGain;
144 RefPtr<AudioParam> m_coneGain; 161 RefPtr<AudioParam> m_coneGain;
145 DistanceEffect m_distanceEffect; 162 DistanceEffect m_distanceEffect;
146 ConeEffect m_coneEffect; 163 ConeEffect m_coneEffect;
147 float m_lastGain; 164 float m_lastGain;
148 165
149 // HRTF Database loader 166 double m_cachedAzimuth;
167 double m_cachedElevation;
168 float m_cachedDistanceConeGain;
169 double m_cachedDopplerRate;
170
171 // Cached listener parameters after processing.
172 RefPtr<AudioListener> m_cachedListener;
173
150 RefPtr<HRTFDatabaseLoader> m_hrtfDatabaseLoader; 174 RefPtr<HRTFDatabaseLoader> m_hrtfDatabaseLoader;
151 175
176 // AudioContext's connection count
152 unsigned m_connectionCount; 177 unsigned m_connectionCount;
153 178
154 // Synchronize process() and setPanningModel() which can change the panner. 179 // Synchronize process() and setPanningModel() which can change the panner.
155 mutable Mutex m_pannerLock; 180 mutable Mutex m_pannerLock;
156 }; 181 };
157 182
158 } // namespace WebCore 183 } // namespace WebCore
159 184
160 #endif // PannerNode_h 185 #endif // PannerNode_h
OLDNEW
« no previous file with comments | « no previous file | Source/modules/webaudio/PannerNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698