'Is it possible to set the length of an OfflineAudioContext after creation/just before rendering?

in a web audio project, I have an online- and an offline audio context, the latter one mirroring the former. The problem is, I don't know the final length of the audio I want to generate, but I have several AudioWorklets that need to be created beforehand, so they can receive user input, etc.

So when calling startRendering on the offline context, it just renders the length specified at creation time.

The length property seems to be read-only.

Is there really no way to set the length just before rendering ?

Best, N



Solution 1:[1]

There is currently no way to do this. But there is an issue filed on the spec to enable incremental rendering. Maybe you can add your use case there.

https://github.com/WebAudio/web-audio-api/issues/2445

For now it might work if you create proxies for your worklets that collect the user input upfront before you create the actual OfflineAudioContext with the real worklets.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 chrisguttandin