1
$\begingroup$

For a mathematics class I am in, my professor is having us manipulate audio files in various ways in order to demonstrate some of the processes we have learned about.

One of these in particular is giving me a lot of trouble. The assignment is to perform a Fourier transform on an audio file, isolate certain frequencies using a step function, and the performing an inverse Fourier transform.

While I understand qualitatively how the problem works, I am having trouble implementing it in Mathematica. I am somewhat new to the software, so any tips you can offer would be much appreciated.

The latest iteration of my code imports the file using AudioData[Import[filename]] and then performs the Fourier transform using Fourier[data], though I am not confident that this is the best method.

$\endgroup$

1 Answer 1

2
$\begingroup$

though I am not confident that this is the best method

Why? Fourier does FFT on data. Make sure if your audio has more than one channel to do one at a time.

 a = Import["ExampleData/drums.ogg"];
 AudioChannels[a]

 (* 2 *)

 data = AudioData[a];
 Dimensions[data]
 (*  {2, 695674} *)

 ListLinePlot[Abs[Fourier[data[[1, 1 ;; 200]]]]^2]

Mathematica graphics

$\endgroup$
2
  • $\begingroup$ From there how can I then remove frequencies? $\endgroup$
    – Anonymous
    Commented Apr 24, 2020 at 18:12
  • $\begingroup$ @Anonymous yes, use BandpassFilter command. You need to provide the cut off frequencies to do that. $\endgroup$
    – Nasser
    Commented Apr 25, 2020 at 7:02

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.