content/media/webaudio/test/test_dynamicsCompressorNode.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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