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

WavDecoder don't support bit depth greater than 16 #2

Closed
Rodrigodd opened this issue Jun 30, 2022 · 1 comment
Closed

WavDecoder don't support bit depth greater than 16 #2

Rodrigodd opened this issue Jun 30, 2022 · 1 comment

Comments

@Rodrigodd
Copy link
Owner

Rodrigodd commented Jun 30, 2022

The WavDecoder uses hound to decode the WAV to i16 samples, but hound return a Result that errors when the target format is smaller than the bit depth of the file, or is in the wrong format (float vs int). audio-engine is currently unwrapping this Result and panicking.

audio-engine should not panic. Should at least decode the samples as i32 or f32 and convert them to i16 (and ideally support more sample formats).

Relevant source code:

audio-engine/src/wav.rs

Lines 36 to 48 in b256adb

#[allow(clippy::needless_range_loop)]
fn write_samples(&mut self, buffer: &mut [i16]) -> usize {
let mut samples = self.reader.samples::<i16>();
for i in 0..buffer.len() {
if let Some(sample) = samples.next() {
buffer[i] = sample.unwrap();
} else {
return i;
}
}
buffer.len()
}

@Rodrigodd
Copy link
Owner Author

@markusmoenig Fixed on 0.3.0 by 775e7e5.

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

1 participant