OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Test AudioBufferSourceNode With Looping a Single-Sample Buffer</title
> |
| 5 <script src="resources/compatibility.js"></script> |
| 6 <script src="resources/audio-testing.js"></script> |
| 7 <script src="../resources/js-test.js"></script> |
| 8 </head> |
| 9 |
| 10 <body> |
| 11 <script> |
| 12 description("Test AudioBufferSourceNode With Looping a Single-Sample Buffe
r"); |
| 13 |
| 14 var context; |
| 15 var source; |
| 16 var buffer; |
| 17 var renderedData; |
| 18 |
| 19 var sampleRate = 44100; |
| 20 var testDurationSamples = 1000; |
| 21 |
| 22 function checkResult (event) { |
| 23 var success = true; |
| 24 |
| 25 renderedData = event.renderedBuffer.getChannelData(0); |
| 26 // Check that the rendered data is all ones, like the buffer source. |
| 27 for (k = 0; k < renderedData.length; ++k) { |
| 28 if (renderedData[k] != 1) { |
| 29 success = false; |
| 30 testFailed("Expected all ones, but sample " + k + " is " + ren
deredData[k]); |
| 31 break; |
| 32 } |
| 33 } |
| 34 if (success) |
| 35 testPassed("All samples equal to 1"); |
| 36 finishJSTest(); |
| 37 } |
| 38 |
| 39 function runTest() { |
| 40 window.jsTestIsAsync = true; |
| 41 |
| 42 // Create the offline context for the test. |
| 43 context = new OfflineAudioContext(1, testDurationSamples, sampleRate); |
| 44 context.oncomplete = checkResult; |
| 45 |
| 46 // Create the single sample buffer |
| 47 buffer = createConstantBuffer(context, 1, 1); |
| 48 |
| 49 // Create the source and connect it to the destination |
| 50 source = context.createBufferSource(); |
| 51 source.buffer = buffer; |
| 52 source.loop = true; |
| 53 source.connect(context.destination); |
| 54 source.start(); |
| 55 |
| 56 // Render it! |
| 57 context.startRendering(); |
| 58 } |
| 59 |
| 60 runTest(); |
| 61 succesfullyParsed = true; |
| 62 </script> |
| 63 </body> |
| 64 </html> |
OLD | NEW |