Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.44k stars 977 forks source link

Dynamic Offline Bounce Duration #1229

Closed jakiestfu closed 5 months ago

jakiestfu commented 6 months ago

If I were to add reverb or a ping pong delay to any source node, I’d like the ability to bounce this with tone.offline to include the effect audio tail.

only thing I can think to do is render a large time and attempt to analyze when audio stops, then trim. Doesn’t feel like a performant solution.

any thoughts or recommendations? I understand there may be a compromise in performance somewhere

tambien commented 5 months ago

Interesting request, this probably isn't possible. The OfflineAudioContext needs to know the size ahead of time. There's also another issue about figuring out when feedback delays actually end. The feedback is potentially infinite, but if it's a decaying feedback, at some point the values are too small to be represented.

The problem is a little easier with the Convolver-based reverbs since those have a known duration, so you should hopefully just be able to add the decay time to the end of the duration to keep your reverb tails from being cut off.

hope that helps!