anthumchris / fetch-stream-audio

Low Latency web audio playback examples for decoding audio streams in chunks with Fetch & Streams APIs
https://fetch-stream-audio.anthum.com
MIT License
378 stars 23 forks source link

Reduce Number of AudioBuffers Created #11

Closed anthumchris closed 4 years ago

anthumchris commented 4 years ago

Opus is decoding so quickly (20ms frames) that hundreds of AudioBuffer objects are being created. This causes performance issues for larger files and would generate up to 20,000 objects created for 5 minute files.

After the first frames are decoded and scheduled to be played, the remaining decoded frames do not need to be scheduled so quickly. Ideally, decoded audio would only be scheduled when needed (during seeking or a few seconds before it is to be played). Because this is a developer demo, a fast path of making AudioBuffers larger and fewer will be taken.