RustAudio / rodio

Rust audio playback library
Apache License 2.0
1.74k stars 228 forks source link

Make `DynamicMixer` and `OutputStream` generic #547

Open eira-fransham opened 7 months ago

eira-fransham commented 7 months ago

This commit adds a new trait, Mixer, and refactors some of the code around generic mixers in order to support it. This is to make more of the code reusable without rewriting - specifically, to support a feature that I would like to implement in bevy_audio where audio sources can send audio to an intermediate mixer. The motivation for this was to add a global limiter to all game audio, so that loud sounds did not cause clipping on the master bus, but another possible usecase would be to split in-game audio and menu audio into separate "worlds" and apply, for example, a low-pass filter while in the pause screen.

eira-fransham commented 7 months ago

It looks like the test failures are due to unrelated code, and are because of the addition of redundant import checks to unused_imports.

eira-fransham commented 7 months ago

A more-minimal version of this PR would just make OutputStream generic, which would still allow reusing rodio's mixer without adding an actual interface around creating your own.

dvdsk commented 6 months ago

Could you rebase this on main? (or merge main into it). Then you'll get the fixed (thanks @hamirmahal) test suite.

hamirmahal commented 6 months ago

You're welcome, @dvdsk!