# PSEUDO CODE FOR MICROPHONE MEASUREMENTS
# ALGORITHM USED
$P_i(f)$ = pressure amplitude of incident sound wave at location $x=0$
$P_r(f)$ = pressure amplitude of reflected sound wave at location $x=0$
$V_n(f) =[p_i(f)exp(-ikx_n)+p_r(f)exp(ikx_n)].M_n(f)$
$V_n(f)$ = voltage output of the $n_{th}$ microphone at location $x_n$
$M_n(f)$ = frequency response of the sensitivity of the $n_{th}$ microphone
$f$ = frequency , $k$ = wave number
$k = 2\pi.f/c$
calculate $V_n(f)$ from microphone measurements i.e, output voltage.
taking frequency response of the first microphone as reference
transfer function $H_n(f) =M_n(f)/M_1(f)$
consider above equations and form a matrix as follows
$$ \begin{bmatrix} V_1(f)\\ V_2(f)\\\vdots\\ V_n(f) \end{bmatrix} = \begin{bmatrix}
H_1(f) & 0 & \cdots & 0 \\
0 & H_2(f) & \cdots & 0\\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \cdots & H_n(f)
\end{bmatrix} \begin{bmatrix} exp(-ikx_1)& exp(ikx_1) \\ exp(-ikx_2)& exp(ikx_2)\\\vdots&\vdots\\exp(-ikx_n)& exp(ikx_n) \end{bmatrix} \begin{bmatrix} p_i(f) \\ p_r(f) \end{bmatrix} M_1(f) $$
the above matrix is written as
$V_{mic}=JAP.M_1$
$P =[1/M_1(f)](A^H.A)^{-1}.A^H.J^{-1}.Vmic$
$$P=\begin{bmatrix} p_i(f) \\ p_r(f) \end{bmatrix}$$
as $p_i(f)$ and $p_r(f)$ are found, acoustic pressure at microphone are found and pressure variation in the tube is obtained.
acoustic reflection coefficient = $p_i(f)/p_r(f)$
## Example of the fft done in matlab
sampling frequency $(F_s)$ = $1000Hz$
sampling time $(T_s)$ = $1/F_s$
the signal taken is of the form
$y =y_1+y_2+y_3$
$y_1=Asin(2\pi.f_1.t)$
$y_2=Asin(2\pi.f_2.t)$
$y_3=Asin(2\pi.f_3.t)$
$f_1=10Hz, f_2=30Hz, f_3=70Hz$
time duration $(dt)$ = $0:T_s:2-T_s$
the plot variation of the signals $y$, $y_1$, $y_2$, $y_3$ with respect to time are as follows

after doing fft the graph of frequency vs amplitude is as follows

comparison between time domain and frequency domain is as follows
