Ralith / oddio

Lightweight game audio
Apache License 2.0
150 stars 9 forks source link

DAG topology #52

Open Ralith opened 3 years ago

Ralith commented 3 years ago

oddio presently only has good support for signals and filters arranged in trees. It's unclear if there's a compelling use case for more complex graph topology; if you have one, please comment!

The primary difficulty in resolving this is that Signal::sample implicitly advances time, so if a single signal must be sent to multiple places, it must be buffered. Additionally, because multiple consumers might sample over differing amounts of time, the buffering logic is non-trivial.

One approach would be to define a special Fork filter that allows any number of handles to be produced (via an internal Arc) which tracks the relative positions of each handle, and buffers at least enough samples to cover the difference between the earliest and latest handle. To avoid dynamic allocation on the audio thread, a maximum buffer size would be needed up front.