Clear Filters
Clear Filters

Why my spectrogram looks so bad? (white lines)

6 views (last 30 days)
Juan
Juan on 27 Feb 2017
Answered: Greg Dionne on 22 Mar 2017
I have an audio called audio.mp3 and I do:
[u Fs]=audioread('audio.mp3');
And then:
figure; spectrogram(u);
figure; spectrogram(u,Fs);
But in both cases I have an awful spectrogram, with white lines in it:
using spectrogram(u):
using spectrogram(u,Fs):
I hope you can help me. I really need this to work properly

Answers (3)

Star Strider
Star Strider on 27 Feb 2017
The spectrogram plot is a surf plot, so if you want to see what the white lines actually mean, use the view function to see it as a 3D plot.
This is from the spectrogram documentation:
Fs = 1000;
t = 0:1/Fs:2-1/Fs;
y = chirp(t,100,1,200,'quadratic');
figure(1)
spectrogram(y,100,80,100,Fs,'yaxis')
view(-77,72)
shading interp
colorbar off
grid on
  2 Comments
Stephen23
Stephen23 on 27 Feb 2017
Edited: Stephen23 on 27 Feb 2017
Juan's "Answer" moved here:
The 3D plot is:
It doesn't show any white lines. So the problem is in my 2D plot. What can I do?
Star Strider
Star Strider on 27 Feb 2017
There may be white lines that are hidden by the peaks. You may have to rotate it to see them. You can do this interactively using the ‘Rotate 3D’ icon in the plot GUI window. (It has an anti-clockwise circular arrow around a 3D box.)
Also, the white lines could simply be a problem with the resolution. Experiment with the input arguments to see if increasing the fft length, changing the overlap, and others could improve the plot.

Sign in to comment.


Steve Jenkins
Steve Jenkins on 22 Mar 2017
I have the same problem. It seems like with older OpenGl renderers, these artifacts appear. The only methods I've found are to use a new version of OpenGl, or to switch to using painters as a renderer.
set(gcf, 'renderer','painters');

Greg Dionne
Greg Dionne on 22 Mar 2017
I've heard sometimes updating NVidia drivers help or maybe using the -softwareopengl switch when starting MATLAB. But if all you want is a 2-D image, try something like:
[~,f,t,P] = spectrogram(...)
imagesc(t,f,10*log10(abs(P)+eps))
xlabel('time')
ylabel('freq')
colorbar

Categories

Find more on Time-Frequency Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!