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

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/Panner/panner-distance-clamping.html

Issue 2859143004: Correctly clamp in distance formulas (Closed)
Patch Set: Clamp distance correctly Created 3 years, 7 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 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test Clamping of Distance for PannerNode</title> 4 <title>Test Clamping of Distance for PannerNode</title>
5 <script src="../../resources/testharness.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/audit-util.js"></script> 7 <script src="../resources/audit-util.js"></script>
8 <script src="../resources/audit.js"></script> 8 <script src="../resources/audit.js"></script>
9 </head> 9 </head>
10 10
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // Merge the panner outputs back into one stereo stream for the 188 // Merge the panner outputs back into one stereo stream for the
189 // destination. 189 // destination.
190 var merger = new ChannelMergerNode(context, {numberOfInputs: 2}); 190 var merger = new ChannelMergerNode(context, {numberOfInputs: 2});
191 191
192 src.connect(pannerTest).connect(splitTest).connect(merger, 0, 0);; 192 src.connect(pannerTest).connect(splitTest).connect(merger, 0, 0);;
193 src.connect(pannerRef).connect(splitRef).connect(merger, 0, 1); 193 src.connect(pannerRef).connect(splitRef).connect(merger, 0, 1);
194 194
195 merger.connect(context.destination); 195 merger.connect(context.destination);
196 196
197 // Move the panner some distance away. Arbitrarily select the x 197 // Move the panner some distance away. Arbitrarily select the x
198 // direction. For the reference panner, manually clamp the distance to 198 // direction. For the reference panner, manually clamp the distance.
199 // lie between refDistance and maxDistance. 199 // All models clamp the distance to a minimum of refDistance. Only the
200 var xRef = Math.min(Math.max(options.distance, pannerRef.refDistance), 200 // linear model also clamps to a maximum of maxDistance.
201 pannerRef.maxDistance); 201 var xRef = Math.max(options.distance, pannerRef.refDistance);;
hongchan 2017/05/05 18:07:58 I see "double semicolon" here and the line 192.
Raymond Toy 2017/05/05 18:18:28 Done.
202
203 if (pannerRef.distanceModel === "linear") {
204 xRef = Math.min(xRef, pannerRef.maxDistance);
205 }
202 206
203 var xTest = options.distance; 207 var xTest = options.distance;
204 208
205 pannerRef.positionZ.setValueAtTime(xRef, 0); 209 pannerRef.positionZ.setValueAtTime(xRef, 0);
206 pannerTest.positionZ.setValueAtTime(xTest, 0); 210 pannerTest.positionZ.setValueAtTime(xTest, 0);
207 211
208 src.start(); 212 src.start();
209 213
210 return context.startRendering().then(function (resultBuffer) { 214 return context.startRendering().then(function (resultBuffer) {
211 var actual = resultBuffer.getChannelData(0); 215 var actual = resultBuffer.getChannelData(0);
212 var expected = resultBuffer.getChannelData(1); 216 var expected = resultBuffer.getChannelData(1);
213 217
214 should(xTest < pannerRef.refDistance || xTest > pannerRef.maxDistance, 218 should(xTest < pannerRef.refDistance || xTest > pannerRef.maxDistance,
215 "Model: " + options.distanceModel + ": Distance (" + xTest + 219 "Model: " + options.distanceModel + ": Distance (" + xTest +
216 ") is outside the range [" + pannerRef.refDistance + ", " + 220 ") is outside the range [" + pannerRef.refDistance + ", " +
217 pannerRef.maxDistance + "]") 221 pannerRef.maxDistance + "]")
218 .beEqualTo(true); 222 .beEqualTo(true);
219 should(actual, "Test panner output " + JSON.stringify(options)) 223 should(actual, "Test panner output " + JSON.stringify(options))
220 .beEqualToArray(expected); 224 .beEqualToArray(expected);
221 }); 225 });
222 } 226 }
223 227
224 audit.run(); 228 audit.run();
225 </script> 229 </script>
226 </body> 230 </body>
227 </html> 231 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698