Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose I read a file with

B = Import["something.wav"]

Now how can I obtain a list of sample values?

share|improve this question
up vote 15 down vote accepted

You want this:

data = Import["test.wav", "Data"]

This imports the raw data of sample values. For example, on a test file of approximately 10 seconds, stereo at 48000 Hz, data is an array of size 2 × 520192 (from which I can deduce that my recording was actually 10.84 seconds).

See the documentation for WAV format import/export, as well as this answer on a related question for some more details.

Going at it differently, if you already have imported your file as a Sound object (as in your example), you can still recover the sample data. Inside your Sound object is a SampledSoundList:

In[25]:= Head@First@B
Out[25]= SampledSoundList

This in turn contains the raw data:

In[26]:= Length@B[[1, 1]]
Out[26]= 2

In[27]:= Table[Length@B[[1, 1, i]], {i, 1, 2}]
Out[27]= {520192, 520192}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.