I want to plot the waveform of an audiosnippet. Since I am working in matlab I exported my audiofile as csv with two columns (n, in). Of course this produces a huge file of about 40MB for my 1 000 000 datapoints. When I now try to plot this using pgf latex will run into a memory error.
TeX capacity exceeded, sorry [main memory size=5000000]. ...=in,col sep=comma] {audio.csv};
Here is the code I am using to plot:
\begin{tikzpicture}
\begin{axis}[width = 18cm, height=6cm,grid=both,xlabel={$n$},ylabel={$x(n)$},ymin=-1, ymax=1,minor y tick num=1,xmin=0, xmax=1000000]
\addplot[color=niceblue] table[x=n,y=in,col sep=comma] {audio.csv};
\end{axis}
\end{tikzpicture}
My first try was to reduce the filesize by only using every 128th datapoint. But this way I lose "interesting" datapoints, like the peaks. This makes my plot look incorrect.
Does anyone have an idea how to get a nice plot for my waveform?
Best Answer
Perhaps you can reduce the number of points by only plotting the envelope of the waveform. Im not certain if that would suffice for your waveform, but you can use Matlab to extract the envelope from the waveform; http://mathworks.com/help/signal/ug/envelope-extraction-using-the-analytic-signal.html