Im new to Matlab. I need to split the time dimensions of an audio track into frames of 10mS and for every 10mS frame have to compute the FFT to generate the spectrograph. I need help on this.

 채택된 답변

Wayne King
Wayne King 2012년 1월 17일

0 개 추천

Hi Karthik, Why can't you just use spectrogram()? You can specify the window length (the number of samples corresponding to 10 msec) as an input.
If you cannot use spectrogram(), you can use reshape() as one option.
Suppose you have an audio signal sampled at 20 kHz.
Then 200 samples is 10 msec.
x = randn(2e4,1);
x = reshape(x,200,100);
You can then apply the Fourier transform to the columns of x.
Better than the above option is buffer(), which allows you to construct overlapping segments.
x = 1:16;
x = buffer(x,4,2)
Again, spectrogram provides a NOVERLAP input argument that handles this easily.

댓글 수: 4

Karthik Raj
Karthik Raj 2012년 1월 17일
K thanks for your reply.
When is use spectrogram() directly it flags an error saying input must be vector.
My audio signal is of length 4 mins. When i stored that in an array it forms a matrix of size 11470464 x 2
frequency is 44100
so samples will be 441 for 10ms correct? how to proceed?
These thing may be silly but help me.
Thanks.
Wayne King
Wayne King 2012년 1월 17일
yes, you don't input an array into spectrogram(). Input a vector. If you have a two-channel audio signal, then just give spectrogram 1 column
input = x(:,1);
Yes, that is correct. 441 samples. You will definitely want to play with NOVERLAP.
You can try:
S = spectrogram(x,441,[],[],44100);
to start
Wayne King
Wayne King 2012년 1월 17일
[s,f,t,p] = spectrogram(x,441,[],[],44100);
surf(t,f,10*log10(abs(p)),'EdgeColor','none');
axis xy; axis tight; colormap(jet); view(0,90);
xlabel('Time');
ylabel('Frequency (Hz)');
Karthik Raj
Karthik Raj 2012년 1월 17일
thanks i got it. Then how to input the window and fft of the signal to spectrogram?
my script looks like this...
[y,fs]=wavread('aud1.wav');
t=fs/100;
nfft=fft(y,t);
nwindow=hann(t);
[s,f,t,p]=spectrogram(y(:,1),t,nwindow,nfft,fs);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by