Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Suppose I read a file with

B = Import["something.wav"]

Now how can I obtain a list of sample values?

share|improve this question

1 Answer 1

up vote 11 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 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}
share|improve this answer

Your Answer

 
discard

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.