HTMLAudioElement: decoding without throttling

Stack Overflow Asked by Joe Meadows on December 16, 2020

I am processing audio files in a browser with Javascript. I’m mostly happy with how it’s working except that the Audio object (used to decode the file) seems to throttle the data stream to somewhere in the neighborhood of the playback rate. I am looking for a way to make the Audio object burst through the entire file without throttling.

Here’s a closer look at what I’ve got set up:

After instantiating an Audio object I call AudioContext.createMediaElementSource() to obtain a MediaElementAudioSourceNode for the Audio object. I’ve got a barebones AudioWorkletProcessor (1 stereo input, 0 outputs) that is connected to the output of this source node. Its job is to take the input data and send it back to the main thread in a message where it gets saved in an IndexedDB. Technically this is all working, but it takes as long to ingest a file as it would to play it.

  • I’ve looked into OfflineAudioContext, but it doesn’t have the createMediaElementSource() method.
  • I can’t use decodeAudioData() because the decoded results are too large for memory.
  • I would like to avoid using third party Javascript libs to do the decoding since the Audio class is capable of decoding any of the formats that I’m interested in.

Any suggestions for how to get the Audio object to run ‘wide open’, or an alternative solution that can be implemented with native browser APIs?

Thanks in advance!


Add your own answers!

Related Questions

Bluehost hosted React pages not found

0  Asked on November 10, 2021 by paul-lindberg


Change a view margins programmatically

4  Asked on November 10, 2021 by m-r_dino


React returning view from switch statement

1  Asked on November 10, 2021 by mattblack


Find string then return different row value Python

0  Asked on November 10, 2021 by newtothecrew


React JS – route does not pick the required Component

0  Asked on November 10, 2021 by nirjal-paudel


get character after space of array value on javascript

9  Asked on November 7, 2021 by riko-pramayudi


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP