The result of Spectrogram()

14 views (last 30 days)
Anonym
Anonym on 4 Dec 2020
Commented: Cris LaPierre on 5 Dec 2020
Hey all, I've a sound and a spectrogram of it.
But I honestly do not know what it means, shows and do.
Here's what I've got
load handel; % 'handel' is a MAT-file which is shipped with MATLAB as an example
x = y/10; % Decrease volume
player = audioplayer(x, Fs);
play(player,[1 (get(player, 'SampleRate')*10)]);
spectrogram(x);
Spectrogram(x) prints this:
Is there anyone that can tell me what the spectrogram function does and shows? What does the yellow and green color mean?

Answers (1)

Cris LaPierre
Cris LaPierre on 5 Dec 2020
There is a documentation page that gives some details.
You might find this previous Answers post helpful as well: How to understand spectrogram function
  2 Comments
Anonym
Anonym on 5 Dec 2020
My goal is to show how much frequency range a sound can cover.
Spectrogram(x) prints this, when x=y/100:
Spectrogram(x) prints this, when x=y/1:
My analysis: Based on my little knowledge, I assume that the colors have something to do with the volume of the sound. The green color shows how high the volume is playing, so the more dense green lines you get, the louder the music plays. And the fewer green lines there are, the lower the music plays.
  • Am I wrong?
I've read most of the threads related to the spectrogram, just wanted to know what the colors mean in this context.
Cris LaPierre
Cris LaPierre on 5 Dec 2020
Note that the limits of your colorbar have changed, so be careful about making broad statements based solely on color. Amplitude of a sound is related to volume, so while the density of the lines does not impact volume, the more a frequency tends towards yellow, the louder it will be.
Each "row" of your spectrogram represents a snapshot in time of your signal. The x-axis shows the range of frequencies contained in the entire signal, and each row of colors indicates the amplitude of the corresponding frequency at that time instance. As you move from the bottom to the top of the spectrogram, you are moving from the start to the end of the song.
You may be able to see this better if you take advantage of some of the other inputs. Note the 3 bands.
load handel; % 'handel' is a MAT-file which is shipped with MATLAB as an example
y(25000:end)=y(25000:end)./10; % y/10
y(50000:end)=y(50000:end)./10; % y/100
spectrogram(y,128,120,128,Fs)
% to listen to it
handelObj = audioplayer(y,Fs);
play(handelObj)

Sign in to comment.

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!