# Calibration of transfer function
Transfer function between the microphones is defined as
$$H_{12}=\frac{p_2.p_1^{*}}{p_1.p_1^{*}}$$
where
$p_2.p_1^{*}$ = cross correlation function (cross power spectrum)
$p_1.p_1^{*}$ = auto correlation function (auto power spectrum)
## matlab code to find the transfer function (steps are written)
```
defining constant variables.
fs= sampling rate
bits= number of bits
sec= length of recording
Measurement of Calibration Transfer Function (Hc)
Playing required noise and then acquiring the data
function
hcn = dsp.ColoredNoise('InverseFrequencyPower',1,'SamplesPerFrame',fs*sec);
x = step(hcn);
sound(x,fs,bits)
Plays required noise for 5 seconds
recorder = audiorecorder(fs,bits,2)
display 'Start Recording'
recordblocking(recorder, sec); it Stops recording
disp('End of Recording.')
c1 = getaudiodata(recorder); Gathers data from microphones
plot(c1); Waveform of the sound recorded by the microhpones
c11=c1(:,1); Splitting data into microphone 1 and 2
c21=c1(:,2);
[C12,freq1]=tfestimate(c11,c21,[],[],[],fs);
Transfer function 1-2
display ('Swap the microphone positions then press any key to resume.')
pause code and swap the position of the microphones
Playing required noise and recording for microphones in swapped position
hcn = dsp.ColoredNoise('InverseFrequencyPower',1,'SamplesPerFrame',fs*sec);
x = step(hcn);
sound(x,fs,bits)
recorder = audiorecorder(fs,bits,2)
display ('Start Recording.)'
recordblocking(recorder, sec);
display ('End of Recording.')
c2 = getaudiodata(recorder);
plot(c2); waveform of the sound recorded by the two microhpones
c12=c2(:,1);
c22=c2(:,2);
[C21,freq2]=tfestimate(c12,c22,[],[],[],fs);
Transfer function 2-1
Hc=(C12.*C21).^0.5; Calculating the calibration transfer function Hc
plot (freq, Hc)
title(Transfer Function (Hc) Between Microphone 1 and 2)
```
for 5 microphones we have to do like this
* Take a measurement first with all five microphones in their normal positions. (Microphones order: $[1,2,3,4,5]$)
* Swap the position of microphone 1 with microphone 2 (leave the other microphones in their normal position) and measure. (Microphones order: $[2,1,3,4,5]$)
* Put the microphone 2 back to its position, put the microphone 1 in the position of the microphone 3 and the microphone 3 in the position of the microphone 1. Measure. (Microphones order:
$[3,2,1,4,5]$)
* Put the microphone 3 back to its position, put the microphone 1 in the position of the microphone 4 and the microphone 4 in the position of the microphone 1. Measure. (Microphones order: $[4,2,3,1,5]$)
* Put the microphone 3 back to its position, put the microphone 1 in the position of the microphone 5 and the microphone 5 in the position of the microphone 1. Measure. (Microphones order: $[5,2,3,4,1]$)
* Here we have taken 1 as the reference microphone.