I've succeeded in converting sound to data using FFT, but I don't know how to convert this data into reverse phase and make sound again. Can I know the code for this?
From helicopter view, The theory says that any signal is the sum of multiple sinusoids at different frequency / amplitudes.
The DFT/FFT process helps you divide a number of sample into its components, those single sinusoidal oscillations at distinct frequencies each with their own amplitude and phase.
In a nutshell, to reconstruct the signal (or something close to the signal using the dominant frequencies) you need to sum back all the sinusoids. This is known as ifft (inverse FFT). Because of the sampling process there will be artifacts that you need to take into account
It’s discussed in many places - here is a first Google hit
Why would you want to do fft followed by ifft?
Just to prove it can be done? That is OK!
Usually one would use fft to make spectrum analyzer or something like that. Or maybe as a start of a compression algorithm.
But most arduinos can only hold a few seconds of audio in RAM... also arduino is not likely to be fast enough for fft ifft in real time...
After computing the inverse FFT, to make sound, you will need a digital to analog converter of some sort (most Arduinos do no have one), an audio amplifier and speaker.