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