user2693902
user2693902

Reputation: 45

How can I make a spectogram out of a wav file

Well I want to make a spectogram of a song. The first 10 seconds are the points of my interest. Should I just do this or is it wrong if I am wrong correct me.

Commands:

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

Upvotes: 4

Views: 14153

Answers (1)

Matt H
Matt H

Reputation: 93

First of all, where did lovers come from, and what is the significance of the number 44100? The easiest way to create a spectrogram is to use the spectrogram function of Matlab. The following code will generate a spectrogram for a specified wave file--you can experiment with the window size and window overlap parameters to find a plot which suits your needs the best.

[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

Upvotes: 4

Related Questions