Page MenuHomec4science

3_synthesis.tex
No OneTemporary

File Metadata

Created
Thu, Mar 13, 13:19

3_synthesis.tex

\documentclass[aspectratio=169]{beamer}
\def\stylepath{../styles}
\usepackage{\stylepath/com303}
\begin{document}
\begin{frame} \frametitle{DFT formulas}
\centering
Analysis formula:
\[
X[k] = \sum_{n = 0}^{N-1} x[n]\, e^{-j\frac{2\pi}{N}nk}, \qquad k = 0,1,\ldots,N-1
\]
$N$-point signal in the {\em frequency domain}
\vspace{2em}
\pause
Synthesis formula:
\[
x[n] = \frac{1}{N} \sum_{k = 0}^{N-1} X[k]\, e^{j\frac{2\pi}{N}nk}, \qquad n = 0,1,\ldots,N-1
\]
$N$-point signal in the {\em ``time'' domain}
\end{frame}
\def\ceStep#1{% define \a (freq) and \p (initial phase)
\FPupn\np{1 #1 - clip} \FPupn\anp{\np{} \a{} * \p{} + clip} \FPupn\anpp{\a{} \anp{} - clip}%
\only<#1->{\dspCPCirclePoint[linecolor=lightgray,toorg=true]{1}{\anpp}{}}
\only<#1>{\dspCPCirclePoint[linecolor=red,toorg=true]{1}{\anp}{$w_k[\np]$}
\dspCPArc{0.6}{\anpp}{\anp}{\tiny $\frac{2\pi}{N}k$}}}
\begin{frame} \frametitle{Synthesis: the sinusoidal generator}
\note<1>{Previous examples were about analysis. Let's now\\ consider the synthesis part by \\
showing that we can think of the DFT synthesis formula \\
as of a signal-generating bank of oscillators which we \\ initialize with the DFT coefficients}
\centering
$w_k[n] = e^{j(\frac{2\pi}{N}kn + \phi_k)}$
\begin{center}
\begin{figure}
\begin{dspPZPlot}[width=6cm,circle=0,xticks=none,yticks=none]{1.5}
\dspCPCircle[linewidth=0.5pt,linecolor=lightgray]{0,0}{1}
\def\a{45}\def\p{20}
\only<1>{
\dspCPCirclePoint[linecolor=red,toorg=true]{1}{\p}{$w_k[0]$}
\dspCPArc{0.7}{0}{20}{\tiny $\phi_k$}}
\multido{\n=2+1}{4}{\ceStep{\n}}
\end{dspPZPlot}
\end{figure}
\end{center}
\end{frame}
\def\Gen#1{%
\raisebox{-1.2em}{%
\psset{xunit=1em,yunit=1em,linewidth=1.5pt}%
\pspicture(-1,0)(7.1,-3)%
\rput[r]{0}(0,-1.5){$A_{#1}$}\rput[r]{0}(0,-2.5){$\phi_{#1}$}
\rput[l](1.9,-1.5){\psframebox[framesep=.2]{\parbox{4em}{~~\pscirclebox{\Large$\mathbf{\sim}$}$_{~~#1}$}}}
\psline[linewidth=0.8pt]{->}(0.1,-1.5)(1.8,-1.5)
\psline[linewidth=0.8pt]{->}(0.1,-2.5)(1.8,-2.5)
\endpspicture}}
\begin{frame} \frametitle{Synthesis: the sinusoidal generator}
\centering
\begin{dspBlocks}{1}{5}
\Gen{k} & ~~$A_k e^{j(\frac{2\pi}{N}kn + \phi_k)}$
\BDConnHNext{1}{1}
\end{dspBlocks}
\end{frame}
\begin{frame} \frametitle{DFT synthesis formula}
\centering
\begin{dspBlocks}{1.2}{0.2}
\rnode{A}{\Gen{\,0}} & & \\
\Gen{\,1} & & \\
\Gen{\,2} & & \BDadd & $x[n]$ \\
\hspace{1em}$\ldots$ & & \\
\Gen{N-2} & & \\
\rnode{B}{\Gen{N-1}} & &
\ncline{1,1}{1,2}\ncline{->}{1,2}{3,3}
\ncline{2,1}{2,2}\ncline{->}{2,2}{3,3}
\ncline{3,1}{3,2}\ncline{->}{3,2}{3,3}
\ncline{5,1}{5,2}\ncline{->}{5,2}{3,3}
\ncline{6,1}{6,2}\ncline{->}{6,2}{3,3}
\ncline{->}{3,3}{3,4}
\end{dspBlocks}
\end{frame}
\begin{frame} \frametitle{Initializing the machine}
\begin{align*}
A_k &= |X[k]|/N \\ \\
\phi_k &= \angle X[k]
\end{align*}
\end{frame}
\begin{frame} \frametitle{Example: triangular signal}
\centering
$\mathbf{x} = [1 \,\, 2 \,\, 3 \,\, 4 \,\, 3 \,\, 2 \,\, 1]^T$
\begin{figure}
\begin{dspPlot}{0, 6}{0,5}
\moocStyle
\dspTaps{0 1 1 2 2 3 3 4 4 3 5 2 6 1}
\end{dspPlot}
\end{figure}
\end{frame}
\begin{frame} \frametitle{DFT of triangular signal}
\begin{center}
\begin{figure}
\begin{dspPlot}[width=8cm,height=2.5cm,ylabel={$|X[k]|$}]{0, 6}{0, 2.50}
\moocStyle
\dspTapsAt{0}{2.2857 0.7213 0.0440 0.0919 0.0919 0.0440 .7213}
\end{dspPlot}
\end{figure}
\begin{figure}
\begin{dspPlot}[yticks=custom,xout=true,width=8cm,height=2.5cm,ylabel={$\angle X[k]$}]{0, 6}{-3.2, 3.2}
\moocStyle
\dspTapsAt{0}{0 -2.6928 0.8976 -1.7952 1.7952 -0.8976 2.6928}
\dspCustomTicks[axis=y]{0 0 -3.14 $-\pi$ 3.14 $\pi$}
\end{dspPlot}
\end{figure}
\end{center}
\end{frame}
\begin{frame} \frametitle{DFT coeffcients}
\centering
\begin{tabular}{c|r|r}
\hline
& & \\ $k$ & $A_k$ & $\phi_k$ \\ & & \\
\hline
& & \\
0 & 2.2857 & 0.0000 \\
1 & 0.7213 & -2.6928 \\
2 & 0.0440 & 0.8976 \\
3 & 0.0919 & -1.7952 \\
4 & 0.0919 & 1.7952 \\
5 & 0.0440 & -0.8976 \\
6 & 0.7213 & 2.6928 \\
\hline
\end{tabular}
\end{frame}
\def\tablePlot#1#2{%
\raisebox{-0.2\textheight}{%
\begin{dspPlot}[width=0.25\textwidth,height=0.3\textheight,xticks=none]{0,6}{-#1,#1}
\moocStyle
#2
\end{dspPlot}}}
\def\component#1#2#3#4#5{%
\only<#1>{%
\FPupn\r{#3 1.15 * 0.5 + 0 trunc 1.1 max}%
\tablePlot{\r}{%
\dspSignal{x 7 div #2 mul #4 6.28 div add 360 mul #5 #3 mul}}}}
\def\parsum#1#2#3{%
\dspSignalOpt[#1]{%
/A [2.2857 0.7213 0.0440 0.0919 0.0919 0.0440 0.7213] def%
/P [0.0000 -2.6928 0.8976 -1.7952 1.7952 -0.8976 2.6928] def}{%
0
/w x 7 div def
0 1 #2 { % a i
/i exch def % a
w i mul P i get 6.28 div add 360 mul #3 A i get mul add
} for}}
\def\totsum#1#2#3#4#5{%
\only<#1>{%
\FPupn\p{1 #2 - 0 max 0 trunc}
\raisebox{-0.2\textheight}{%
\begin{dspPlot}[width=0.25\textwidth,height=0.3\textheight,xticks=none]{0,6}{#4,#5}
\moocStyle
\parsum{linecolor=lightgray}{\p}{#3}
\parsum{}{#2}{#3}
\end{dspPlot}}}}
\def\totsumRe#1#2{\totsum{#1}{#2}{cos }{0}{4.5}}
\def\totsumIm#1#2{\totsum{#1}{#2}{sin }{-1.1}{1.1}}
\begin{frame} \frametitle{Example}
\centering
\begin{tabular}{ccc}
\only<1>{$k=0$}%
\only<2>{$k=1$}%
\only<3>{$k=2$}%
\only<4>{$k=3$}%
\only<5>{$k=4$}%
\only<6>{$k=5$}%
\only<7>{$k=6$}%
& Re & Im \\
\parbox{10em}{
$A_k e^{j(\frac{2\pi}{N}kn + \phi_k)}$
\\ \\
\only<1>{$A_0 = 2.28, \phi_0 = 0$}%
\only<2>{$A_1 = 0.72, \phi_1 = -2.69$}%
\only<3>{$A_2 = 0.04, \phi_2 = 0.89$}%
\only<4>{$A_3 = 0.09, \phi_3 = -1.79$}%
\only<5>{$A_4 = 0.09, \phi_4 = 1.79$}%
\only<6>{$A_5 = 0.04, \phi_5 = -0.89$}%
\only<7>{$A_6 = 0.72, \phi_6 = 2.69$}}
&
\component{1}{0}{2.2857}{ 0.0000}{cos }%
\component{2}{1}{0.7213}{-2.6928}{cos }%
\component{3}{2}{0.0440}{ 0.8976}{cos }%
\component{4}{3}{0.0919}{-1.7952}{cos }%
\component{5}{4}{0.0919}{ 1.7952}{cos }%
\component{6}{5}{0.0440}{-0.8976}{cos }%
\component{7}{6}{0.7213}{ 2.6928}{cos }%
&
\component{1}{0}{2.2857}{ 0.0000}{sin }%
\component{2}{1}{0.7213}{-2.6928}{sin }%
\component{3}{2}{0.0440}{ 0.8976}{sin }%
\component{4}{3}{0.0919}{-1.7952}{sin }%
\component{5}{4}{0.0919}{ 1.7952}{sin }%
\component{6}{5}{0.0440}{-0.8976}{sin }%
\component{7}{6}{0.7213}{ 2.6928}{sin }%
\\
\parbox{10em}{
\only<1>{$\displaystyle\sum_{k=0}^{0} A_k e^{j(\frac{2\pi}{N}kn + \phi_k)}$}%
\only<2>{$\displaystyle\sum_{k=0}^{1} A_k e^{j(\frac{2\pi}{N}kn + \phi_k)}$}%
\only<3>{$\displaystyle\sum_{k=0}^{2} A_k e^{j(\frac{2\pi}{N}kn + \phi_k)}$}%
\only<4>{$\displaystyle\sum_{k=0}^{3} A_k e^{j(\frac{2\pi}{N}kn + \phi_k)}$}%
\only<5>{$\displaystyle\sum_{k=0}^{4} A_k e^{j(\frac{2\pi}{N}kn + \phi_k)}$}%
\only<6>{$\displaystyle\sum_{k=0}^{5} A_k e^{j(\frac{2\pi}{N}kn + \phi_k)}$}%
\only<7>{$\displaystyle\sum_{k=0}^{6} A_k e^{j(\frac{2\pi}{N}kn + \phi_k)}$}}
&
\totsumRe{1}{0}%
\totsumRe{2}{1}%
\totsumRe{3}{2}%
\totsumRe{4}{3}%
\totsumRe{5}{4}%
\totsumRe{6}{5}%
\totsumRe{7}{6}%
&
\totsumIm{1}{0}%
\totsumIm{2}{1}%
\totsumIm{3}{2}%
\totsumIm{4}{3}%
\totsumIm{5}{4}%
\totsumIm{6}{5}%
\totsumIm{7}{6}%
\end{tabular}
\end{frame}
\begin{frame} \frametitle{The machine before DSP}
\centering
\includegraphics[height=0.7\paperheight]{tidemachine.eps}
tide-predicting machine (originally invented by Lord Kelvin)
\end{frame}
\begin{frame} \frametitle{Wonderful website}
\begin{center}
{\color{blue} \tt \bf \large \href{http://jackschaedler.github.io/circles-sines-signals}{http://jackschaedler.github.io/circles-sines-signals} }
\end{center}
\end{frame}
\begin{frame} \frametitle{Running the machine too long...}
\centering
\[
x[n + N] = x[n]
\]
output signal is $N$-periodic!
\end{frame}
\begin{frame} \frametitle{Inherent periodicities in the DFT}
%\note<1>{same as slide 27 in 4.2}
\centering
the synthesis formula:
\[
x[n] = \frac{1}{N} \sum_{k = 0}^{N-1} X[k]\, e^{j\frac{2\pi}{N}nk}, \qquad
\only<1>{n = 0,1,\ldots,N-1}\only<2->{{\color{darkred}n \in \mathbb{Z}}}
\]
produces an \only<1>{$N$-point}\only<2->{{\color{darkred}$N$-periodic}} signal in the time domain
\vspace{2em}
the analysis formula:
\[
X[k] = \sum_{n = 0}^{N-1} x[n]\, e^{-j\frac{2\pi}{N}nk}, \qquad \only<1-2>{k = 0,1,\ldots,N-1}\only<3->{{\color{darkred}k \in \mathbb{Z}}}
\]
produces an \only<1-2>{$N$-point}\only<3->{{\color{darkred}$N$-periodic}} signal in the frequency domain
\end{frame}
\begin{frame}
\frametitle{Discrete Fourier Series (DFS)}
\begin{center}
DFS = DFT with periodicity explicit
\end{center}
\vspace{1em}
\begin{itemize}
\item the DFS maps an $N$-periodic signal onto an $N$-periodic sequence of Fourier coefficients
\item the inverse DFS maps an $N$-periodic sequence of Fourier coefficients a set onto an $N$-periodic signal
\item the DFS of an $N$-periodic signal is mathematically equivalent to the DFT of one period
\end{itemize}
\end{frame}
\begin{frame} \frametitle{Finite-length time shifts revisited}
\begin{center}
The DFS helps us understand how to define time shifts for finite-length signals.
\end{center}
\vspace{1em}
For an $N$- periodic sequence $\tilde{x}[n]$:
\begin{itemize}
\item<2-> $\tilde{x}[n-M]$ is well-defined for all $M \in \mathbb{N}$
\item<3-> $\DFS{\tilde{x}[n-M]} = e^{-j\frac{2\pi}{N}Mk}\tilde{X}[k]$ (easy derivation)
\item<4-> $\IDFS{
\only<4>{e^{-j\frac{2\pi}{N}Mk}}
\only<5->{\hlBox{t1}{green!30}{e^{-j\frac{2\pi}{N}Mk}}}\,\,\tilde{X}[k]} = \tilde{x}[n-M]$
\end{itemize}
\vspace{2em}
\only<5->{
\hspace{14em}\rnode[lc]{T1}{ a delay in time becomes a {\em linear phase} factor in frequency}
\nccurve[linecolor=green!30,angleA=180,angleB=-75]{->}{T1}{t1}}
\end{frame}
\begin{frame} \frametitle{Finite-length time shifts revisited}
For an $N$-point signal $x[n]$ :
\begin{itemize}[<+->]
\item $x[n-M]$ is {\em not} well-defined
\item what is $\IDFT{{\color{darkred}e^{-j\frac{2\pi}{N}Mk}}\,\,X[k]}$ ?
% \item build $\tilde{x}[n] = x[n \mod N] \,\, \Rightarrow \,\, \tilde{X}[k] = X[k]$
% \item $\IDFT{{\color{darkred}e^{-j\frac{2\pi}{N}Mk}}\,\,X[k]} = \IDFS{e^{-j\frac{2\pi}{N}Mk}\tilde{X}[k]} = \tilde{x}[n-M] = x[(n-M)\mod N]$
% \vspace{0.5em}
% \item shifts for finite-length signals are ``naturally'' circular
\end{itemize}
\end{frame}
\begin{frame} \frametitle{Finite-length time shifts revisited}
\begin{align*}
\IDFT{e^{-j\frac{2\pi}{N}Mk}\,X[k]}[n] &= \frac{1}{N} \sum_{k = 0}^{N-1} X[k]e^{-j\frac{2\pi}{N}Mk} \, e^{j\frac{2\pi}{N}nk} \\ \pause
&= \frac{1}{N} \sum_{k = 0}^{N-1} \left( \sum_{m = 0}^{N-1} x[m]\, e^{-j\frac{2\pi}{N}mk} \right) \, e^{-j\frac{2\pi}{N}Mk} \, e^{j\frac{2\pi}{N}nk} \\ \pause
&= \frac{1}{N} \sum_{m = 0}^{N-1} x[m] \sum_{k = 0}^{N-1} \, e^{j\frac{2\pi}{N}(n - M -m)k}\\
\end{align*}
\end{frame}
\begin{frame} \frametitle{Always remember the orthogonality of the roots of unity!}
\centering
\[
\sum_{k=0}^{N-1} e^{j\frac{2\pi}{N}pk} = \begin{cases}
N & \mbox{if $p$ multiple of $N$}\\
0 & \mbox{otherwise}
\end{cases}
\]
\end{frame}
\begin{frame} \frametitle{Finite-length time shifts revisited}
\[
\IDFT{e^{-j\frac{2\pi}{N}Mk}\,X[k]}[n] = \frac{1}{N} \sum_{m = 0}^{N-1} x[m] \sum_{k = 0}^{N-1} \, e^{j\frac{2\pi}{N}(n - M -m)k}
\]
\vspace{1em}
\pause
\[
\sum_{k = 0}^{N-1} e^{j\frac{2\pi}{N}((n - M) - m)k} =
\begin{cases}
N & \mbox{for $((n-M)-m)$ multiple of $N$}\\
0 & \mbox{otherwise}
\end{cases}
\]
\vspace{2em}
\pause
\centering
is there an $m$ between $0$ and $N$ so that $((n-M)-m)$ multiple of $N$?
\end{frame}
\begin{frame} \frametitle{Modulo operator}
\begin{center}
given $C\in \mathbb{N}$, find $m$ such that $0 \leq m < N$ and $C-m$ is a multiple of $N$
\end{center}
\pause
\vspace{1em}
any integer $C$ can be written as $C = pN + (C \mod N), \quad p\in\mathbb{N}$:
\begin{itemize}
\item $ 0 \leq (C \mod N) < N$
\item $C - (C \mod N)$ is a multiple of $N$
\end{itemize}
\end{frame}
\begin{frame} \frametitle{Finite-length time shifts revisited}
\[
\sum_{k = 0}^{N-1} e^{j\frac{2\pi}{N}(n - M -m)k} =
\begin{cases}
N & \mbox{for $m = (n-M) \mod N$}\\
0 & \mbox{otherwise}
\end{cases}
\]
\vspace{1em}\pause
\begin{align*}
\IDFT{e^{-j\frac{2\pi}{N}Mk}\,X[k]}[n]&= \frac{1}{N} \sum_{m = 0}^{N-1} x[m] \sum_{k = 0}^{N-1} \, e^{j\frac{2\pi}{N}(n - M -m)k}\\
&= x[(n-M) \mod N]
\end{align*}
\vspace{1em}\pause
\centering
shifts for finite-length signals are ``naturally'' circular
\end{frame}
\end{document}

Event Timeline