-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
BUG: read tries to handle 20-bit WAV files but shouldn't #5990
Conversation
Currently it only handles np.int* types.
@@ master #5990 diff @@
======================================
Files 238 238
Stmts 43757 43757
Branches 8218 8218
Methods 0 0
======================================
Hit 34182 34182
Partial 2604 2604
Missed 6971 6971
|
Agreed.
By normalizing by MAX_INT for the appropriate type? Agreed. PRs welcome when you get time. |
I think the manual list is okay for now. Hopefully you can make it better soon :) Good to merge from your end? |
Actually normalizing to BitsPerSample from the headers, in case it's not a multiple of 8, and shifting from unsigned for BitsPerSample from 1 to 8. and if it doesn't normalize, it should return the bit depth as well as fs and data.
yes |
This one would be tougher because it would be a backward-incompatible change, but I suppose you could add a |
BUG: read tries to handle 20-bit WAV files but shouldn't
Thanks @endolith |
This resulted in 24 test errors on my 32-bit Python install. Introduced in scipygh-5990.
Actually maybe that should be a separate function? This one is only for converting to exact equivalent dtypes, when possible? |
A |
This resulted in 24 test errors on my 32-bit Python install. Introduced in scipygh-5990.
Audition can save WAV files as "24-bit packed int (type 1, 20-bit)" format where each sample is 3 bytes and BitsPerSample = 0x14 = 20. SciPy tries to open it and interprets it as 16-bit and it's all screwed up. Changed the handling to only accept bits per sample that align with numpy int types.
I guess it would be better if it read the byte lengths from numpy itself instead of a hardcoded list?
Though better yet would be to read any bit depth of file and store it as the next-highest numpy int type.
(And should also have a
norm=True
or something option that converts every type to normalized floating point from -1 to +1 so you don't have to do that yourself, same as scikits.audiolab.)