how can i get a wave file of a particular duration

Actually i got a .wave file of some duration but i need a particular portion of that .wave file.i used wavsurfer software but its not working.i need a .wav file ranging from 2.9sec to 3.4sec can anybody pls help me with matlab code??

답변 (1개)

Jan
Jan 2013년 6월 13일
편집: Jan 2013년 6월 16일

0 개 추천

When you know the frequency of the signal, you can specify the wanted part in the inputs:
[y, Fs] = wavread(filename, [N1, N2])
Or the modern version in new Matlab versions:
[y,Fs] = audioread(filename, [N1, N2])
Without knowing the frequency, you can either import the whole signal and cut it afterwards, or obtain the frequency:
info = audioinfo(filename);
Fs = info.SampleRate;
Signal = audioread(filename, round([2.9, 3.4] * Fs)); % [EDITED, typo]

댓글 수: 4

Sony
Sony 2013년 6월 13일
[...] = wavread(filename,[N1 N2]) returns only samples N1 through N2 from each channel in the file. but how to find samples from 2.9 to 3.4 sec?
As Jan wrote,
round([2.9, 2.4] * Fs)
except his 2.4 should have been 3.4.
That is, multiply time desired by number of samples per second to get the sample number.
Sony
Sony 2013년 6월 14일
how to get number of samples per second?
Do you see above where Jan did the wavread() ? The second output, Fs, is the sampling frequency. You can also get it without reading the file by using wavinfo() (older) or audioinfo() (newer)

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

카테고리

도움말 센터File Exchange에서 Language Fundamentals에 대해 자세히 알아보기

질문:

2013년 6월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by