RustAudio / audrey

A crate to simplify reading, writing and converting between a variety of audio formats.
Other
132 stars 16 forks source link

Fix flac sample conversion #25

Closed panicbit closed 4 years ago

panicbit commented 4 years ago

Claxon only outputs u32 samples and doesn't scale from the bit depth of the stream to 32 bits. As a result, audrey's sample conversion reduces the volume extremely. This PR tries to work around this problem.


This change is Reviewable

panicbit commented 4 years ago

23 seems to fixe the same issue 😩

panicbit commented 4 years ago

23 uses sample << (32 - sample_bits) to shift the samples, but that seems to be not quite right to me. Wouldn't that compress the volume range?

est31 commented 4 years ago

Wouldn't that compress the volume range?

How would it compress it? To me it seems that the shift only ensures that the topmost bit of the input data is also the topmost bit of the output data.

panicbit commented 4 years ago

I think it's fine. The samples crate does it that way too. Closing this in favor of #23.