| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../resources/testharness.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> | 5 <script src="../../resources/testharnessreport.js"></script> |
| 6 <script src="../resources/audit-util.js"></script> | 6 <script src="../resources/audit-util.js"></script> |
| 7 <script src="../resources/audit.js"></script> | 7 <script src="../resources/audit.js"></script> |
| 8 <title>Handle Silent Inputs to AnalyserNode</title> | 8 <title>Handle Silent Inputs to AnalyserNode</title> |
| 9 </head> | 9 </head> |
| 10 | 10 |
| 11 <body> | 11 <body> |
| 12 <script> | 12 <script> |
| 13 let audit = Audit.createTaskRunner(); | 13 let audit = Audit.createTaskRunner(); |
| 14 let sampleRate = 16000; | 14 let sampleRate = 16000; |
| 15 let renderDuration = 1; | 15 let renderDuration = 1; |
| 16 let renderFrames = renderDuration * sampleRate; | 16 let renderFrames = renderDuration * sampleRate; |
| 17 | 17 |
| 18 audit.define({ | 18 audit.define({ |
| 19 label: 'connected', | 19 label: 'connected', |
| 20 description: 'Test handling of silent inputs' | 20 description: 'Test handling of silent inputs' |
| 21 }, function (task, should) { | 21 }, function (task, should) { |
| 22 tester(should, false).then(task.done.bind(task)); | 22 tester(should, false, '0').then(task.done.bind(task)); |
| 23 }); | 23 }); |
| 24 | 24 |
| 25 audit.define({ | 25 audit.define({ |
| 26 label: 'auto-pull', | 26 label: 'auto-pull', |
| 27 description: 'Test handling of silent inputs' | 27 description: 'Test handling of silent inputs' |
| 28 }, function(task, should) { | 28 }, function(task, should) { |
| 29 tester(should, true).then(task.done.bind(task)); | 29 tester(should, true, '1').then(task.done.bind(task)); |
| 30 }); | 30 }); |
| 31 | 31 |
| 32 audit.define({ | 32 audit.define({ |
| 33 label: 'timing', | 33 label: 'timing', |
| 34 description: 'Test shifting in of zeroes after source has stopped' | 34 description: 'Test shifting in of zeroes after source has stopped' |
| 35 }, function(task, should) { | 35 }, function(task, should) { |
| 36 let renderQuantumFrames = 128; | 36 let renderQuantumFrames = 128; |
| 37 | 37 |
| 38 // sampleRate chosen to be a power of two so we don't have round-off | 38 // sampleRate chosen to be a power of two so we don't have round-off |
| 39 // errors in computing the times for when to suspend the context. | 39 // errors in computing the times for when to suspend the context. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 }) | 93 }) |
| 94 .then(context.resume.bind(context)); | 94 .then(context.resume.bind(context)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Start the test | 97 // Start the test |
| 98 context.startRendering().then(() => task.done()); | 98 context.startRendering().then(() => task.done()); |
| 99 }); | 99 }); |
| 100 | 100 |
| 101 audit.run(); | 101 audit.run(); |
| 102 | 102 |
| 103 function tester(should, isAutoPullTest) { | 103 function tester(should, isAutoPullTest, prefix) { |
| 104 // Connect an oscillator to an analyser for testing the time data of the | 104 // Connect an oscillator to an analyser for testing the time data of the |
| 105 // analyser after the oscillator stops. | 105 // analyser after the oscillator stops. |
| 106 let context = new OfflineAudioContext(1, renderFrames, sampleRate); | 106 let context = new OfflineAudioContext(1, renderFrames, sampleRate); |
| 107 let source = new OscillatorNode(context); | 107 let source = new OscillatorNode(context); |
| 108 let analyser = new AnalyserNode(context, {fftSize: 128}); | 108 let analyser = new AnalyserNode(context, {fftSize: 128}); |
| 109 let timeData = new Float32Array(analyser.fftSize); | 109 let timeData = new Float32Array(analyser.fftSize); |
| 110 timeData.fill(NaN); | 110 timeData.fill(NaN); |
| 111 | 111 |
| 112 source.connect(analyser); | 112 source.connect(analyser); |
| 113 | 113 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 124 // from the analyser. | 124 // from the analyser. |
| 125 let stopTime = 0.1; | 125 let stopTime = 0.1; |
| 126 let dataTime = 0.5; | 126 let dataTime = 0.5; |
| 127 | 127 |
| 128 source.stop(stopTime); | 128 source.stop(stopTime); |
| 129 context.suspend(dataTime) | 129 context.suspend(dataTime) |
| 130 .then(() => { analyser.getFloatTimeDomainData(timeData); }) | 130 .then(() => { analyser.getFloatTimeDomainData(timeData); }) |
| 131 .then(context.resume.bind(context)); | 131 .then(context.resume.bind(context)); |
| 132 | 132 |
| 133 return context.startRendering().then(buffer => { | 133 return context.startRendering().then(buffer => { |
| 134 should(timeData, 'Analyser time data at time ' + dataTime) | 134 should(timeData, prefix + ': Analyser time data at time ' + dataTime) |
| 135 .beConstantValueOf(0); | 135 .beConstantValueOf(0); |
| 136 }); | 136 }); |
| 137 } | 137 } |
| 138 </script> | 138 </script> |
| 139 </body> | 139 </body> |
| 140 </html> | 140 </html> |
| OLD | NEW |