\section{Theoretical Background}
The following subchapters shall supply the reader with the theoretical foundation of digital signal processing to better understand the following implementation of ANR on a low-power signal processor.\\ \\
The chapter begins with the basics of digital signal processing in general, covering fundamental topics like signals, transfer functions and filters.\\
Filters are used in various functional designs, therefore a short explanation into the concepts of Finite Impulse Response- and Infinite Impulse Response filters is indispensable.\\
At this point an introduction into adaptive noise reduction follows, including a short overview of the most important steps in history, the general concept of ANR, its design possibilities and its use of the Least-Mean-Square algorithm.\\
With this knowledge covered, a realistic signal flow diagram of an implanted CI system with corresponding transfer functions is designed, essential to implement ANR on a low-power digital signal processor.\\
At the end of chapter two, high-level Python simulations shall function as a practical demonstration of the recently presented theoretical background.\\ \\
\subsection{Fundamentals of digital signal processing}
Digital signal processing describes the manipulation of digital signals on a digital signal processor (DSP) trough mathematical approaches. Analog signals have to be digitalized before being able to be handled by a DSP. 
\subsubsection{Signals}
\begin{figure}[H]
    \centering
    \includegraphics[width=0.8\linewidth]{Bilder/fig_dsp.jpg}
    \caption{Block diagram of processing an analog input signal to an analog output signal with digital signal processing in between  \cite{source_dsp_ch1}}
    \label{fig:fig_dsp}
\end{figure}
Before digital signal processing can be applied to an analog signal like human voice, several steps are required beforehand. An analog signal, continuous in both time and amplitude, is passed through an initial filter, which limits the frequency bandwidth. An analog-digital converter then samples and quantities the signal into a digital form, now discrete in time and amplitude. This digital signal can now be processed, before (possibly) being converted to an analog signal again (refer to Figure \ref{fig:fig_dsp}). The sampling rate defines, in how many samples per second are taken from the analog signal - a higher sample rate delivers a more accurate digital representation of the signal but also uses more resources. According to the Nyquist–Shannon sampling theorem, the sample rate must be at least twice the highest frequency component present in the signal to avoid aliasing of the signal. Aliasing describes the phenomenon, that high frequency parts of a signal are wrongly interpreted, if the sampling rate of the analog signal is too low. The digitlazied signal then contains low frequencies, which don´t occur in the original signal. \\ \\
Throughout this thesis, sampled signals are denoted in lowercase with square brackets (e.g. {x[n]}) to distinguish them from time-continuous signals 
(e.g. {x(t)}).\\ 
The discrete digital signal can be viewed as a sequence of finite samples with its amplitude being a discrete value, like a 16- or 32-bit integer. A signal vector of the length N, containing N samples, is therefore notated as
\begin{equation}
\label{equation1}
 x[n] = [x[n-N+1],x[n-N+2],...,x[n-1],x[n]]
\end{equation}
where x[n] is the current sample and x[n-1] is the preceding sample. 
\subsubsection{Time domain vs. frequency domain}
A signal (either analog or digital) can be displayed and analyzed in two ways: the time domain and the frequency domain. The time domain shows the amplitude of the signal over time - like the sine waves from Figure \ref{fig:fig_interference}. If a Fast Fourier Transformation (FFT) is applied to the signal in the time spectrum, we receive the same signal in the frequency spectrum, now showing the spectral power present in the signal (refer to Figure \ref{fig:fig_fft}).\\ \\
\begin{figure}[H]
    \centering
    \includegraphics[width=0.8\linewidth]{Bilder/fig_fft.jpg}
    \caption{Sampled digital signal in the time spectrum and in the frequency spectrum  \cite{source_dsp_ch1}}
    \label{fig:fig_fft}
\end{figure}
\subsubsection{Transfer Functions and filters}
When we discuss signals in a mathematical way, we need to explain the term ``transfer function''. A transfer function is a mathematical representation of an abstract system that describes how an input signal is transformed into an output signal. This could mean a simple amplification or a phase shift applied to an input signal.
\begin{figure}[H]
    \centering
    \includegraphics[width=0.8\linewidth]{Bilder/fig_transfer.jpg}
    \caption{Simple representation of a transfer function taking a noisy input signal and delivering a clean output signal  \cite{source_dsp_ch1}}
    \label{fig:fig_transfer}
\end{figure}
\noindent In digital signal processing, especially in the design of a noise reduction algorithm, transfer functions are essential for modeling and analyzing filters, amplifiers, and the pathway of the signal itself. By understanding a system’s transfer function, one can predict how sound signals are altered and therefore how filter parameters can be adapted to deliver the desired output signal.\\ \\
During the description of transfer functions, the term ``filter'' was used but not yet defined. A filter can be understood as a component in signal processing, designed to modify or extract specific parts of a signal by selectively allowing certain frequency ranges to pass while attenuating others. Filters can be static, meaning they always extract the same portion of a signal, or adaptive, meaning they change their filtering behavior over time according to their environment. Examples for static filter include low-pass-, high-pass-, band-pass- and band-stop filters, each tailored to isolate or remove particular frequency content (refer to Figure \ref{fig:fig_lowpass}).
\begin{figure}[H]
    \centering
    \includegraphics[width=0.8\linewidth]{Bilder/fig_lowpass.jpg}
    \caption{Behavior of a low-pass-filter. At the highlighted frequecny $f_c$ of 3400 Hz, the amplitude of the incoming signal is reduced to 70\%  \cite{source_dsp_ch2}}
    \label{fig:fig_lowpass}
\end{figure}
\subsection{Filter designs}
Before we continue with the introduction to the actual topic of this thesis, adaptive noise reduction, two very essential filter designs need further explanation - the Finite Impulse Response- and Infinite Impulse Response filter. 
\subsubsection{Finite Impulse Response filters}
A Finite Impulse Response (FIR) filter, commonly referred to as a ``Feedforward Filter'' is defined through the property, that it uses only input values and not feedback from output samples to determine it´s filtering behavior - therefore, if the input signal is reduced to zero, the response of a FIR filter reaches zero after a finite number of samples.\\ \\
Equation \ref{equation_fir} specifies the input-output relationship of a FIR filter - $x[n]$ is the input sample, $y[n]$ is output sample, and $b_0$ to $b_M$ the filter coefficients and M the length of the filter
\begin{equation}
\label{equation_fir}
 y[n] = \sum_{k=0}^{M} b_kx[n-k] = b_0x[n] + b_1x[n-1] + ... + b_Mx[n-M]
\end{equation}
Figure \ref{fig:fig_fir} visualizes a simple FIR filter with two coefficients - the first sample is multiplied with the operator $b_0$ whereas the following sample $b1$ is multiplied with the operator $b_1$ before added back together. The Operator $Z^{-1}$ represents a delay operator of one sample.
\begin{figure}[H]
    \centering
    \includegraphics[width=0.8\linewidth]{Bilder/fig_fir.jpg}
    \caption{FIR filter example with three feedforward operators}
    \label{fig:fig_fir}
\end{figure}
\subsubsection{Infinite Impulse Response filters}
An Infinite Impulse Response (IIR) filter, commonly referred to as a ``Feedback Filter'' can be seen as an extension of the FIR filter. In contrary to its counterpart, it also uses past output samples in addition to current input samples to adapt it´s filtering behavior - therefore the response of an IIR filter theoretically continues indefinitely, even if the input signal is reduced to zero.\\ \\
Equation \ref{equation_iir} specifies the input-output relationship of a IIR filter. In addition to Equation \ref{equation_fir} there is now a second term included, where $a_0$ to $a_N$ are the feedback coefficients with their own filter length N.
\begin{equation}
\label{equation_iir}
 y[n] = \sum_{k=0}^{M} b_kx[n-k] - \sum_{k=0}^{N} a_ky[n-k] = b_0x[n] + ... + b_Mx[n-M] - a_0y[n] - ... - a_Ny[n-N]
\end{equation}
Figure \ref{fig:fig_iir} visualizes a simple IIR filter with one feedforward coefficient and one feedback coefficient. The first sample passes through the adder after it was multiplied with $b_0$. After that, it is passed back after being multiplied with $a_0$ and is added two the second sample, also multiplied with $b_0$.
\begin{figure}[H]
    \centering
    \includegraphics[width=0.8\linewidth]{Bilder/fig_iir.jpg}
    \caption{IIR filter example with two feedforward operators and two feedback operators}
    \label{fig:fig_iir}
\end{figure}
\subsubsection{FIR- vs. IIR-filters}
Due to the fact, that there is no feedback, a FIR filter offers unconditional stability, meaning that the filter response always converges, no matter how the coefficients are set. The disadvantages of the FIR design is the relatively flat frequency response and the higher number of needed coefficitents needed to achieve a certain frequency response compared to its Infinite Impulse Response counterpart.\\ \\
The recursive nature of an IIR filter, in contrary, allows to achieve a sharp frequency response with significantly fewer coefficients than an equivalent FIR filter, but it also opens up the possibility, that the filter response diverges, depending on the set coefficients.\\ \\
A higher number of needed coefficients implies, that the filter itself needs more time to complete it´s signal response, as more samples are needed to pass the filter.
\subsection{Introduction to Adaptive Nose Reduction}
\subsubsection{History}
The necessity for the use of electric filters arose the first time in the beginnings of the 20th century with the development of the quite young fields of tele- and radio-communication. At his time, engineers used static filters like low- or highpass filters to improve transmission quality - this fundamental techniques allowed limiting the frequency spectrum, by cutting out certain frequencies like high-pitched noises or humming. From this time on, the development of new filter designs accelerated, for example with the soon-to-be developed LC-filter by Otto Zobel, an American scientist working at the telecommunication company AT\&T. Until then, the used filters were static, meaning they didn't change their behavior over time.\\ \\
In the 1930s, the first real concept of active noise cancellation was proposed by the German Physician Paul Lueg. Lueg patented the idea of two speakers emitting antiphase signals which cancel each other out. Though his patent was granted in 1936, back at the time, there was no technical possibility detect and process audio signals in a way, to make his noise cancellation actually work in a technical environment.\\ \\
20 years after Lueg's patent, Lawrence Fogel patented a practical concept of noise cancellation, intended for noise suppression in aviation - this time, the technical circumstances of the 1950s enabled the development of an aviation headset, lowering the overall noise experienced by pilots in the cockpit of a helicopter or an airplane by emitting a 180 degree phase shifted signal of the recorded background noise of the cockpit into the pilots' headset. (see Figure \ref{fig:fig_patent}).  
\begin{figure}[H]
    \centering
    \includegraphics[width=0.7\linewidth]{Bilder/fig_patent.jpg}
    \caption{Reconstruction of Lawrence Fogel´s patent in 1960. \cite{source_patent}}
    \label{fig:fig_patent}
\end{figure}
\noindent In contrary to the static filters in the beginning of the century, the active noise cancellation of Lueg and Widrow was far more advanced than just reducing a signal by a specific frequency portion like with the use of static filters, yet this technique still has their limitations as it is designed only to work within to a certain environment.\\ \\
With the rapid advancement of digital signal processing technologies, noise cancellation techniques  evolved from static, hardware-based filters and pyhsical soundwave cancellation towards more sophisticated approaches. In the then 1970s, the concept of digital adaptive filtering was introduced, allowing filters to adjust their parameters in real-time based on the characteristics of the incoming signal and noise. This marked a significant leap forward, as it enabled systems to cope with dynamic and unpredictable noise environments - the concept of adaptive noise reduction was born.\\ \\
\subsubsection{The concept of adaptive filtering}
Adaptive noise reduction describes an advanced filtering method based on an error-metric and represents a significant advancement over these earlier methods by allowing the filter parameters to continuously adapt to the changing acoustic environment in real-time. This adaptability makes ANR particularly suitable for hearing devices, where environmental noise characteristics vary constantly.\\ \\
Static filters low- and high-pass filters as described in the previous chapter feature coefficients that remain constant over time. They are designed for known, predictable noise conditions (e.g., removing a steady 50 Hz hum). While these filters are efficient and easy to implement, they fail to function when noise characteristics change dynamically.\\ \\
Although active noise cancellation and adaptive noise reduction share obvious similarities, they differ fundamentally in their application and signal structure. While active noise cancellation aims to physically cancel noise in the acoustic domain — typically before, or at the time, the signal reaches the ear — ANR operates within the signal processing chain, attempting to extract the digital noisy component from the desired digital signal. In cochlear implant systems, the latter is more practical because the acoustic waveform is converted into electrical stimulation signals; thus, signal-domain filtering is the only feasible approach.
\begin{figure}[H]
    \centering
    \includegraphics[width=0.8\linewidth]{Bilder/fig_anr.jpg}
    \caption{The basic idea of an adaptive filter design for noise reduction.}
    \label{fig:fig_anr}
\end{figure}
Figure \ref{fig:fig_anr} shows the basic concept of an adaptive filter design, represented through a feedback filter application. The signal sensor aims to recieve the input signal, which consists out of the target signal and the noise signal, whereas the noise sensor aims to recieve (ideally) only the noise signal, which then feeds the adaptive filter. The adaptive filter removes a certain, noise-related, frequency part of the input signal and re-evaluates the output through its feedback design. The filter parameters are then adjusted and applied to the next sample to minimize the observed error. In reality, a signal contamination of the two sensors has to be expected, which will be illustrated in a more realistic signal flow diagram of an implanted CI system.
\subsubsection{Static vs. hybrid filter design}
\subsubsection{Filter optimization}


\subsection{Signal flow diagram showing the origin of the useful signal,
noise signal, and their coupling}
\subsection{Derivation of the system’s transfer function based on the problem setup}
\subsection{Example applications and high-level simulations using Python}
