TransWikia.com

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!

Joe

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP