14dfbd26e98d3d4f1a3978cce05d1370345f4ee1
[WebKit-https.git] / LayoutTests / webaudio / delaynode-scheduling.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5 <script src="../fast/js/resources/js-test-pre.js"></script>
6 <script src="resources/audio-testing.js"></script>
7 <script src="resources/delay-testing.js"></script>
8 </head>
9
10 <body>
11
12 <div id="description"></div>
13 <div id="console"></div>
14
15 <script>
16 description("Tests that DelayNode delayTime parameter can be scheduled at a given time.");
17
18 function runTest() {
19     if (window.testRunner) {
20         testRunner.dumpAsText();
21         testRunner.waitUntilDone();
22     }
23     
24     window.jsTestIsAsync = true;
25         
26     // Create offline audio context.
27     var context = new webkitAudioContext(1, sampleRate * renderLengthSeconds, sampleRate);
28     var toneBuffer = createToneBuffer(context, 20, 20 * toneLengthSeconds, sampleRate); // 20Hz tone
29     
30     var bufferSource = context.createBufferSource();
31     bufferSource.buffer = toneBuffer;
32
33     var delay = context.createDelayNode();
34     
35     // Schedule delay time at time zero.
36     delay.delayTime.setValueAtTime(delayTimeSeconds, 0);
37
38     bufferSource.connect(delay);
39     delay.connect(context.destination);
40     bufferSource.noteOn(0);
41     
42     context.oncomplete = checkDelayedResult(toneBuffer);
43     context.startRendering();
44 }
45
46 runTest();
47
48 </script>
49
50 <script src="../fast/js/resources/js-test-post.js"></script>
51 </body>
52 </html>