Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test DynamicsCompressorNode</title> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 7 | </head> |
michael@0 | 8 | <body> |
michael@0 | 9 | <pre id="test"> |
michael@0 | 10 | <script class="testbody" type="text/javascript"> |
michael@0 | 11 | |
michael@0 | 12 | function near(a, b, msg) { |
michael@0 | 13 | ok(Math.abs(a - b) < 1e-4, msg); |
michael@0 | 14 | } |
michael@0 | 15 | |
michael@0 | 16 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 17 | addLoadEvent(function() { |
michael@0 | 18 | var context = new AudioContext(); |
michael@0 | 19 | var buffer = context.createBuffer(1, 2048, context.sampleRate); |
michael@0 | 20 | for (var i = 0; i < 2048; ++i) { |
michael@0 | 21 | buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | var destination = context.destination; |
michael@0 | 25 | |
michael@0 | 26 | var source = context.createBufferSource(); |
michael@0 | 27 | |
michael@0 | 28 | var compressor = context.createDynamicsCompressor(); |
michael@0 | 29 | |
michael@0 | 30 | source.buffer = buffer; |
michael@0 | 31 | |
michael@0 | 32 | source.connect(compressor); |
michael@0 | 33 | compressor.connect(destination); |
michael@0 | 34 | |
michael@0 | 35 | is(compressor.channelCount, 2, "compressor node has 2 input channels by default"); |
michael@0 | 36 | is(compressor.channelCountMode, "explicit", "Correct channelCountMode for the compressor node"); |
michael@0 | 37 | is(compressor.channelInterpretation, "speakers", "Correct channelCountInterpretation for the compressor node"); |
michael@0 | 38 | |
michael@0 | 39 | // Verify default values |
michael@0 | 40 | with (compressor) { |
michael@0 | 41 | near(threshold.defaultValue, -24, "Correct default value for threshold"); |
michael@0 | 42 | near(knee.defaultValue, 30, "Correct default value for knee"); |
michael@0 | 43 | near(ratio.defaultValue, 12, "Correct default value for ratio"); |
michael@0 | 44 | near(reduction.defaultValue, 0, "Correct default value for reduction"); |
michael@0 | 45 | near(attack.defaultValue, 0.003, "Correct default value for attack"); |
michael@0 | 46 | near(release.defaultValue, 0.25, "Correct default value for release"); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | source.start(0); |
michael@0 | 50 | SimpleTest.executeSoon(function() { |
michael@0 | 51 | source.stop(0); |
michael@0 | 52 | source.disconnect(); |
michael@0 | 53 | compressor.disconnect(); |
michael@0 | 54 | |
michael@0 | 55 | SimpleTest.finish(); |
michael@0 | 56 | }); |
michael@0 | 57 | }); |
michael@0 | 58 | |
michael@0 | 59 | </script> |
michael@0 | 60 | </pre> |
michael@0 | 61 | </body> |
michael@0 | 62 | </html> |