tesselode / kira

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

Fixed device config selection #2

Closed Moxinilian closed 3 years ago

Moxinilian commented 3 years ago

Fixes #1

The reason for not using default_output_config is because as we don't support surround sound at all, cpal's heuristic might not be the most appropriate (we would like to keep the device in stereo mode to reduce buffer sizes, notably).

I also introduced a cap at 48kHz users can customize. I had to update cpal in the process as there was a bug in 0.12 that prevented picking the sample rate.

A good thing to do now would be to support i16 and u16 output as well. It probably would not be that hard to just cast them every single time.

tesselode commented 3 years ago

@xelivous can you check if this fix works well on your system?

xelivous commented 3 years ago

Yea the sound plays without any panics using a modified version of the example in the readme.

edit: Having tested out the max_sample_rate parameter just now, it's a little annoying that it requires the SampleRate struct directly from cpal, since clients using kira would then need to add cpal to their cargo.toml with the exact version used in kira in order to use that parameter. Would likely be better to just have that param take a u32 and then constuct a SampleRate struct when needed to pass to cpal tbh.

tesselode commented 3 years ago

Fixed separately in v0.1.2 (but with input from Moxinillian!)