Mercurial > hg > pmhd
annotate f0detection.m @ 13:844d341cf643 tip
Back up before ISMIR
author | Yading Song <yading.song@eecs.qmul.ac.uk> |
---|---|
date | Thu, 31 Oct 2013 13:17:06 +0000 |
parents | 6840f77b83aa |
children |
rev | line source |
---|---|
yading@10 | 1 function f0 = f0detection(mX, fs, ploc, pmag, ef0max, minf0, maxf0) |
yading@10 | 2 % Fundamental frequency detection function |
yading@10 | 3 % mX: magnitude spectrum, fs: sampling rate, ploc, pmag: peak loc and mag, |
yading@10 | 4 % ef0max: maximim error allowed, minf0: minimum f0, maxf0: maximum f0 |
yading@10 | 5 % f0: fundamental frequency detected |
yading@10 | 6 N = length(mX)*2; % size of complex spectrum |
yading@10 | 7 nPeaks = length(ploc); % number of peaks |
yading@10 | 8 f0 = 0; % initialize output |
yading@10 | 9 if(nPeaks>3) % at least 3 peaks in spectrum for trying to find f0 |
yading@10 | 10 nf0peaks = min(50,nPeaks); % use a maximum of 50 peaks |
yading@10 | 11 [f0,f0error] = TWM(ploc(1:nf0peaks),pmag(1:nf0peaks),N,fs,minf0,maxf0); |
yading@10 | 12 if (f0>0 && f0error>ef0max) % limit the possible error by ethreshold |
yading@10 | 13 f0 = 0; |
yading@10 | 14 end |
yading@10 | 15 end; |