Re: Importing part of a WAV file
- To: mathgroup at smc.vnet.net
- Subject: [mg60686] Re: Importing part of a WAV file
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Sat, 24 Sep 2005 02:55:29 -0400 (EDT)
- Organization: The Open University, Milton Keynes, U.K.
- References: <dh0ecg$q3i$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hugh Goyder wrote: > 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? Hi Hugh, About data organization you may check the following URLs: http://ccrma.stanford.edu/courses/422/projects/WaveFormat/ http://www.sonicspot.com/guide/wavefiles.html http://www.tsp.ece.mcgill.ca/MMSP/Documents/AudioFormats/ (this one contains also samples of different audio file formats). Hope this helps, /J.M.