Suppose I read a file with

B = Import["something.wav"]

Now how can I obtain a list of sample values?


1 Answer 1


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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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