0
$\begingroup$

When I try to do a Fourier analysis of a WAV file with a sample rate of 22050 I get an error "Cannot take positions". What am doing wrong?

In[5]:= Import[path,"Options"]
Out[5]= {AudioChannels->1,AudioEncoding->Integer16,SampleRate->22050}

In[13]:= ListLinePlot[Abs[Fourier[signal2[[0;;22050]]]]]
During evaluation of In[13]:= Part::take: Cannot take positions 0 through 22050 in {-0.139099,-0.143005,-0.147125,-0.149109,-0.14563,-0.136719,-0.12442,-0.102112,-0.0857239,-0.0933228,-0.115112,-0.132629,-0.14621,-0.165161,-0.18399,-0.194122,-0.194702,-0.184052,<<15>>,0.144867,0.124451,0.100403,0.0848694,0.0855713,0.100586,0.11911,0.128052,0.123932,0.110077,0.0941772,0.0918274,0.107971,0.134216,0.157959,0.176849,0.187927,<<905296>>}. >>
During evaluation of In[13]:= Fourier::fftl: Argument RowBox[{\({\(-0.13909912109375`\), \(-0.14300537109375`\), \(-0.147125244140625`\), \(-0.14910888671875`\), \(-0.1456298828125`\), \(-0.13671875`\), \(-0.124420166015625`\), \(-0.10211181640625`\), \(-0.085723876953125`\), \(-0.09332275390625`\), \(-0.1151123046875`\), \(-0.13262939453125`\), \(-0.146209716796875`\), \(-0.1651611328125`\), \(-0.183990478515625`\), \(-0.194122314453125`\), \(-0.1947021484375`\), \(-0.184051513671875`\), \(<< 15 >>\), 0.144866943359375`, 0.12445068359375`, 0.10040283203125`, 0.084869384765625`, 0.0855712890625`, 0.1005859375`, 0.119110107421875`, 0.1280517578125`, 0.123931884765625`, 0.110076904296875`, 0.09417724609375`, 0.091827392578125`, 0.10797119140625`, 0.13421630859375`, 0.157958984375`, 0.176849365234375`, 0.18792724609375`, \(<< 905296 >>\)}\), "[[", RowBox[{"0", ";;", RowBox[{"", \(<< 5 >>\), ""}]}], "]]"}] is not a non-empty list or rectangular array of numeric quantities. >>
During evaluation of In[13]:= ListLinePlot::lpn: Abs[Fourier[{-0.139099,-0.143005,-0.147125,-0.149109,-0.14563,-0.136719,-0.12442,-0.102112,-0.0857239,-0.0933228,-0.115112,-0.132629,-0.14621,-0.165161,-0.18399,-0.194122,-0.194702,-0.184052,<<16>>,0.124451,0.100403,0.0848694,0.0855713,0.100586,0.11911,0.128052,0.123932,0.110077,0.0941772,0.0918274,0.107971,0.134216,0.157959,0.176849,0.187927,<<905296>>}[[0;;22050]]]] is not a list of numbers or pairs of numbers. >>
Out[13]= A very large output was generated. Here is a sample of it:
ListLinePlot[Abs[Fourier[{-0.139099,-0.143005,-0.147125,-0.149109,-0.14563,-0.136719,-0.12442,-0.102112,-0.0857239,-0.0933228,-0.115112,-0.132629,-0.14621,-0.165161,-0.18399,-0.194122,-0.194702,<<905313>>,0.0675659,0.0622253,0.0541382,0.0477905,0.0399475,0.0280457,0.015564,0.00323486,-0.00512695,-0.00515747,-0.00265503,-0.00686646,-0.0162048,-0.0269775,-0.0352173,-0.0334473}[[0;;22050]]]]]
Show Less\[ThinSpace]Show More\[ThinSpace]Show Full Output\[ThinSpace]Set Size Limit...
$\endgroup$
2
  • $\begingroup$ For one thing, MM is 1 indexed... $\endgroup$
    – ciao
    Commented Jan 16, 2014 at 3:49
  • $\begingroup$ It might be an indexing error: vectors start with 1 and not 0, so you might try signal2[[all]] or signal2[[1;;Length[signal2]]]. $\endgroup$
    – bill s
    Commented Jan 16, 2014 at 4:16

1 Answer 1

3
$\begingroup$

You are trying to take 22051 elements from an list that's only 22050 elements long. To demonstrate the problem, this gives the same error:

x = {1, 2, 3}
Take[x, 4]
$\endgroup$

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.