OLD | NEW |
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | 1 <!doctype> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> |
5 <script src="../resources/audit-util.js"></script> | 6 <script src="../resources/audit-util.js"></script> |
6 <script src="../resources/audio-testing.js"></script> | 7 <script src="../resources/audit.js"></script> |
7 <script src="../resources/note-grain-on-testing.js"></script> | 8 <script src="../resources/note-grain-on-testing.js"></script> |
8 </head> | 9 </head> |
9 | 10 |
10 <body> | 11 <body> |
11 <div id="description"></div> | 12 <script> |
12 <div id="console"></div> | 13 let audit = Audit.createTaskRunner(); |
13 | 14 |
14 <script> | 15 let squarePulseBuffer; |
15 description("Test timing of noteGrainOn."); | |
16 | 16 |
17 var squarePulseBuffer; | 17 function checkResult(buffer, should) { |
| 18 renderedData = buffer.getChannelData(0); |
| 19 let nSamples = renderedData.length; |
| 20 let startEndFrames = findStartAndEndSamples(renderedData); |
18 | 21 |
19 function checkResult(event) { | 22 verifyStartAndEndFrames(startEndFrames, should); |
20 var buffer = event.renderedBuffer; | |
21 renderedData = buffer.getChannelData(0); | |
22 var nSamples = renderedData.length; | |
23 | |
24 var success = true; | |
25 | |
26 var startEndFrames = findStartAndEndSamples(renderedData); | |
27 | |
28 success = success && verifyStartAndEndFrames(startEndFrames); | |
29 | |
30 if (success) { | |
31 testPassed("noteGrainOn timing tests passed."); | |
32 } else { | |
33 testFailed("noteGrainOn timing tests failed."); | |
34 } | |
35 | |
36 finishJSTest(); | |
37 } | 23 } |
38 | 24 |
39 function runTest() { | 25 audit.define("Test timing of noteGrainOn", function (task, should) { |
40 if (window.testRunner) { | 26 // Create offline audio context. |
41 testRunner.dumpAsText(); | 27 context = new OfflineAudioContext(2, sampleRate * renderTime, |
42 testRunner.waitUntilDone(); | 28 sampleRate); |
43 } | |
44 | 29 |
45 window.jsTestIsAsync = true; | 30 squarePulseBuffer = createSignalBuffer(context, function (k) { |
46 | 31 return 1 |
47 // Create offline audio context. | 32 }); |
48 context = new OfflineAudioContext(2, sampleRate * renderTime, sampleRa
te); | |
49 | |
50 squarePulseBuffer = createSignalBuffer(context, function (k) { return
1 }); | |
51 | 33 |
52 playAllGrains(context, squarePulseBuffer, numberOfTests); | 34 playAllGrains(context, squarePulseBuffer, numberOfTests); |
53 | 35 |
54 context.oncomplete = checkResult; | 36 context.startRendering() |
55 context.startRendering(); | 37 .then(function (audioBuffer) { |
56 } | 38 checkResult(audioBuffer, should); |
| 39 task.done(); |
| 40 }); |
| 41 }); |
57 | 42 |
58 runTest(); | 43 audit.run(); |
59 successfullyParsed = true; | |
60 | |
61 </script> | 44 </script> |
62 | 45 |
63 </body> | 46 </body> |
64 </html> | 47 </html> |
OLD | NEW |