-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPeakInterpolate_frame.m
27 lines (25 loc) · 1.14 KB
/
PeakInterpolate_frame.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function [newPeakFreq_frame, newspecMagDb_frame] = PeakInterpolate_frame(specMagDb_frame, peakFreq_frame, DFTFrequencies)
% Quadratic interpolation
%
% Input
% - specMagDb : magnitude spectrogram
% - freqBin : frequency bins of detected peaks in a frame
% - DFTfrequencies : vector with frequencies (in Hz) corresponding to the
% DFT frequency bins
% Output
% - newPeakFreq_cell : cell with real frequency (in Hz) of the new detected peaks (each frame is a column)
% - newspecMagDbPeak_cell : amplitudes in dB of the new interpolated peaks
%
% Author: Zhiyao Duan
% Created: 2007
%
% Heavily modified by Carlos Lordelo in 2016
if ~isempty(specMagDb)
%freqBin = find(ismember(DFTFrequencies, peakFreq));
newspecMagDb = specMagDb(freqBin) - 1/8 *((specMagDb(freqBin+1)-specMagDb(freqBin-1)).^2) ./ (specMagDb(freqBin-1)+specMagDb(freqBin+1)-2*specMagDb(freqBin));
newPeakFreq_frame = freqBin - 1/2*(specMagDb(freqBin+1)-specMagDb(freqBin-1)) ./ (specMagDb(freqBin-1)+specMagDb(freqBin+1)-2*specMagDb(freqBin));
else
newPeakFreq = [];
newspecMagDb = [];
end
end