[Pkg-octave-devel] Re: Bug#408268: marked as done (octave2.9-forge: wavwrite writes invalid WAV files)

Rafael Laboissiere rafael at debian.org
Sun Feb 4 22:22:05 CET 2007


* Thomas Weber <thomas.weber.mail at gmail.com> [2007-02-04 21:53]:

> Am Sonntag, 4. Februar 2007 21:11 schrieb Rafael Laboissiere:
> > > Eh, in that case a file with only one channel should be written,
> > > shouldn't it?
> >
> > Indeed:
> >
> > $ octave2.9 -q
> > octave2.9:1> wavwrite('noise.wav', randn(65536,1));
> > warning: wavwrite: sample rate set to 8000 Hz
> > warning: wavwrite: sample resolution set to 16-bit
> > octave2.9:2> exit
> > $ file noise.wav
> > noise.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit,
> > mono 8000 Hz $ ls -l noise.wav
> > -rw-r--r-- 1 rafael rafael 131116 2007-02-04 21:10 noise.wav
> 
> Yes, but if I write a .wav-file with a 1x50000 matrix, the resulting file 
> should have 50000 channels. The current code however generates a file with 
> 32767 channels.
> 
> octave2.9:1> a = rand(1,50000);
> octave2.9:2> wavwrite('noise.wav', a)
> octave2.9:3> system ("file noise.wav")
> noise.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, 32767 
> channels 8000 Hz
> ans = 0

This seems to be a limitation of the RIFF/WAV format [1]

    WAVE Format Chunk

      The WAVE format chunk <fmt-ck> specifies the format of the
      <wave-data>. The <fmt-ck> is defined as follows:

      <fmt-ck> ->   fmt( <common-fields>
                       <format-specific-fields> )

      <common-fields> ->
            struct
            {
               WORD wFormatTag;              // Format category
               WORD wChannels;               // Number of channels
               DWORDdwSamplesPerSec;         // Sampling rate
               DWORDdwAvgBytesPerSec;        // For buffer estimation
               WORD wBlockAlign;             // Data block size
            }


It guess that "WORD" is a signed 16-bits integer, whose maximum value is
2^15 - 1.

-- 
Rafael

[1] http://www.neurophys.wisc.edu/auditory/riff-format.txt



More information about the Pkg-octave-devel mailing list