4038558e8fc744259d1012fa12c938542ccb6260
[WebKit-https.git] / LayoutTests / webaudio / delaynode.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 attribute and basic functionality of Delay.");
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.createDelay();
34     
35     window.delay = delay;
36     shouldBeTrue("delay.numberOfInputs === 1");
37     shouldBeTrue("delay.numberOfOutputs === 1");
38     shouldBeTrue("delay.delayTime.defaultValue === 0.0");
39     shouldBeTrue("delay.delayTime.minValue === 0.0");
40     shouldBeTrue("delay.delayTime.maxValue === 1.0");
41     shouldBeTrue("delay.delayTime.value === 0.0");
42
43     delay.delayTime.value = delayTimeSeconds;
44     shouldBeTrue("delay.delayTime.value === 0.5");
45
46     bufferSource.connect(delay);
47     delay.connect(context.destination);
48     bufferSource.noteOn(0);
49     
50     context.oncomplete = checkDelayedResult(toneBuffer);
51     context.startRendering();
52 }
53
54 runTest();
55
56 </script>
57
58 <script src="../fast/js/resources/js-test-post.js"></script>
59 </body>
60 </html>