# Fourier Transform on a Sound

I don't really know much above Fourier Transform , or how it's used in Mathematica but I want to know how I can find out, out of which Sin-waves a (static) sound is made of.

So for example I take "G" played by a Violin

Sound[SoundNote["G", 1, "Violin"]]


Because this isn't a pure tone, I want to know, which frequencies are present in which "strength".

My Questions:

How do I get this information?

How do I plot that? (I think it's called "Frequency-Domain")

How do I plot all the involved frequencies together?

I know, this may be simple for some people, but I have neither much know-how in Mathematica, nor do I know how to use Fourier Transform at all.

Hope you can help me, nxt191 aka Marc

Unfortunately I don't think that Mathematica really knows anything about the frequency content of SoundNote objects. They are not audio files (recorded in the time domain), but more like MIDI objects. (In fact I think they're 'sonified' by sending them as MIDI events to the OS.)

You can, however, do a fourier transform on an audio file. Either import your own with Import, or use one of the example sounds:

sound = ExampleData[{"Sound", "ViolinScale"}]


We can extract the list of samples from the single SampledSoundList inside this Sound object:

samples = sound[[1, 1, 1]];


We can also extract the sample rate:

sampleRate = sound[[1, 2]];


From here we can compute the FFT and plot:

fft = Fourier[samples];
ListLogPlot[Abs[fft]^2, PlotRange -> All,
DataRange -> {0, (1 - 1/Length[samples]) sampleRate}]


There is a lot of other analysis you can do, but that should get you started.

• It's true that there is no way to get SampledSoundList directly from MIDI, but here is a workaround. – Dan Oak Apr 28 '16 at 10:22