Mercurial > hg > gccphat-windowing
comparison Functions/gccPHATFunc_win.m @ 0:ab043bd3b162 tip
First commit
author | Alice Clifford <alice.clifford@eecs.qmul.ac.uk> |
---|---|
date | Mon, 11 Jun 2012 17:42:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ab043bd3b162 |
---|---|
1 function [frameDelayVec]=gccPHATFunc_win(x,frameSize,hopSize,windowShape) | |
2 % calculate the GCC-PHAT delay estimation on frames of data | |
3 % | |
4 % Input: | |
5 % - x: stereo audio file. x(:,2) is delayed | |
6 % - frameSize: size of frames (samples) | |
7 % - hopSize: overlap between frames (samples) | |
8 % - windowShape: string passed to window() | |
9 % | |
10 % Output: | |
11 % - frameDelayVec: array of delay estimation for each frame | |
12 % | |
13 % Developers: - Alice Clifford (alice.clifford@eecs.qmul.ac.uk) | |
14 | |
15 [xMat,numFrames]=createMat(x,frameSize,hopSize); | |
16 | |
17 w=repmat(window(windowShape,frameSize),[1 2 numFrames]); | |
18 | |
19 X=fft(xMat.*w); %FFT of each frame with window applied | |
20 | |
21 for n=1:numFrames | |
22 | |
23 %GCC-PHAT | |
24 Sxs=X(:,2,n).*conj(X(:,1,n)); | |
25 | |
26 S=Sxs./abs(Sxs); | |
27 | |
28 s=ifft(S); | |
29 | |
30 [dummy,frameDelay]=max(s(1:frameSize/2)); %assume delay in first frameSize/2 samples | |
31 | |
32 frameDelayVec(n)=frameDelay-1; %compensate for index starting at 1 | |
33 | |
34 | |
35 end |