# Music and Fourier Transform [closed]

I posted this question on MathStackExchange. My question is in here now: How can I program a Fourier Tranform of a plot without knowing the function that generates the plot, assuming the funcion is of the form $$\sum_{n}\sin(2\pi n)?$$ As I said in my earlier post: This is an unrigorous project. Don't worry about real-world application or what would be the fastest way. I'm just very curious how one could program such a Transform in Mathematica.

• So, how would you get the function? As a list of values? In other words, in what physical form should we expect the input of your Fourier transform? Feb 18, 2021 at 22:56
• What if I play an A4 note on my piano, without backgroundnoises, and record it? Feb 18, 2021 at 22:57
• Use the command Fourier. It takes a list (like your sampled piano) and calculates the spectrum. Feb 18, 2021 at 23:00
• How does this command work? What are is the idea behind it? Can I program "my own" easy Fourier comman? Feb 18, 2021 at 23:02
• @vitamind To be frank, that would only be interesting as an exercise for you, but nobody in their right mind will go re-implementing the FFT algorithm, when perfectly good standard implementations exist. In fact, I suspect that even the one in Mathematica probably relies on an underlying fast optimized library of some kind. To see how Fourier works, search Fourier transform on this website and you will find a ton of answers. FFT is a topic that comes up often. Feb 18, 2021 at 23:14

Here is the slow Fourier transform... call it the SFT... it's basically the same as the FFT, but slower. On the positive side, it's not hard to program. Let x be the list that you want to take the transform of. The formula implemented is:

where N is the length of x. In Mathematica, this is:

 X[k_] :=  Sum[x[[n + 1]] Exp[-I 2 Pi k n/Length[x]], {n, 0, Length[x] - 1}]


You can evaluate this for all n terms using

X[#] & /@ Range[Length[x]]


OK. It's not really called the Slow Fourier Transform. It's called the "Discrete Fourier Transform," or DFT. MarcoB already thinks I'm not in my right mind, so I better stop here.

• Time for you to do something. Take a lot of samples of your function, call them x, then the transform will be X as defined above. Feb 19, 2021 at 0:23
• I understand the mathematical computation now. Thank you very much. I will come back to inform you if I was able to program it. Feb 19, 2021 at 0:33
• Okay I did it. Only one small question: What's the command to find a function-value of a plot? So I only I have plot, I put in $2$ and then I get the value of that plot at $2$. Feb 19, 2021 at 0:47
• @bills Hehe. I like the Slow Fourier Transform though :-) Feb 19, 2021 at 4:14