content/media/webaudio/test/test_convolverNode_mono_mono.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/webaudio/test/test_convolverNode_mono_mono.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +<!DOCTYPE html>
     1.5 +
     1.6 +<html>
     1.7 +<head>
     1.8 +<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +<script type="text/javascript" src="webaudio.js"></script>
    1.10 +<script type="text/javascript" src="layouttest-glue.js"></script>
    1.11 +<script type="text/javascript" src="blink/audio-testing.js"></script>
    1.12 +<script type="text/javascript" src="blink/convolution-testing.js"></script>
    1.13 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.14 +</head>
    1.15 +
    1.16 +<body>
    1.17 +
    1.18 +<div id="description"></div>
    1.19 +<div id="console"></div>
    1.20 +
    1.21 +<script>
    1.22 +description("Tests ConvolverNode processing a mono channel with mono impulse response.");
    1.23 +SimpleTest.waitForExplicitFinish();
    1.24 +
    1.25 +// To test the convolver, we convolve two square pulses together to
    1.26 +// produce a triangular pulse.  To verify the result is correct we
    1.27 +// check several parts of the result.  First, we make sure the initial
    1.28 +// part of the result is zero (due to the latency in the convolver).
    1.29 +// Next, the triangular pulse should match the theoretical result to
    1.30 +// within some roundoff.  After the triangular pulse, the result
    1.31 +// should be exactly zero, but round-off prevents that.  We make sure
    1.32 +// the part after the pulse is sufficiently close to zero.  Finally,
    1.33 +// the result should be exactly zero because the inputs are exactly
    1.34 +// zero.
    1.35 +function runTest() {
    1.36 +    if (window.testRunner) {
    1.37 +        testRunner.dumpAsText();
    1.38 +        testRunner.waitUntilDone();
    1.39 +    }
    1.40 +
    1.41 +    window.jsTestIsAsync = true;
    1.42 +
    1.43 +    // Create offline audio context.
    1.44 +    var context = new OfflineAudioContext(2, sampleRate * renderLengthSeconds, sampleRate);
    1.45 +
    1.46 +    var squarePulse = createSquarePulseBuffer(context, pulseLengthFrames);
    1.47 +    var trianglePulse = createTrianglePulseBuffer(context, 2 * pulseLengthFrames);
    1.48 +
    1.49 +    var bufferSource = context.createBufferSource();
    1.50 +    bufferSource.buffer = squarePulse;
    1.51 +
    1.52 +    var convolver = context.createConvolver();
    1.53 +    convolver.normalize = false;
    1.54 +    convolver.buffer = squarePulse;
    1.55 +
    1.56 +    bufferSource.connect(convolver);
    1.57 +    convolver.connect(context.destination);
    1.58 +
    1.59 +    bufferSource.start(0);
    1.60 +
    1.61 +    context.oncomplete = checkConvolvedResult(trianglePulse);
    1.62 +    context.startRendering();
    1.63 +}
    1.64 +
    1.65 +function finishJSTest() {
    1.66 +  SimpleTest.finish();
    1.67 +}
    1.68 +
    1.69 +runTest();
    1.70 +successfullyParsed = true;
    1.71 +
    1.72 +</script>
    1.73 +
    1.74 +<script src="../fast/js/resources/js-test-post.js"></script>
    1.75 +</body>
    1.76 +</html>

mercurial