% AudioSignalProcessing-HA.tex
\begin{hcarentry}[updated]{Audio Signal Processing}
\label{audiosp}
\report{Henning Thielemann}%11/11
\status{experimental, active development}
\makeheader

In this project, audio signal algorithms are written in Haskell,
that is,
no binding to existing sound synthesis systems like SuperCollider. % or Csound.
The highlights are:
\begin{compactitem}
\item It is based on the Numeric Prelude framework (\url{http://haskell.org/communities/05-2009/html/report.html#sect5.6.2}).
% \item a basic signal synthesis backend for Haskore (\url{http://haskell.org/communities/05-2009/html/report.html#sect5.12.1}),
% \item experimental structures for filter networks,
% \item basic audio signal processing, including some hard-coded frequency filters,
\item We support physical units while maintaining efficiency.
% that is, the plain data can be stored in a very simple number format,
% even fixed point numbers,
% but the sampling parameters rate and amplitude can be complex types,
% like numbers with physical units,
% \item unlike other software synthesizer packages,
% there are not two global rates, namely control and audio rate.
% Instead there can be many different rates,
% and a signal processor can have different control and audio rate,
% in which case the internal processor control parameters are interpolated.
\item There are frameworks for abstraction from sample rate.
That is, the sampling rate can be omitted in most parts
of a signal processing expression.
% They are inferred automatically,
% just as types are inferred in Haskell's type system.
% We tried hard to preserve the functional style of programming
% and do not need Arrows and according notation.
\item
We provide several low-level implementations in order to achieve reasonable speed.
% The standard list data structure is very convenient for programming,
% and especially the element-wise laziness
% allows for a range of very elegant implementations,
% but it is much too slow for signal processing.
We complement the standard list type
with a lazy \verb|StorableVector| structure
and a \verb|StateT s Maybe a| generator, like in stream-fusion.
% Now, both our custom signal generator type
% and the Stream type from stream-fusion
% can be fused to work directly on storable vectors.
\item
There is support for causal processes.
Causal signal processes only depend on current and past data
and thus are suitable for real-time processing
(in contrast to a function like time reversal).
% All arrow operations like function composition
% maintain the causality property.
We express causal processes
by arrows that work internally like a \verb|mapAccumL|.
They are important
for sharing on a per sample basis and in feedback loops
where they statically warrant that no future data is accessed.
\item
Allow to describe acyclic arrow networks using a functional notation.
By observation of sharing and the new \texttt{Vault} data structure
we get the same efficiency
as when using arrow combinators or the arrow syntax.
\item Type class framework for unifying lazy time values
and signals expressed by lists, storable vectors or signal generators.
\item Connection to ALSA bindings, in order to provide real-time sound synthesis
controlled by MIDI events from keyboards or sequencers.
% \item Stand-alone binding to Sox for audio format conversion and playback,
% \item improved safety of causal processes with physical dimensions,
% \item A pyramid filter for efficient computation
% of moving average and moving maximum
% for baseline detection of mass spectra,
% \item Novel algorithm for independent modulation of time and phase of a sampled monophonic sound,
% \item Implementation of the Fast Fourier Transform for all signal lengths,
% that can be used both for complex numbers and integer residue class fields.
% \item Novel algorithm for white noise generation that adapts to the sampling rate.
\item
A real-time software synthesizer
that employs Just-In-Time-compilation and vector instructions
provided by the Low-Level Virtual Machine (\url{http://llvm.org/})
\end{compactitem}

\noindent
Recent advances are:
\begin{compactitem}
\item Extended and safer bindings to ALSA PCM and ALSA MIDI sequencer.
\item New bindings to \texttt{libsox} for reading and writing
many audio file formats.
\item MIDI, ALSA and LLVM code is now cleanly separated.
\end{compactitem}

% \FuturePlans
% \begin{itemize}
% \item
% Design a common API to the Haskell synthesizer code,
% CSound support included in Haskore~\cref{haskore},
% and the SuperCollider interface.
% \item
% Connect with the HaskellDSP library % \url{http://www.haskell.org/haskellwiki/DSP}.
% \item
% Hope on faster code generated by Haskell compilers.\ \texttt{:-)}
% In simple setups GHC generated code can compete with C,
% but in more complex ones the performance is not satisfying.
% \end{itemize}

\FurtherReading
\begin{compactitem}
\item \url{http://www.haskell.org/haskellwiki/Synthesizer}
% \item \url{http://dafx04.na.infn.it/WebProc/Proc/P_201.pdf}
% \item \url{http://arxiv.org/abs/0911.5171} % Pitch shift and more
% \item \url{http://arxiv.org/abs/1004.4796} % LLVM synth
% \item \url{http://arxiv.org/abs/1103.4118} % Sampling-rate aware noise
% \item \url{http://hackage.haskell.org/package/vault}
\end{compactitem}
\end{hcarentry}
