 
 
 
 
 
 
Importing part of a WAV file
- To: mathgroup at smc.vnet.net
- Subject: [mg60645] Importing part of a WAV file
- From: "Hugh Goyder" <h.g.d.goyder at cranfield.ac.uk>
- Date: Fri, 23 Sep 2005 04:19:48 -0400 (EDT)
- Organization: University of Warwick, UK
- Sender: owner-wri-mathgroup at wolfram.com
I have some long sound files in WAV format. Typically files are of length 26
MB. These files are too long to read in using Import["filename.wav"] and
anyway I just want portions of the file for Fourier analysis and so I don't
even want the data in sound file format. How can I read in a fixed number of
data points from a specified part of the file? To experiment I started with
generating a short sound file and exporting it as a WAV file. The following
code does this.
vals = {f0 -> 1000, tt -> 5, inc -> 1./8192};
f = 2*Pi*(f0*t - (f0/(2*tt))*t^2) /. vals;
e = Table[Evaluate[Sin[f]], {t, 0., tt /. vals, inc /. vals}];
Length[e]
e1 = ListPlay[e];
Export["t1.wav", e1]
Attempts at reading part of the file fail. I can read in the whole file but
not part of it. In the example below Read does not give any sensible answer.
Should I be using something other than Record? Is this a case for
BinaryRead? What is the correct approach? How is the data in WAV files
organised?
str = OpenRead["t1.wav"]
s1 = Read[str, Record]
Close[str]
Thanks
Hugh Goyder

