| 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/audit-util.js"></script> | 9 <script src="../../resources/js-test.js"></script> |
| 10 <script src="resources/audio-testing.js"></script> | 10 <script src="../resources/audit-util.js"></script> |
| 11 <script type="text/javascript" src="resources/buffer-loader.js"></script> | 11 <script src="../resources/audio-testing.js"></script> |
| 12 <script type="text/javascript" src="../resources/buffer-loader.js"></script> |
| 12 | 13 |
| 13 <script> | 14 <script> |
| 14 | 15 |
| 15 window.onload = init; | 16 window.onload = init; |
| 16 | 17 |
| 17 var sampleRate = 44100.0; | 18 var sampleRate = 44100.0; |
| 18 var lengthInSeconds = 2; | 19 var lengthInSeconds = 2; |
| 19 | 20 |
| 20 var context = 0; | 21 var context = 0; |
| 21 var bufferLoader = 0; | 22 var bufferLoader = 0; |
| 22 | 23 |
| 23 function init() { | 24 function init() { |
| 24 if (!window.testRunner) | 25 if (!window.testRunner) |
| 25 return; | 26 return; |
| 26 | 27 |
| 27 // Create offline audio context. | 28 // Create offline audio context. |
| 28 context = new OfflineAudioContext(2, sampleRate * lengthInSeconds, sampleRat
e); | 29 context = new OfflineAudioContext(2, sampleRate * lengthInSeconds, sampleRat
e); |
| 29 | 30 |
| 30 bufferLoader = new BufferLoader( | 31 bufferLoader = new BufferLoader( |
| 31 context, | 32 context, |
| 32 [ | 33 [ |
| 33 "resources/hyper-reality/br-jam-loop.wav", | 34 "../resources/hyper-reality/br-jam-loop.wav", |
| 34 ], | 35 ], |
| 35 finishedLoading | 36 finishedLoading |
| 36 ); | 37 ); |
| 37 | 38 |
| 38 bufferLoader.load(); | 39 bufferLoader.load(); |
| 39 testRunner.waitUntilDone(); | 40 testRunner.waitUntilDone(); |
| 40 } | 41 } |
| 41 | 42 |
| 42 function finishedLoading(bufferList) { | 43 function finishedLoading(bufferList) { |
| 43 var bufferSource = context.createBufferSource(); | 44 var bufferSource = context.createBufferSource(); |
| 44 bufferSource.buffer = bufferList[0]; | 45 bufferSource.buffer = bufferList[0]; |
| 45 | 46 |
| 46 bufferSource.connect(context.destination); | 47 bufferSource.connect(context.destination); |
| 47 bufferSource.start(0); | 48 bufferSource.start(0); |
| 48 | 49 |
| 49 context.oncomplete = finishAudioTest; | 50 context.oncomplete = finishAudioTest; |
| 50 context.startRendering(); | 51 context.startRendering(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 </script> | 54 </script> |
| 54 </head> | 55 </head> |
| 55 <body> | 56 <body> |
| 56 </body> | 57 </body> |
| 57 </html> | 58 </html> |
| OLD | NEW |