Commit graph

39 commits

Author SHA1 Message Date
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
Francesco Zardi
6a8c71bdb2 Run cargo fmt 2018-04-19 10:03:48 +02:00
Francesco Zardi
74ceb63c3c Update cpal dependency to 0.7
The update required adapting to the breaking changes introduced by the new version, as reported in the `cpal`'s
[changelog](a2fe9386af/CHANGELOG.md), namely:

- Rename `ChannelsCount` to `ChannelCount`.
- Rename `SamplesRate` to `SampleRate`.
- Rename the `min_samples_rate` field of `SupportedFormat` to `min_sample_rate`
- Rename the `with_max_samples_rate()` method of`SupportedFormat` to `with_max_sample_rate()`
- Rename the `samples_rate` field of `Format` to `sample_rate`
- Changed the type of the `channels` field of the `SupportedFormat` struct from `Vec<ChannelPosition>` to `ChannelCount` (an alias to `u16`)
2018-04-18 14:24:33 +02:00
Pierre Krieger
88b0d40e4b Run rustfmt on the code 2017-07-03 10:10:00 +02:00
Pierre Krieger
44a8a2b923 Rustfmt 2017-05-04 13:51:33 +02:00
Pierre Krieger
7df741665d Rename methods of the Source trait 2017-05-01 11:11:33 +02:00
Pierre Krieger
642f11c824 Run rustfmt on the code 2017-02-01 10:14:50 +01:00
Pierre Krieger
5d58d9188f Add some docs at various places 2015-10-22 20:30:07 +02:00
Pierre Krieger
9d80295d5d Better duration handling 2015-10-16 14:02:44 +02:00
Pierre Krieger
2e09c3494d Remove the Decoder trait and switch to the Source trait 2015-10-16 13:35:30 +02:00
Pierre Krieger
95b2f5a45e Fix the wav decoder 2015-09-27 10:50:11 +02:00
Pierre Krieger
112c8c94e5 Use a proper type for WAVE decoding instead of a Box 2015-09-27 10:41:46 +02:00
Pierre Krieger
f339184d75 Fix all warnings 2015-09-27 10:24:41 +02:00
Pierre Krieger
bc6f78de4c Handle the volume in the engine core instead of the decoders 2015-09-27 10:04:32 +02:00
Pierre Krieger
92a4567f08 Start using one voice per endpoint and mixing samples manually 2015-09-27 09:56:29 +02:00
Pierre Krieger
a6b5197a59 Use loops of 17ms 2015-09-27 08:58:40 +02:00
Pierre Krieger
43171fab08 Remove sounds that are finished playing 2015-09-24 12:56:36 +02:00
tomaka
8f623f757c Merge pull request #24 from tomaka/fix-warnings
Fix warnings
2015-09-23 18:32:27 +02:00
Pierre Krieger
86eab17039 Fix the vorbis decoder 2015-09-23 17:11:44 +02:00
Pierre Krieger
4ca0c7f42a Fix warnings 2015-09-23 10:57:43 +02:00
Pierre Krieger
5060063e5d Also add get_total_duration_ms() 2015-09-23 10:47:15 +02:00
Pierre Krieger
5c68d37055 Add Handle::sleep_until_end and rework decoder handling 2015-09-23 10:33:45 +02:00
Pierre Krieger
ba13cb3da0 Fix samples rate converter not working when from == to 2015-09-22 21:47:09 +02:00
Pierre Krieger
65f699038d Remove a debugging println! 2015-09-22 21:21:26 +02:00
tomaka
5058b708a8 Merge pull request #19 from tomaka/prefer-wav-format
Prefer the more lightweight compatible format for WAV
2015-09-22 21:09:28 +02:00
Pierre Krieger
0ba1f4ee4e Prefer the more lightweight compatible format for WAV 2015-09-22 20:24:34 +02:00
Pierre Krieger
5848128386 Fix wav waiting time and improve background thread sleeping functionnality 2015-09-22 17:58:03 +02:00
tomaka
930f9b30e9 Merge pull request #16 from tomaka/faster-format-determination
Faster format determination for wav files
2015-09-22 16:59:02 +02:00
Pierre Krieger
24252a64fe Faster format determination for wav files 2015-09-22 16:49:36 +02:00
Pierre Krieger
580e0c4309 Fix samples rate converter not taking interleaved channels into account 2015-09-22 11:20:08 +02:00
Pierre Krieger
cefae3aa51 Reorganize the conversions module 2015-09-11 16:52:44 +02:00
Pierre Krieger
338114d93e Add set_volume to Handle 2015-09-11 13:49:07 +02:00
Pierre Krieger
b0652147c2 Use hound from crates.io 2015-09-11 11:57:02 +02:00
Pierre Krieger
056a56950e Add proper sleeps in the engine 2015-09-11 10:04:13 +02:00
Pierre Krieger
df063c075c Choose the most suitable voice format 2015-09-10 17:20:42 +02:00
Pierre Krieger
89abf72790 Update to cpal 0.2 2015-09-10 16:17:37 +02:00
Pierre Krieger
e4a246a08f Remove the WAV hack to bypass the cpal bug 2015-07-22 14:31:02 +02:00
Pierre Krieger
5a438bcdec Add support for vorbis decoding 2015-07-22 14:23:03 +02:00
Pierre Krieger
824b4f0041 Initial commit 2015-07-22 12:14:11 +02:00