tesselode / kira

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

Add effect on existing audio track #99

Open kz-n opened 1 month ago

kz-n commented 1 month ago

Would it be possible to add an effect to an existing audio track in real time? The only solution i could think for doing this would be to create a new audio track with desired effect, destroy the sound handle, recreate it, set the playback to where it left off and then play the sound there, but that seems unreasonably complex. I would try to contribute this kind of feature directly but i'm a beginner to rust so I'm not sure where i would start

fairywreath commented 1 month ago

The effects themselves have handles that you can modify in runtime. For example, you can set the mix to 0.0 to have a completely dry sound then turn it 1.0 at some later point in time to “add the effect”. You can also tune other effect parameters dynamically.

Alternatively you can create custom effecfs manually. A no-effect/unprocessed sound would simply have the output frame exactly the same as the input frame, and you can dynamically adjust this behavior. Note that these methods still require the effect to be attached to the track - you simply just make the effect output completely dry when you want it “off”.