rodio/tests/lmms32bit.wav
Aaron Kofsky d20a3c661e Fix reading WAV of different encodings. (#199)
* Read 32 bit float and 24 bit int encoded files correctly.

Before, we were assuming that all WAV files are encoded as 16 bit integers.
This is not true, WAVs can actually also be encoded as 32 bit floats and
24 bit integers. Hound returns `Err` when we attempt to read files as the
wrong encoding, which was getting `unwrap_or`'d to just zero. This explains
why the file would load but not play any sound. We fix this by first
checking for the appropriate encoding, and then converting to an i16. This
might cause some slight dither issues but hopefully it is quiet enough that
it doesn't matter.

Fixes #195.

* Add tests of reading wav files different encodings

* Use `.map()` instead of control flow & unwrapping.

This makes things slightly cleaner to read.
Also remove extraneous print statement.
2018-11-09 21:58:43 +01:00

590 KiB