Mercurial > hg > pmhd
annotate peakinterp.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 | f445c3017523 |
children |
rev | line source |
---|---|
yading@11 | 1 function [iploc, ipmag, ipphase] = peakinterp(mX, pX, ploc) |
yading@11 | 2 % Parabolic interpolation of spectral peaks |
yading@11 | 3 % mX: magnitude spectrum, pX: phase spectrum, ploc: locations of peaks |
yading@11 | 4 % iploc, ipmag, ipphase: interpolated values |
yading@11 | 5 % note that ploc values are assumed to be between 2 and length(mX)-1 |
yading@11 | 6 val = mX(ploc); % magnitude of peak bin |
yading@11 | 7 lval = mX(ploc-1); % magnitude of bin at left |
yading@11 | 8 rval= mX(ploc+1); % magnitude of bin at right |
yading@11 | 9 iploc = ploc + .5*(lval-rval)./(lval-2*val+rval); % center of parabola |
yading@11 | 10 ipmag = val-.25*(lval-rval).*(iploc-ploc); % magnitude of peaks |
yading@11 | 11 ipphase = interp1(1:length(pX),pX,iploc,'linear'); % phase of peaks |