Merge "[Release] Webkit2-efl-123997_0.11.77" into tizen_2.2
[framework/web/webkit-efl.git] / LayoutTests / webaudio / convolution-mono-mono.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5 <link rel="stylesheet" href="../fast/js/resources/js-test-style.css"/>
6 <script type="text/javascript" src="resources/audio-testing.js"></script>
7 <script src="../fast/js/resources/js-test-pre.js"></script>
8 <script src="resources/convolution-testing.js"></script>
9 </head>
10
11 <body>
12
13 <div id="description"></div>
14 <div id="console"></div>
15
16 <script>
17 description("Tests ConvolverNode processing a mono channel with mono impulse response.");
18
19 // To test the convolver, we convolve two square pulses together to
20 // produce a triangular pulse.  To verify the result is correct we
21 // check several parts of the result.  First, we make sure the initial
22 // part of the result is zero (due to the latency in the convolver).
23 // Next, the triangular pulse should match the theoretical result to
24 // within some roundoff.  After the triangular pulse, the result
25 // should be exactly zero, but round-off prevents that.  We make sure
26 // the part after the pulse is sufficiently close to zero.  Finally,
27 // the result should be exactly zero because the inputs are exactly
28 // zero.
29 function runTest() {
30     if (window.testRunner) {
31         testRunner.dumpAsText();
32         testRunner.waitUntilDone();
33     }
34     
35     window.jsTestIsAsync = true;
36         
37     // Create offline audio context.
38     var context = new webkitOfflineAudioContext(2, sampleRate * renderLengthSeconds, sampleRate);
39
40     var squarePulse = createSquarePulseBuffer(context, pulseLengthFrames);
41     var trianglePulse = createTrianglePulseBuffer(context, 2 * pulseLengthFrames);
42     
43     var bufferSource = context.createBufferSource();
44     bufferSource.buffer = squarePulse;
45     
46     var convolver = context.createConvolver();
47     convolver.normalize = false;
48     convolver.buffer = squarePulse;
49
50     bufferSource.connect(convolver);
51     convolver.connect(context.destination);
52
53     bufferSource.noteOn(0);
54     
55     context.oncomplete = checkConvolvedResult(trianglePulse);
56     context.startRendering();
57 }
58
59 runTest();
60 successfullyParsed = true;
61
62 </script>
63
64 <script src="../fast/js/resources/js-test-post.js"></script>
65 </body>
66 </html>