Fourier Analysis of a sound signal using Mathematica

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 8K views
neoromeo
Messages
2
Reaction score
0

Homework Statement



I am trying to construct a Mathematica notebook that will be able to import sound in the form of a .wmv file and then create the frequency spectrum for a given time interval.

Homework Equations



I managed to complete this part, though I am trying to figure out:
a) How could I make a filter to cut off certain frequencies and then,
b) using the Inverse Fourier transform to rebuild the signal.

The Attempt at a Solution



The following code does the import and frequency analysis job.

Clear All

file = "C:\\SOUND\\adriana.wav";

data = Flatten@Import[file, "Data"];

Import[file, "Options"]

snd = Import[file, "Sound"]

Length[data]

SetOptions[ListLinePlot, ImageSize -> {500, 150}, AspectRatio -> 0.25,
PlotRange -> All];

SetOptions[ListPlot, ImageSize -> {500, 150}, AspectRatio -> 0.25,
PlotRange -> All];

ListLinePlot[data[[1 ;; 4820100 ;; 100]]]

ListLinePlot[Abs[Fourier[data[[500000 ;; 500000 + 88200]]]]]

ListLinePlot[Abs[Fourier[data[[200000 ;; 600000]]]][[1 ;; 600]]]


Thanks in advance :)
 
on Phys.org
neoromeo said:
a) How could I make a filter to cut off certain frequencies and then,
You have the Fourier transform of the input data - how would you manipulate that to cut off certain frequencies? (If you don't know the Mathematica functions for it, at least conceptually: how could you do this?)
neoromeo said:
b) using the Inverse Fourier transform to rebuild the signal.
Look at the Mathematica documentation for Fourier and it should point you to the proper function.
 
a) I guess I 'll have to make a loop that will check for the certain intensities on the frequency region I want to cut off and make everything zero. Another way could be the convolution of the original data with some other function, but it's getting tricky when it comes to real data.

b) Actually I managed to do the Inverse Fourier, though it's really distorted compared to the original, even for small time fragments... I have to clear the spectrum first and then try again.
 
Mathematica is generally better at working with functions than loops (or arrays, lists, etc.). So you should investigate using an envelope function. How would you construct the function? (Simple example: suppose you wanted to cut off all frequencies above 1000 Hz, what function would you use?)

Note that convolutions have a special relationship with Fourier transforms that make them very easy to compute.
 
Last edited: