dom/media/webaudio/test/test_biquadFilterNodeWithGain.html
author Emilio Cobos Álvarez <emilio@crisal.io>
Tue, 28 Mar 2023 08:20:09 +0000
changeset 658112 702d4a62e5d03a2b36b3a17645718208a30ddb08
parent 491143 3b3c5e0e1bc4a58d8a7d5718745cc41153e06a76
permissions -rw-r--r--
Bug 1824304 - Fix PiP window type hint after bug 1823350. r=stransky Differential Revision: https://phabricator.services.mozilla.com/D173677

<!DOCTYPE HTML>
<html>
<head>
  <title>Test BiquadFilterNode after a GainNode and tail - Bugs 924286 and 924288</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script src="webaudio.js" type="text/javascript"></script>
<script class="testbody" type="text/javascript">

const signalLength = 2048;

var gTest = {
  length: signalLength,
  numberOfChannels: 1,
  createGraph(context) {
    // Two oscillators scheduled sequentially
    var signalDuration = signalLength / context.sampleRate;
    var osc1 = context.createOscillator();
    osc1.type = "square";
    osc1.start(0);
    osc1.stop(signalDuration / 2);
    var osc2 = context.createOscillator();
    osc2.start(signalDuration / 2);
    osc2.stop(signalDuration);

    // Comparing a biquad on each source with one on both sources checks that
    // the biquad on the first source doesn't shut down early.
    var biquad1 = context.createBiquadFilter();
    osc1.connect(biquad1);
    var biquad2 = context.createBiquadFilter();
    osc2.connect(biquad2);

    var gain = context.createGain();
    gain.gain.value = -1;
    osc1.connect(gain);
    osc2.connect(gain);

    var biquadWithGain = context.createBiquadFilter();
    gain.connect(biquadWithGain);

    // The output of biquadWithGain should be the inverse of the sum of the
    // outputs of biquad1 and biquad2, so blend them together and expect
    // silence.
    var blend = context.createGain();
    biquad1.connect(blend);
    biquad2.connect(blend);
    biquadWithGain.connect(blend);

    return blend;
  },
};

runTest();

</script>
</pre>
</body>
</html>