forked from ThomasFeher/oms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmaBuildCardioids.m
59 lines (53 loc) · 2.1 KB
/
admaBuildCardioids.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
%-----------------------------------------------------------------------
%| Function: admaBuildCardioids
%-----------------------------------------------------------------------
%| Generate the 3 cardioid patterns out of the 3 mic signals
%|
%| Author: Patrick Michelson
%| Version: 0.1
%| Date: 08.10.2012
%| Library: ADMA
%|
%|
%| @param <3xN complex> sigVec - Matrix with freq spec. of 3 mics
%| (N=number of freqencies)
%| @param <1xN double> freqVec - Vector with frequencies
%| @param <double> dis - Distance between mics
%|
%| @return <3xN complex> sigVecCardioid - Matrix with 3 cardioid patterns XX1:
%|
%----------------------------------------------------------------------
function [sigVecCardioid sigVecEight] = admaBuildCardioids(sigVec,freqVec...
,dist,speedOfSound,doEqualization)
if(nargin<5)
doEqualization = true;
end
%c = 340; %speed of sound in m/s
j = 1i;
x2 = 0.84; %level adjustment of mic 2
x3 = 1.08; %level adjustment of mic 3
%calculate gain for frequencies (low-pass filter)
offset = 1/30;
gain = abs(2*sin(2*pi .* freqVec / speedOfSound * 14.3e-3))+2*offset;
%adjust level of mic signals
sigVec(2,:) = x2 * sigVec(2,:);
sigVec(3,:) = x3 * sigVec(3,:);
%build cardioids
sigVecCardioid(1,:) = (sigVec(1,:) - sigVec(2,:)...
.* exp((-j*2*pi*dist/speedOfSound) * freqVec));
sigVecCardioid(2,:) = (sigVec(3,:) - sigVec(1,:)...
.* exp((-j*2*pi*dist/speedOfSound) * freqVec));
sigVecCardioid(3,:) = (sigVec(2,:) - sigVec(3,:)...
.* exp((-j*2*pi*dist/speedOfSound) * freqVec));
%build eights
sigVecEight(1,:) = sigVec(1,:) - sigVec(2,:);
sigVecEight(2,:) = sigVec(3,:) - sigVec(1,:);
sigVecEight(3,:) = sigVec(2,:) - sigVec(3,:);
if(doEqualization)%equalize levels
sigVecCardioid(1,:) = sigVecCardioid(1,:) ./ gain;
sigVecCardioid(2,:) = sigVecCardioid(2,:) ./ gain;
sigVecCardioid(3,:) = sigVecCardioid(3,:) ./ gain;
sigVecEight(1,:) = sigVecEight(1,:) ./ gain;
sigVecEight(2,:) = sigVecEight(2,:) ./ gain;
sigVecEight(3,:) = sigVecEight(3,:) ./ gain;
end