How do I invert audio pitch?

I’m trying to use a script to be able to invert an audio clip’s pitch, like they do when canceling out noise.

I’m using javascript.

Inverting the pitch of an audio clip isn’t what you’re looking for. [Here’s][1] a quick explanation why.

Pitch is frequency. Inverting the frequency will give you the period of the wave. P = 1 / f

Working with audio, you should know the basic terminology and equations for waves. First you have amplitude. Amplitude is the distance of the wave from the baseline. Then you have peaks and troughs. Peaks are the high parts of the wave, troughs are the low parts. Frequency is the number of times, per second, that the wave oscillates (peak to peak or trough to trough). Period is the time between each oscillation.

What you’re looking for is inverting the amplitude of the wave, which will make peaks into troughs and troughs into peaks. I have not done this before, but I believe these two methods are what you’re looking for… [AudioClip.GetData()][2] and [AudioClip.SetData()][3]

They both deal with floats between -1 and 1. That’s the amplitude, which is what you want to invert. Use GetData() to get all the data, then invert all the values in the array by doing data _= -1.0f * data* Then use SetData() to set it back. I have not done this before, but it should work. Good luck!_
[1]: Wavelength, Period,Frequency*

_[2]: http://docs.unity3d.com/Documentation/ScriptReference/AudioClip.GetData.html*_
_
[3]: http://docs.unity3d.com/Documentation/ScriptReference/AudioClip.SetData.html*_