I want to extract local maximum from FFT frame after processing signal with spectrogram.
Specifically, said that I have a audio file which is a wav file and it's collected in the following procedure:
phone user hold the smartphone at approximately arm's length, breathe in their full lung volume, and forcefully exhale until the entire lung volume is expelled. The phone's microphone records the exhalation and store data in a wav file.
Then i process the audio with spectrogram using following procedure:
Firstly, I buffer the audio into 30ms frames (with 50% overlap between frames). Then each frame is windowed using a hamming window and the |FFT|db is taken to produce the magnitude spectrogram of the signal.
Here is how i do that using matlab:
 [X, FS] = audioread('Rec_002.wav');
 info = audioinfo('Rec_002.wav');
 window = (30*0.001/info.Duration)*info.TotalSamples;
 [s,f,t,ps]=spectrogram(X, window, [], [], FS);
Rec_002.wav is my audio file. After processing signal with spectrogram, i want to extract the resonances using local maximum in each frame, calculated over a sliding window. Then, any local maximum that is greater than 20% of the global maximum is saved.
Below shows how spectrogram looks like when using the data above: Spectrogram image
This shows what resonances should looks like after extracting from spectrogram
After extracting resonaces from spectrogram image
By now, I use one of output argument s - Short-time Fourier transform to extract local maximum.
Here's my code:
 local_max=max(abs(s));
 threshold=0.2*max(local_max,[],2); 
 local_max=local(:,local_max>threashold);
The questions is that I am not sure whether it's correct to use s or should i use ps - Power spectral density (PSD) to achieve my goal.
Can anyone point out to me? Any help would be appreciated.