# How to extract sample values from an imported WAV file?

Suppose I read a file with

B = Import["something.wav"]


Now how can I obtain a list of sample values?

-
add comment

## 1 Answer

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 WAF format import/export, as well as this answer on a related question for some more details

Going at it different, 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}

-
add comment