how to apply stft to audio signal?

19 views (last 30 days)
studentmatlaber
studentmatlaber on 12 Jan 2022
Answered: Bjorn Gustavsson on 12 Jan 2022
Hello everyone. This is my first time processing audio, so I'm a beginner at this. I want to apply stft to my audio signal. It needs to have a 256-point Hamming window length, 128-point overlap, and 256-point transform values. I repeat a study, it says there is a 256-point sample that corresponds to 16ms.
Is this code I wrote correct? I would be glad if you help.
[data,fs]=audioread('SA1.wav')
% data = 46797x1 double
% fs = 16000
d = seconds(16*10e-3);
stft(data,d,'Window',hamming(256),'OverlapLength',128,'FFTLength',256);

Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 12 Jan 2022
You might do this, but the call to seconds looks spooky. From audioread you get the sampling-frequency fs, that is the sampling-frequency you should send in to stft. If that matches the sampling-frequency from the study you're good. If that sampling-frequency doesn't match you will have to work - but making up a sampling-frequency or sampling-time array like you do cannot be anyting but an unnecessary risk, if you're right you might just as well have used fs if you're wrong you only set yourself up for more future pain and toil...
HTH

Community Treasure Hunt

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

Start Hunting!