# Waveform filter - what's in the black box?

I'm trying to come up with an algorithm or filter that has the i/o characteristics in the image below (waveform plotted from audio data) .. I input a sine wave or saw and the resulting graphic is an area filled wave.

I've been trying different filters like a moving average and gaussian smooth, but it's not right.

The idea is to go from the raw data input waveform and generate an area filled and smooth graphic like the output. I'm interested in the 'smoothed' data points.

By looking at the input and output, can anybody see what tranformations would be in the black box to create the resulting data set?

The only one I'm sure of is the waveform is inversed and added to the original - but what else happens?

(i can upload more examples if a specific input waveform would help)

y-axis data min/max is -1 to 1

http://i.stack.imgur.com/1Ppkb.png

http://i.stack.imgur.com/Xv1sZ.png

-
It's not clear what the output image shows -- there seem to be two signals, a positive one and a negative one, at the same time? Or is that a signal oscillating too rapidly to be seen and what you see is the envelope? Whatever it is, it has roughly the shape of $\pm\sqrt{|f|}$, where $f$ is the input. – joriki Jan 7 '12 at 7:44
Your edits didn't answer joriki's question. A waveform is typically drawn as a single curve like in the input image, not a filled region like in the output (unless, as joriki said, the signal is oscillating too rapidly to be seen). How did you create the input and output images? They're clearly in different styles -- perhaps it might help if you rendered the output signal in the same way as you rendered the input? – Rahul Jan 7 '12 at 8:09
The output waveform area is filled in .. I'm trying to emulate the desired output signal so it's not possible for me to render it using the same style. The idea is to go from raw data of the input waveform and generate an area filled and smooth graphic like the output – Rob Jan 7 '12 at 8:25
Then you should clarify the question accordingly -- it says "the resulting wave is the output you see", but now you're saying the output is in fact not a wave but an area. – joriki Jan 7 '12 at 8:38
updated.. thanks! (new to this) – Rob Jan 7 '12 at 8:44

It appears that the filled area lies between curves proportional to either $\pm\sqrt{|f|}$ or $\pm\log|f|$, where $f$ is proportional to the input signal. The logarithmic version would require some cutoff to avoid large negative values near $f=0$. Since such waves are usually digitally sampled, this could be done by taking the logarithm of the integer sample value, which would be $0$ for an input of $1$, and then defining the output to also be $0$ for an input of $0$. You can see in this plot that it's hard to tell with the naked eye which of the two it is. From what I know about audio, I'd expect that the logarithm would make more sense. If you can, you should apply both of those functions to the input you gave as an example and then compare the outputs in detail.