I'm trying to generate a sawtooth wave using the IFFT. I can do this successfully by first performing an FFT and then putting that analysed spectrum into the IFFT, however I would really like to be able to write a UI that enables me to draw the bin magnitudes and generate a full spectrum ready for IFFT from that. I have been partially successful, however the waveforms don't look/sound quite right even though the spectrum input is per the formula for synthesising a sawtooth wave.

My question is how do I generate a spectrum array of complex values for an IFFT when all I have are the magnitude values?

I know that bin 0 and 1 are zero valued. I've been trying to render the wave by only calculating the magnitudes and phases for the significant bins (bins with magnitude > 0). Am I able to put white noise in the remaining magnitude bins and then calculate the accompanying phases at the centre frequency or alternatively calculate these non significant bins as random phase? my start phase is -90, bin size 1024, complex fft. Thanks in advance for your contribution.

  • $\begingroup$ Why you want to do this? You know what you want in the frequency domain OR the time domain and you only rely on one of these. $\endgroup$ – Moti Jun 27 '15 at 1:12
  • $\begingroup$ Hi moti. I'm not just $\endgroup$ – cixelsyd Jun 29 '15 at 19:56
  • $\begingroup$ I'm trying to calculate the phases based one the note frequency. I've coded this and my Ifft works but only if my note frequency is a bin Center frequency multiple. As soon as the frequency varies off the Center frequency my waveform starts to break up $\endgroup$ – cixelsyd Jun 29 '15 at 19:59
  • $\begingroup$ When you have a "non centered" frequency, the FFT includes many frequencies, each with a different phase. You can not do IFFT of the power spectrum - you must maintain the phase. $\endgroup$ – Moti Jul 1 '15 at 1:34
  • $\begingroup$ Hi Moti. Thank you for your response. are you able to explain this further? What your saying is matching what I am seeing. I am calculating the new phases based on the delta of my frequency for each bin to the frequency of the harmonic but my waveform seems to break down the more I'm moving away from the centre frequency. If I generate at the centre frequency it is absolutely perfect. I guess I don't understand why my synthesis method works perfectly at a 'centered' frequency but not for an off centre frequency. $\endgroup$ – cixelsyd Jul 2 '15 at 4:25

I believe that if you will keep the phases and not convert it into magnitude (power spectrum) the IFFT will work. When you use the center frequency, the phase is 0, in other words, the real part is also the magnitude. As you move from the center frequency the error in magnitude growth as the phase growth. As result your error in recovery by means of IFFT growth.

|improve this answer|||||
  • $\begingroup$ you're exactly right Moti. I underestimated how much the phase means to the spectrum. $\endgroup$ – cixelsyd Jul 4 '15 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.