tesselode / kira

Library for expressive game audio.
https://crates.io/crates/kira
Apache License 2.0
836 stars 42 forks source link

Allow adding `Box<dyn Effect>` to tracks directly #83

Closed SolarLiner closed 2 months ago

SolarLiner commented 2 months ago

Hi, I'm working on a alternative integration of Kira for Bevy and I find myself backed a little into a corner wrt. creating tracks with effects. I'd like to rely as little as possible on the TrackBuilder, instead having users insert components for the track settings and children for the effects, however it's currently not possible to build the effect yourself without the track builder, and then insert the built effect into the track builder at a later point.

Right now it's pretty much impossible to do without a multi-step system and requires bidirectional communication between the track and effect systems, which creates a lot of unnecessary complexity.

So the solution I've been imagining is either an additional method for directly inserting the Box<dyn Effect> into the track builder, or having Box<dyn Effect> also be itself an effect builder, with a () handle.

tesselode commented 2 months ago

Yeah that seems like a good feature to have. I think having separate methods on the TrackBuilder like add_built_effect and with_built_effect would be less surprising than implementing EffectBuilder for Box<dyn Effect>, so I'm more in favor of that option. If you make a PR, I'll merge it. Otherwise, I'll probably implement it myself at some point.