OLD | NEW |
1 <!doctype html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
| 4 <title> |
| 5 Test getFloatFrequencyData With Zero Inputs |
| 6 </title> |
4 <script src="../../resources/testharness.js"></script> | 7 <script src="../../resources/testharness.js"></script> |
5 <script src="../../resources/testharnessreport.js"></script> | 8 <script src="../../resources/testharnessreport.js"></script> |
6 <script src="../resources/audit-util.js"></script> | 9 <script src="../resources/audit-util.js"></script> |
7 <script src="../resources/audit.js"></script> | 10 <script src="../resources/audit.js"></script> |
8 <title>Test getFloatFrequencyData With Zero Inputs</title> | |
9 </head> | 11 </head> |
| 12 <body> |
| 13 <script id="layout-test-code"> |
| 14 let sampleRate = 48000; |
10 | 15 |
11 <body> | 16 // Render enough data to run the test. |
12 <script> | 17 let renderFrames = 2 * 1024; |
13 var sampleRate = 48000; | 18 let renderDuration = renderFrames / sampleRate; |
14 | 19 |
15 // Render enough data to run the test. | 20 let audit = Audit.createTaskRunner(); |
16 var renderFrames = 2*1024; | |
17 var renderDuration = renderFrames / sampleRate; | |
18 | |
19 var audit = Audit.createTaskRunner(); | |
20 | 21 |
21 | 22 |
22 // Test that getFloatFrequencyData returns -Infinity when the input is all
-zeroes. | 23 // Test that getFloatFrequencyData returns -Infinity when the input is |
23 audit.define("zero input", (task, should) => { | 24 // all-zeroes. |
24 var context = new OfflineAudioContext(1, renderFrames, sampleRate); | 25 audit.define('zero input', (task, should) => { |
| 26 let context = new OfflineAudioContext(1, renderFrames, sampleRate); |
25 | 27 |
26 // Constant source of 0's. | 28 // Constant source of 0's. |
27 var source = context.createBufferSource(); | 29 let source = context.createBufferSource(); |
28 source.buffer = createConstantBuffer(context, 1, 0); | 30 source.buffer = createConstantBuffer(context, 1, 0); |
29 source.loop = true; | 31 source.loop = true; |
30 | 32 |
31 // Create analyser and use some non-default minDecibels value. | 33 // Create analyser and use some non-default minDecibels value. |
32 var analyser = context.createAnalyser(); | 34 let analyser = context.createAnalyser(); |
33 analyser.minDecibels = -123; | 35 analyser.minDecibels = -123; |
34 | 36 |
35 source.connect(analyser); | 37 source.connect(analyser); |
36 analyser.connect(context.destination); | 38 analyser.connect(context.destination); |
37 | 39 |
38 source.start(); | 40 source.start(); |
39 | 41 |
40 // Suspend after some number of frames and grab the float frequency data
. | 42 // Suspend after some number of frames and grab the float frequency |
41 context.suspend(1024 / sampleRate).then(function () { | 43 // data. |
42 var f = new Float32Array(analyser.frequencyBinCount); | 44 context.suspend(1024 / sampleRate) |
43 analyser.getFloatFrequencyData(f); | 45 .then(function() { |
| 46 let f = new Float32Array(analyser.frequencyBinCount); |
| 47 analyser.getFloatFrequencyData(f); |
44 | 48 |
45 should(f, "getFloatFrequencyData() with zero-valued input") | 49 should(f, 'getFloatFrequencyData() with zero-valued input') |
46 .beConstantValueOf(-Infinity); | 50 .beConstantValueOf(-Infinity); |
47 }).then(context.resume.bind(context)); | 51 }) |
| 52 .then(context.resume.bind(context)); |
48 | 53 |
49 context.startRendering().then(() => task.done()); | 54 context.startRendering().then(() => task.done()); |
50 }); | 55 }); |
51 | 56 |
52 audit.run(); | 57 audit.run(); |
53 | |
54 </script> | 58 </script> |
55 </body> | 59 </body> |
56 </html> | 60 </html> |
OLD | NEW |