Skip to content

Instantly share code, notes, and snippets.

@paulschwoerer
Created July 13, 2023 20:37
Show Gist options
  • Select an option

  • Save paulschwoerer/57e92f20ffb11fee4db4c286d717db3f to your computer and use it in GitHub Desktop.

Select an option

Save paulschwoerer/57e92f20ffb11fee4db4c286d717db3f to your computer and use it in GitHub Desktop.

Revisions

  1. paulschwoerer created this gist Jul 13, 2023.
    44 changes: 44 additions & 0 deletions chromium-createIIRFilter-bug.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    <!--
    Run the following file in Firefox and Chromium.
    It has been observed, that createIIRFilter() takes around 50ms to complete in Chromium-based browsers on Linux (Ubuntu, Gnome, PulseAudio).
    In Firefox, it takes <1ms.
    createBiquadFilter() has been included as a reference.
    It takes <1ms in both browsers.
    -->

    <!DOCTYPE html>
    <html>

    <head>
    <meta charset="UTF-8" />
    <title>WebAudioAPI IIR Filter Bug</title>
    </head>

    <script type="module">
    const ctx = new OfflineAudioContext({
    length: 1,
    sampleRate: 44100,
    numberOfChannels: 1
    });

    const feedback = [1, -1.9635105015543133, 0.9658787263376775];
    const feedforward = [0.017060636575783206, 0, -0.017060636575783206];

    const t1 = performance.now();
    const iirNode = ctx.createIIRFilter(feedforward, feedback);
    const t2 = performance.now();

    console.log(`createIIRFilter() took: ${t2 - t1}ms`);

    const t3 = performance.now();
    const biquadNode = ctx.createBiquadFilter();
    const t4 = performance.now();

    console.log(`createBiquadFilter() took: ${t4 - t3}ms`);
    </script>

    <body>
    See console
    </body>

    </html>