Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WavReader may be too strict on WAVEFORMATEX data #20

Closed
cormac-obrien opened this issue Feb 14, 2018 · 6 comments
Closed

WavReader may be too strict on WAVEFORMATEX data #20

cormac-obrien opened this issue Feb 14, 2018 · 6 comments

Comments

@cormac-obrien
Copy link

At least one of the WAV files used by Quake (pak0.pak/sound/doors/baseuse.wav) results in FormatError("unexpected WAVEFORMATEX size") when trying to open it. This file opens and plays successfully in mplayer, VLC and mpv.

Using hound 3.3.0:

extern crate hound;

fn main() {
    let _ = hound::WavReader::open("baseuse.wav").unwrap();
}

Output:

$ cargo run
(...)
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: \
    FormatError("unexpected WAVEFORMATEX size")', libcore/result.rs:916:5

Perhaps this should be a warning instead of a fatal error?

(This is using pak0.pak with md5sum 85fc9cee2035b66290da1e33be2ac86b)

@ruuda
Copy link
Owner

ruuda commented Feb 15, 2018

Thanks for reporting! If the struct has an unexpected size, it might have fields in there that need to be taken into account, or other fields could be at different offsets. It is possible that we can figure out the meaning, or that these fields can be safely ignored, but I would have to look at the file. Are you able to share a file to reproduce this issue? If copyright is an issue, you can truncate the file after the first 100 or so bytes of audio data. (In a hex editor, look for the string data, that is the start of the audio data chunk.) The resulting file will be corrupt, but it should be enough to understand how to read the header.

@cormac-obrien
Copy link
Author

cormac-obrien commented Feb 15, 2018

First 200 bytes of the file are here.

@ruuda
Copy link
Owner

ruuda commented Feb 17, 2018

Thanks! I believe the file is actually valid and Hound was being too restrictive. I pushed a fix to master, could you please confirm that you are now able to read the file?

@cormac-obrien
Copy link
Author

Yep! This fixes the problem. Thanks for the quick update!

@ruuda
Copy link
Owner

ruuda commented Feb 18, 2018

Great, I’ll make a new release then.

@ruuda ruuda closed this as completed Feb 18, 2018
@ruuda
Copy link
Owner

ruuda commented Feb 18, 2018

Hound v3.3.1 is now on crates.io.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants