Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 | 2 |
| 3 <!-- | 3 <!-- |
| 4 See if we can load an AudioBuffer, create an AudioBufferSourceNode, attach the b uffer to it, then play it. | 4 See if we can load an AudioBuffer, create an AudioBufferSourceNode, attach the b uffer to it, then play it. |
| 5 --> | 5 --> |
| 6 | 6 |
| 7 <html> | 7 <html> |
| 8 <head> | 8 <head> |
| 9 <script src="../../resources/js-test.js"></script> | 9 <script src="../../resources/testharness.js"></script> |
| 10 <script src="../../resources/testharnessreport.js"></script> | |
| 10 <script src="../resources/audit-util.js"></script> | 11 <script src="../resources/audit-util.js"></script> |
| 11 <script src="../resources/audio-testing.js"></script> | 12 <script src="../resources/audit.js"></script> |
| 12 <script type="text/javascript" src="../resources/buffer-loader.js"></script> | 13 <script src="../resources/buffer-loader.js"></script> |
| 13 | 14 |
| 14 <script> | 15 <script> |
| 16 let audit = Audit.createTaskRunner(); | |
| 15 | 17 |
| 16 window.onload = init; | 18 let sampleRate = 44100.0; |
| 19 let lengthInSeconds = 2; | |
| 17 | 20 |
| 18 var sampleRate = 44100.0; | 21 let context = 0; |
| 19 var lengthInSeconds = 2; | 22 let bufferLoader = 0; |
| 20 | 23 |
| 21 var context = 0; | 24 // Note: The text output from this test is ignored. The test will generate |
| 22 var bufferLoader = 0; | 25 // output WAV file that is compared to the expected file and these two should |
| 26 // match exactly. | |
| 27 audit.define('test', (task, should) => { | |
| 28 // This test requires testRunner to exist | |
| 29 should(window.testRunner, 'window.testRunner').notBeEqualTo(undefined); | |
| 23 | 30 |
| 24 function init() { | 31 // Create offline audio context. |
| 25 if (!window.testRunner) | 32 context = |
| 26 return; | 33 new OfflineAudioContext(2, sampleRate * lengthInSeconds, sampleRate); |
| 27 | |
| 28 // Create offline audio context. | |
| 29 context = new OfflineAudioContext(2, sampleRate * lengthInSeconds, sampleRat e); | |
| 30 | |
| 31 bufferLoader = new BufferLoader( | |
| 32 context, | |
| 33 [ | |
| 34 "../resources/hyper-reality/br-jam-loop.wav", | |
| 35 ], | |
| 36 finishedLoading | |
| 37 ); | |
| 38 | |
| 39 bufferLoader.load(); | |
| 40 testRunner.waitUntilDone(); | |
| 41 } | |
| 42 | 34 |
| 43 function finishedLoading(bufferList) { | 35 bufferLoader = new BufferLoader( |
|
hongchan
2017/02/27 18:05:35
Can this be replaced with Audit.loadFileFromURL()?
Raymond Toy
2017/02/27 18:48:08
Done.
| |
| 44 var bufferSource = context.createBufferSource(); | 36 context, |
| 45 bufferSource.buffer = bufferList[0]; | 37 [ |
| 46 | 38 '../resources/hyper-reality/br-jam-loop.wav', |
| 47 bufferSource.connect(context.destination); | 39 ], |
| 48 bufferSource.start(0); | 40 bufferList => { |
| 49 | 41 finishedLoading(bufferList, task, should); |
| 50 context.oncomplete = finishAudioTest; | 42 }); |
| 51 context.startRendering(); | 43 |
| 44 bufferLoader.load(); | |
| 45 testRunner.waitUntilDone(); | |
| 46 }); | |
| 47 | |
| 48 audit.run(); | |
| 49 | |
| 50 function finishedLoading(bufferList, task, should) { | |
| 51 let bufferSource = context.createBufferSource(); | |
| 52 bufferSource.buffer = bufferList[0]; | |
| 53 | |
| 54 bufferSource.connect(context.destination); | |
| 55 bufferSource.start(0); | |
| 56 | |
| 57 context.oncomplete = (event) => { | |
|
hongchan
2017/02/27 18:05:35
Use promise?
| |
| 58 finishAudioTest(event); | |
| 59 task.done(); | |
| 60 }; | |
| 61 context.startRendering(); | |
| 52 } | 62 } |
| 53 | 63 |
| 54 </script> | 64 </script> |
| 55 </head> | 65 </head> |
| 56 <body> | 66 <body> |
| 57 </body> | 67 </body> |
| 58 </html> | 68 </html> |
| OLD | NEW |