如何从wav文件中制作频谱图

时间:2013-08-18 13:25:08

标签: matlab

我想制作一首歌的谱图。前10秒是我感兴趣的点。 如果我错了,我应该这样做,还是错了。

命令:

song = wavread('C:\Path of My FIle\song.wav')

length(song)/44100

song_seg = lovers(44100*1 : 44100*10)

plot(song_seg) % this command makes my spectogram Hz/Time

1 个答案:

答案 0 :(得分:4)

首先,恋人来自哪里,44100的重要性是什么?创建频谱图的最简单方法是使用Matlab的频谱图功能。以下代码将为指定的波形文件生成光谱图 - 您可以试验窗口大小和窗口重叠参数,以找到最适合您需求的图。

[song, fs] = wavread('C:\Path of My File\song.wav');
song = song(1:fs*10);
spectrogram(song, windowSize, windowOverlap, freqRange, fs, 'yaxis');

%Larger Window Size value increases frequency resolution
%Smaller Window Size value increases time resolution
%Specify a Frequency Range to be calculated for using the Goertzel function
%Specify which axis to put frequency

%%EXAMPLE
spectrogram(song, 256, [], [], fs, 'yaxis');
%Window Size = 256, Window Overlap = Default, Frequency Range = Default
%Feel free to experiment with these values