I want to make a frequency shift on a .wav file.
So you've got an audio, which means a real-valued, signal.
The spectrum of a real valued signal has symmetry to f=0, i.e. it's Fourier Transform has hermitian symmetry.
If you now shift that input spectrum (blue), the result (red) loses symmetry, i.e. the resulting signal is no longer real:

Notice how things are, through aliasing, circular, so what you "shift out" of the Nyquist range will appear at the opposite end. In my example, this means that you get unexpected high frequency components!
The problem I have is that the FFT uses complex numbers, and the .wav file has integer values. So I want to make a frequency shift and that means that I have to make a direct transform and an inverse transform , the problem is that the inverse transform doesn't give me integer values (it gives me complex values), but I need integer values for the samples of the .wav file.
Indeed! And that's because the result of your shift really isn't a real signal anymore.
What you can do, however, is:
- shift (either in time or frequency domain – honestly, doing it in time domain would be easier! Just multiply the nth sample with exp(2j π f_shift/f_sample n ).)
- apply a complex bandpass filter that removes everything outside the frequency [0; f_sample / 2 - shift ]. This gives you what is called an analytical signal (i.e. only positive frequencies), which still isn't real-valued, because it's not symmetric.
- Throwing away the imaginary part now doesn't alter the information of your signal - it just halves the energy and gives you a symmetric spectrum, and something you can write to a .wav file.
Now, this whole "doing it in frequency domain through the FFT" is an approach that people in the Software Defined Radio world are pretty used to – they deal with complex baseband signals all the time.
How do I interpret the values of the inverse transform ?
As the complex signal that they are. Ignoring the imaginary part as suggested in the comments will lead to the energy contained in the negative frequencies being mirrored onto you positive frequencies (and the other way around), and is most likely not what you want – unless either:
- you've made sure that prior to this "symmetricalization", the energy on either side of f=0 was 0, so that nothing bad happens, pr
- you've made sure that you selectively shifted the negative and positive frequencies so, that symmetry was retained. Notice that this is not a "simple" shift of the whole frequency domain, but two selective shifts; the selection of these shifting regions has a shape, which boils down to using a window. If you just "select" or "not select" each bin for shifting, you're effectively applying a rectangular window – with all the Gibb's Phenomenom you can incur with that.