Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
michael@0 | 1 | <!DOCTYPE html> |
michael@0 | 2 | |
michael@0 | 3 | <html> |
michael@0 | 4 | <head> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <script type="text/javascript" src="webaudio.js"></script> |
michael@0 | 7 | <script type="text/javascript" src="layouttest-glue.js"></script> |
michael@0 | 8 | <script type="text/javascript" src="blink/audio-testing.js"></script> |
michael@0 | 9 | <script type="text/javascript" src="blink/convolution-testing.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 11 | </head> |
michael@0 | 12 | |
michael@0 | 13 | <body> |
michael@0 | 14 | |
michael@0 | 15 | <div id="description"></div> |
michael@0 | 16 | <div id="console"></div> |
michael@0 | 17 | |
michael@0 | 18 | <script> |
michael@0 | 19 | description("Tests ConvolverNode processing a mono channel with mono impulse response."); |
michael@0 | 20 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 21 | |
michael@0 | 22 | // To test the convolver, we convolve two square pulses together to |
michael@0 | 23 | // produce a triangular pulse. To verify the result is correct we |
michael@0 | 24 | // check several parts of the result. First, we make sure the initial |
michael@0 | 25 | // part of the result is zero (due to the latency in the convolver). |
michael@0 | 26 | // Next, the triangular pulse should match the theoretical result to |
michael@0 | 27 | // within some roundoff. After the triangular pulse, the result |
michael@0 | 28 | // should be exactly zero, but round-off prevents that. We make sure |
michael@0 | 29 | // the part after the pulse is sufficiently close to zero. Finally, |
michael@0 | 30 | // the result should be exactly zero because the inputs are exactly |
michael@0 | 31 | // zero. |
michael@0 | 32 | function runTest() { |
michael@0 | 33 | if (window.testRunner) { |
michael@0 | 34 | testRunner.dumpAsText(); |
michael@0 | 35 | testRunner.waitUntilDone(); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | window.jsTestIsAsync = true; |
michael@0 | 39 | |
michael@0 | 40 | // Create offline audio context. |
michael@0 | 41 | var context = new OfflineAudioContext(2, sampleRate * renderLengthSeconds, sampleRate); |
michael@0 | 42 | |
michael@0 | 43 | var squarePulse = createSquarePulseBuffer(context, pulseLengthFrames); |
michael@0 | 44 | var trianglePulse = createTrianglePulseBuffer(context, 2 * pulseLengthFrames); |
michael@0 | 45 | |
michael@0 | 46 | var bufferSource = context.createBufferSource(); |
michael@0 | 47 | bufferSource.buffer = squarePulse; |
michael@0 | 48 | |
michael@0 | 49 | var convolver = context.createConvolver(); |
michael@0 | 50 | convolver.normalize = false; |
michael@0 | 51 | convolver.buffer = squarePulse; |
michael@0 | 52 | |
michael@0 | 53 | bufferSource.connect(convolver); |
michael@0 | 54 | convolver.connect(context.destination); |
michael@0 | 55 | |
michael@0 | 56 | bufferSource.start(0); |
michael@0 | 57 | |
michael@0 | 58 | context.oncomplete = checkConvolvedResult(trianglePulse); |
michael@0 | 59 | context.startRendering(); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | function finishJSTest() { |
michael@0 | 63 | SimpleTest.finish(); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | runTest(); |
michael@0 | 67 | successfullyParsed = true; |
michael@0 | 68 | |
michael@0 | 69 | </script> |
michael@0 | 70 | |
michael@0 | 71 | <script src="../fast/js/resources/js-test-post.js"></script> |
michael@0 | 72 | </body> |
michael@0 | 73 | </html> |