Q:

Cleaning up noisy audio signal

Can you give a circuit that would clean up noisy audio signal?

Basically, I have created a square wave from a software (Real Time Analyzer) at certain frequency to the audio jack port of the computer. 
The output of the oscilloscope yields the signal as shown on the top part of the image above. The signal I created from the software is similar to the bottom part of the image. There is no problem with the software. My problem is how to clean the noisy signal from the audio jack? That is, how to make the output from the circuit created similar to the bottom part of the image?
I want to have a circuit that would clean the signal.

A:

The simplest way would be to simply feed it through any logic IC which features Schmitt Triggering. 
A Schmitt trigger has what is called input hysteresis.  
This includes many of the 7400 series of logic ICs. There is a list Here, just Ctrl+F for "schmitt".

Alternatively, if you really want to do it yourself, it's pretty simple to achieve with an Op-Amp.

The way this circuit works is fairly simple.  

Take the above schematic, and imagine the "input" pin is at -V.  
Since the voltage at the "+" input is less then the voltage at the "-" input, the value of "Output" will be Low (in this case, approximately -V).
Now, "Input" begins to rise. However, notice that there are two resistors. To cause the output to change to High, the voltage at the "+" input has to increase until i is greater then the voltage at the "-" input. This means that the value of input has to increase above the value of the negative input by an amount determined by the ratio of the resistor divider.
Now, as soon as the "+" input is higher then the value of the "-" input, the value of output will go High (in this case, it will be approximately the value of +V).
Since the output is also fed into the input through the resistor divider, once the output has gone positive, the threshold to cause the output to go negative changes as a function of the resistor divider. 
When the Voltage at input decreases, the same happens in reverse: Because the end of the voltage divider is now at +V, the value of input has to go below the value of the - input to cause the output to become low.

All together, this is called positive feedback (as you can see, the output is connected to the positive input. As a result, the transition threshold is affected by both the output state and the input state
The term for this, e.g. the output as both a function of the input and the previous output is Hysteresis.
When hysteresis is implemented in a circuit like this, it is called input hysteresis.

