Skip to content

saving 24bit WAV files results in "non standard" file, at least according to LibSndFile sndfile-info command line tool #112

@perrinmeyer

Description

@perrinmeyer

It appears that WAV.jl saves "non standard" WAV files for 24bit Integer PCM (which is an industry standard in professional audio).

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)

I then use sndfile-info from the LibSndFile package to look at the file, and it complains that CHANNEL MASK should not be zero, and it says

**** All non-PCM format files should have a 'fact' chunk.

if I then use sndfile-convert to convert it to a wav file, snd-file convert seems to "fix" the wave file, and sndfile-info gives a more reasonable WAV file (i.e. the format is "Format : 0x1 => WAVE_FORMAT_PCM" and it no longer complains about the channel mask

the details:

psm_m4:~/perrin2013/SCaRF_Julia/LibSndFile/$ sndfile-info test_WAV_dot_jl__24bit.wav 
========================================
File : test_WAV_dot_jl__24bit.wav
Length : 49981244
RIFF : 49981236
WAVE
fmt  : 40
  Format        : 0xFFFE => WAVE_FORMAT_EXTENSIBLE
  Channels      : 2
  Sample Rate   : 44100
  Block Align   : 6
  Bit Width     : 24
  Bytes/sec     : 264600
  Valid Bits    : 24
  Channel Mask  : 0x0 (should not be zero)
  Subformat
    esf_field1 : 0x1
    esf_field2 : 0x0
    esf_field3 : 0x10
    esf_field4 : 0x80 0x0 0x0 0xAA 0x0 0x38 0x9B 0x71 
    format : pcm
data : 49981176
End
**** All non-PCM format files should have a 'fact' chunk.

----------------------------------------
Sample Rate : 44100
Frames      : 8330196
Channels    : 2
Format      : 0x00130003
Sections    : 1
Seekable    : TRUE
Duration    : 00:03:08.893
Signal Max  : 8.29363e+06 (-0.10 dB)

========================================================================================
========================================================================================
========================================================================================
oops

psm_m4:~/perrin2013/SCaRF_Julia/LibSndFile/$ sndfile-convert test_WAV_dot_jl__24bit.wav test_sndfile_convert_24bit.wav

and now:

psm_m4:~/perrin2013/SCaRF_Julia/LibSndFile/$ sndfile-info test_sndfile_convert_24bit.wav 
========================================
File : test_sndfile_convert_24bit.wav
Length : 49981220
RIFF : 49981212
WAVE
fmt  : 16
  Format        : 0x1 => WAVE_FORMAT_PCM
  Channels      : 2
  Sample Rate   : 44100
  Block Align   : 6
  Bit Width     : 24
  Bytes/sec     : 264600
data : 49981176
End

----------------------------------------
Sample Rate : 44100
Frames      : 8330196
Channels    : 2
Format      : 0x00010003
Sections    : 1
Seekable    : TRUE
Duration    : 00:03:08.893
Signal Max  : 8.29363e+06 (-0.10 dB)

[ so WAV.jl outputs in a slightly funny format but sndfile-convert makes it whole again... nice ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions