For the record, I have confirmed that WAV.jl correctly writes out 24bit Signed Integer PCM WAV files.
First, I ripped a track off of CD, so its 16Bit Signed PCM at 44_100Hz sampling, as confirmed by the (excellent) soxi utility.:
psm_m4:~/perrin2013/SCaRF_Julia/LibSndFile/$ soxi JolieHollandSacha.wav
Input File : 'JolieHollandSacha.wav'
Channels : 2
Sample Rate : 44100
Precision : 16-bit
Duration : 00:03:08.89 = 8330196 samples = 14167 CDDA sectors
File Size : 33.3M
Bit Rate : 1.41M
Sample Encoding: 16-bit Signed Integer PCM
then I used WAV.jl to read in the WAV file, and then re-save as 24 bit PCM and 32bit PCM WAV files:
using WAV
y,Fs,nbits,stuff = wavread("JolieHollandSacha.wav") #16bit 44_100Hz sampling (ripped from CD)
y_int_24 = floor.(Int32,y * 2^23)
wavwrite(y_int_24,"test_WAV_dot_jl__24bit.wav",Fs=44_100,nbits=24,compression=WAVE_FORMAT_PCM)
y_int_32 = floor.(Int32,y * 2^31)
wavwrite(y_int_32,"test_WAV_dot_jl__32bit.wav",Fs=44_100,nbits=32,compression=WAVE_FORMAT_PCM)
Note that as is the custom (Matlab, Audacity), even though the original WAV file is 16bit Signed Integer PCM, wavread converts to a Float64 array scaled between -1.0 and +1.0. So when writing out I re-converted to Int32. For 24bit the scaling is 2^23, and for 32bit its 2^31.
I then read all the files into Audacity (another excellent open source audio application), and confirmed the wavforms were the same and they sound identical. I also used Audacity to save versions of original file in 24bit PCM and 32bit PCM, and I compared the file sizes, which match as expected:
psm_m4:~/perrin2013/SCaRF_Julia/LibSndFile/$ ls -larth *.wav
-rw-r--r-- 1 perrin staff 32M May 15 17:05 JolieHollandSacha.wav
-rw-r--r-- 1 perrin staff 48M May 15 20:53 test_WAV_dot_jl__24bit.wav
-rw-r--r-- 1 perrin staff 64M May 15 20:53 test_WAV_dot_jl__32bit.wav
-rw-r--r--@ 1 perrin staff 48M May 15 20:58 test_audacity_24bit_PCM.wav
-rw-r--r--@ 1 perrin staff 64M May 15 20:58 test_audacity_32bit_PCM.wav
and as expected sox is happy too:
psm_m4:~/perrin2013/SCaRF_Julia/LibSndFile/$ soxi *.wav
Input File : 'JolieHollandSacha.wav'
Channels : 2
Sample Rate : 44100
Precision : 16-bit
Duration : 00:03:08.89 = 8330196 samples = 14167 CDDA sectors
File Size : 33.3M
Bit Rate : 1.41M
Sample Encoding: 16-bit Signed Integer PCM
Input File : 'test_audacity_24bit_PCM.wav'
Channels : 2
Sample Rate : 44100
Precision : 24-bit
Duration : 00:03:08.89 = 8330196 samples = 14167 CDDA sectors
File Size : 50.0M
Bit Rate : 2.12M
Sample Encoding: 24-bit Signed Integer PCM
Input File : 'test_audacity_32bit_PCM.wav'
Channels : 2
Sample Rate : 44100
Precision : 32-bit
Duration : 00:03:08.89 = 8330196 samples = 14167 CDDA sectors
File Size : 66.6M
Bit Rate : 2.82M
Sample Encoding: 32-bit Signed Integer PCM
Input File : 'test_WAV_dot_jl__24bit.wav'
Channels : 2
Sample Rate : 44100
Precision : 24-bit
Duration : 00:03:08.89 = 8330196 samples = 14167 CDDA sectors
File Size : 50.0M
Bit Rate : 2.12M
Sample Encoding: 24-bit Signed Integer PCM
Input File : 'test_WAV_dot_jl__32bit.wav'
Channels : 2
Sample Rate : 44100
Precision : 32-bit
Duration : 00:03:08.89 = 8330196 samples = 14167 CDDA sectors
File Size : 66.6M
Bit Rate : 2.82M
Sample Encoding: 32-bit Signed Integer PCM