How can I compute and plot the spectrogram of a signal/time series/data in Mathematica? I have a WAV file, sampled at 44100 samples/second and I want to generate a spectrogram of that data. Something like this:

|
How can I compute and plot the spectrogram of a signal/time series/data in Mathematica? I have a WAV file, sampled at 44100 samples/second and I want to generate a spectrogram of that data. Something like this:
|
||||
|
|
|
Get a sample sound:
This gives us a
Plotting the data:
Find the lowest amplitude level (used as reference for dB calculations):
A spectrogram is made by making a DFT of partitions of the sample. The partitions usually have some overlap.
Note that I skip the first element of the DFT. This is the mean level. I also show only half of the frequency data. Because of the finite sampling only half of the returned coefficient list contains useful frequency information (up to the Nyquist frequency).
A 3D spectrogram (note the different offset value):
|
|||||||||||
|
|
The following is a more detailed version of a First load the package and some example data:
A sample call to
You can then plot this like in Sjoerd's example (or you can implement a default plot style within
A couple of things that are on my to-do list are to implement the Goertzel algorithm so that you can easily supply a list of frequencies at which the spectrogram needs to be calculated and different plotting schemes for 2D (something like the plot above as default) and waterfall and similar for 3D plots. I'll update this post when I get around to doing that. Spectrogram code
|
|||||||||||||||||
|
|
Version 9 has introduced several signal processing functions and
|
|||||||||||||
|