content/media/webaudio/test/test_dynamicsCompressorNode.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial