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