11
$\begingroup$

Suppose I read a file with

B = Import["something.wav"]

Now how can I obtain a list of sample values?

$\endgroup$
18
$\begingroup$

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}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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