# How to extract samples from audio and hamming window?

조회 수: 12 (최근 30일)
Peter 2016년 10월 7일
댓글: Peter 2016년 10월 7일
fs = 16000;
r = audiorecorder(fs, 16, 1);
recordblocking(r,3);
x = getaudiodata(r, 'double');
plot(x);
t = [1/fs: 1/fs: length(x)/fs ];
I have got a 3 sec audio with the code above, how can I extract 160samples from it?
And I am not quite sure about how to hamming window the speech frame (20ms) from an audio using the hamming().
Thanks

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

### 채택된 답변

Wayne King 2016년 10월 7일
x is just a double precision vector that should have 48000 samples. These elements are just indexed from 1 to 48000. So you can just do
y = x(1:160);
20 msec of data with a sampling rate of 16 kHz is 320 samples. So you just have to create a hamming window of length 320 and multiply that element-by-element by a signal segment of the equal length.
y = x(1:320).*hamming(320);
Since both 160 and 320 divide 48000, you can simply reshape your data into matrix with 160 or 320 rows
y = reshape(x,[320 150]);
Then you can multiply each column by a hamming window
y = y.*repmat(hamming(320),1,150);
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Peter 2016년 10월 7일
Clear, this saves my day, thanks

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

### 카테고리

Help CenterFile Exchange에서 Audio Processing Algorithm Design에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by