wavread has a misleading error message
Reported by Federico Miyara
BUG DESCRIPTION:
----------------
The code of function wavread contains the following error message at line 280
error(msprintf(gettext("%s: An error occurred: %s\n"), "read_dat_pcm", gettext("Cannot read .wav file with more than 16 bits per sample.")));
This is triggered when the number of bytes per sample is none of 1, 2, 3 or 4. However, when it is 3 or 4 the number of bits is 24 or 32, which are greater than 16 and yet valid number of bits which are correctly processed. The error message that would appear in an unsupported case is misleading, inducing the user to think they cannot open 24 bit or 32 bit wav files, which is not the case.
ERROR LOG:
----------
N/A
HOW TO REPRODUCE THE BUG:
-------------------------
I didn't test it with a real file, but I suppose that manually replacing the number of bits per sample in a valid wav file by 0 or 33 will trigger the message since ceil(0/8)==0 and ceil(33/8)==5. In both cases the error message would be
Cannot read .wav file with more than 16 bits per sample.
which is not true for the reason mentioned in the bug description
OTHER INFORMATION:
------------------
I think the bug comes from when 24 bit and 32 bit were not yet supported, and when updating somebody forgot to change the error message.
The error message line should be replaced by
error(msprintf(gettext("%s: An error occurred: %s\n"), "read_dat_pcm", gettext("Cannot read .wav file with less than 1 or more than 32 bits per sample.")));
Changes: 1) A duplicate space has been removed; 2) "more than 16" has been replaced by "less than 1 or more than 32"