[Tex/LaTex] Noisy, analogue waveform in TikZ

audiodiagramstikz-pgf

Is there an easy way of drawing a noisy waveform in TikZ? I know you can draw a simple sinusoid by repeatedly using cos and sin for every half-period, but doing that for a noisy waveform seems like a massive undertaking and a very roundabout way of doing it.

I'm looking for something like this: Noisy waveform

It doesn't have to be that long, a fifth of the length is fine. I'm diagramming a noise reduction system and need to show a noisy waveform as the input to the diagram (whereas the rest of the diagram is simple rectangular boxes and text…).

Any ideas?

Best Answer

You can use \draw plot for plotting functions. For the noise, you can use the rand function.

In general, plotting is more comfortable using the PGFPlots package, which builds on PGF/TikZ:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
    \begin{tikzpicture}[samples=200, domain=0:5*360]
        \begin{axis}[
            width=10cm, height=4cm,
            enlarge x limits=false,
            xtick=\empty,
            axis lines*=middle,
            hide y axis
        ]
        \addplot [no markers, smooth] {sin(x)+rand*2};
        \end{axis}
    \end{tikzpicture}
\end{document}
Related Question