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