content/media/webaudio/test/test_gainNodeInLoop.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 GainNode in presence of loops</title>
     5   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6   <script type="text/javascript" src="webaudio.js"></script>
     7   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     8 </head>
     9 <body>
    10 <pre id="test">
    11 <script class="testbody" type="text/javascript">
    13 var gTest = {
    14   length: 4096,
    15   numberOfChannels: 1,
    16   createGraph: function(context) {
    17     var sourceBuffer = context.createBuffer(1, 2048, context.sampleRate);
    18     for (var i = 0; i < 2048; ++i) {
    19       sourceBuffer.getChannelData(0)[i] = 1;
    20     }
    22     var source = context.createBufferSource();
    23     source.buffer = sourceBuffer;
    24     source.loop = true;
    25     source.start(0);
    26     source.stop(sourceBuffer.duration * 2);
    28     var gain = context.createGain();
    29     // Adjust the gain in a way that we don't just end up modifying AudioChunk::mVolume
    30     gain.gain.setValueAtTime(0.5, 0);
    31     source.connect(gain);
    32     return gain;
    33   },
    34   createExpectedBuffers: function(context) {
    35     var expectedBuffer = context.createBuffer(1, 4096, context.sampleRate);
    36     for (var i = 0; i < 4096; ++i) {
    37       expectedBuffer.getChannelData(0)[i] = 0.5;
    38     }
    39     return expectedBuffer;
    40   },
    41 };
    43 runTest();
    45 </script>
    46 </pre>
    47 </body>
    48 </html>

mercurial