Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Won't Read Entire Soundfile; Why?

  • To: mathgroup at
  • Subject: [mg7420] Re: [mg7388] Won't Read Entire Soundfile; Why?
  • From: Mark Evans <evans at>
  • Date: Sat, 31 May 1997 15:07:33 -0400 (EDT)
  • Organization: None
  • Sender: owner-wri-mathgroup at

Neal E. Tornberg wrote:
> I generate a white noise file externally in *.wav format on a PC.
> This is generated as a mono file, 16 bit sampling, 16000 samples/sec,
> for 2 seconds
> I set up noisefile=<filename>  (i.e. a string containing the file's
> path and name) and read it in.  Note what happens to its length:
> In[12]:= noise1=ReadSoundfile[noisefile,        PrintHeader->True];
>         Format: Multimedia Wave
>         Duration: 2.0 Seconds
>         Channels: 1
>         Sampling Rate: 16000
>         Bits per sample: 16
>         Data size: 64000 bytes
>         Number of samples: 32000
> In[13]:=Length[noise1]
> Out[13]=469
> If I regenerate the file or change its amplitude the resulting length
> changes, but is always the same for the same file.
> Can anyone tell me what's going on and how I can force the entire file
> to be read?
> Thanks
> Neal E. Tornberg
> tornberg at

The code for ReadSoundfile in Miscellaneous`Audio` is buggy.  Although
it parses the header for all WAV formats, it only works for 8-bit

My suggestion is to take a look at the module definition, and make your
own version that reads 16-bit, taking into account little-endian vs.
big-endian issues, or to settle for using 8-bit WAV files only.

It was very surprising to me that WRI let this package out the
seems as though it was only partially finished.  They really ought to
post a bug-fix version on MathSource.

Mark Evans
evans at

  • Prev by Date: Re: A Plot to Rotate
  • Next by Date: Re: Getting values from a Plot
  • Previous by thread: Plot Rotation solution
  • Next by thread: Re: Getting values from a Plot