Extract one frame of an audio file

Hi. I'm new to matlab.
I have manually cut out few wave files containing one piano note each, and I'm required to extract the frame just after the attack of the note for analysis purpose.
My question is, is there an inbuilt function on this or it requires an algorithm? Could anyone help me on this? Thanks.

 Akzeptierte Antwort

Paulo Silva
Paulo Silva am 17 Mär. 2011

0 Stimmen

[y, Fs, nbits] = wavread(filename);
soundsc(y,Fs); %listen to all the wav
y1=y(1:2000); %listen to the first 2000 samples
soundsc(y1,Fs); %listen to the select part of the wav
You can select the range of samples to listen/use just like I did for y1, example y1=y(2000:3000)
If you want one interactive way try
[y, Fs, nbits] = wavread(filename);
plot(y);
[x1,y1]=ginput(1) %select the start point
[x2,y2]=ginput(1) %select the end point
soundsc(y(x1:x2),Fs); %listen to the wav from start point to end point

4 Kommentare

Franc
Franc am 17 Mär. 2011
Hi Paulo.
Thanks for the reply, it definitely solve my problem to a certain extent.
However, now that I have another problem.
As the audio samples are manually cut, I do have very short duration of near-silence (presence of slight noise). And I want to remove that duration from the samples as shown here:
http://i52.tinypic.com/10d72wz.jpg
Is there any kind of automatic process in doing this? I've tried an edge detector algorithm but it's not working too well. The last resort will be manually reading graph I guess.
Paulo Silva
Paulo Silva am 17 Mär. 2011
try with the diff function
y((diff(y)>0.001))
Franc
Franc am 17 Mär. 2011
hey thanks again here, but I'm losing significant amount of data doing this...
Guess i'll just try finding another solution to this.
Cheers
Paulo Silva
Paulo Silva am 17 Mär. 2011
apply it just to the beginning of the data
a=diff(y)>0.001; %find the interesting values
y=y(a(1):end); %ignore the values until something interesting comes up

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by