[Date Index] [Thread Index] [Author Index]
Re: Won't Read Entire Soundfile; Why?
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:= 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:=Length[noise1] > Out=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 primenet.com The code for ReadSoundfile in Miscellaneous`Audio` is buggy. Although it parses the header for all WAV formats, it only works for 8-bit formats. 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 door...it seems as though it was only partially finished. They really ought to post a bug-fix version on MathSource. Mark Evans evans at gte.net