wavwrite with 32 bits per sample seems to overflow? I am trying to generate a 32bit PCM wav file with octave, the file shall contain a single full-scale sample (0db impulse). I am getting the expected result when using 24 bits per sample:

&gt;&gt; wavwrite(1, 96000, 24, 'foo.wav');
&gt;&gt; wavread('foo.wav')
ans =  1.00000                          # as expected


However, when using 32 bits per sample, the value seems to overflow.

&gt;&gt; wavwrite(1, 96000, 32, 'foo.wav');
&gt;&gt; wavread('foo.wav')
ans = -1                                # WHAT ?!


I am expecting the second wavread('foo.wav') to return 1 not -1. I have checked the wav file with a hex editor, the sample raw value is 0x80000000, I am expecting it to be 0x7fffffff.
Is it an octave bug or am I missing something?

Using 0.99999 instead of 1 generates the expected result.
It seems like it is a bug. Octave's wavwrite() function writes 32-bit wav in 32 bits int (type 1 format) instead of normalized 32-bit floats (type 3 format). Unfortunately, 1 can't be represented in 32-bit type 1 format which is why you get this result.
The solution could be to use the audiowrite() function, or to write 0x7fffffff instead of 1.
More about wav formats.
EDIT: seems from the bug report that the audiowrite function has the same problem...