2
$\begingroup$

I am a computer science student and want to do some stuff with audio data. I want to use the DFT to analyze and synthesize some sounds. Before going to the more complex stuff I experimented with basic tones and found some issues I do not understand - therefore I want to ask for help in this physics forum.

I created a single sinus wave function with an audioprogram of $440\textrm{ Hz}$. From this I take the DFT and want to recreate the original signal from this. While doing so, first I emit the negative frequencies, thus take only the first $n/2$ frequencies. $N$ is my blocksize (I divide the signal into blocks of length $n$). The sampling rate of my audio signal is $44100\textrm{ Hz}$. So when I do this, and take the IFT from the resulting data, I can perfectly reconstruct my signal.

Now to my issues and questions:

  1. When I set the phase to $0$ in the Fourier space (the imaginary part), with different $n$, I recover a sinus signal with some periodic noise.
    • I assume this is the phase difference which can be heard between the blocks?
  2. When I set $n$ to $44100$ (the sampling frequency), I get complete noise.
    • Why is that?
  3. Now I want to take only the strongest frequency amplitude wise (which in my opinion should perfectly work) - thus I set all other frequencies in the Fourier space to $0$ and then do the IFT. For different $n$ this kind of works, I get a sinus signal with some periodic noise.
    • Why the noise?
    • Moreover, the frequency of the resulting tone changes with $n$. Why is that?
    • With $n = 44100$ I get complete silence. Why?
  4. When I set the phases to $0$ again I get the same results.

I hope it's somewhat interesting for you too. Could you explain to me these "phenomena"?

$\endgroup$
  • 2
    $\begingroup$ Would Signal Processing be a better home for this question? $\endgroup$ – Qmechanic Dec 30 '16 at 0:08
  • $\begingroup$ I never heard it called a sinus signal. The sinus is part of the human nose. $\endgroup$ – JMLCarter Dec 30 '16 at 0:30
  • $\begingroup$ it's going to be moved, not answered here. 1) see 4, below. 2) You cannot detect frequencies greater than half your sampling rate. en.wikipedia.org/wiki/Nyquist_frequency 3) If your source is a real audio source there will be noise in it. Your detector will introduce further noise. You will get some harmonic frequencies detected by the transform, but it does not introduce "noise" per se. 4) Phase information is not retained by a Fourier Transform. Preventing re-construction of the original waveform correctly. This can sound like noise. $\endgroup$ – JMLCarter Dec 30 '16 at 0:41
  • $\begingroup$ Thanks. I know Nyquists theorem, but 440 Hz is by far below the maximum rate for a sampling rate of 44100 Hz? So what does this have to do with it? Also I do not see any connection between Nyquists theorem and my question asked here - as this noise or silence only occurs when n = 44100, and I can reconstruct the signal for n = 44100 - 1. $\endgroup$ – Gemini Dec 30 '16 at 0:44
  • 1
    $\begingroup$ 2. @JMLCarter is wrong to say the FFT does not retain phase information. It doesn't if you only look at the magnitude of the output; but if you keep the whole complex value of the output, you will not lose phase information. $\endgroup$ – The Photon Dec 30 '16 at 0:56
1
$\begingroup$

Part of the problem is that you are using sine waves. The imaginary components of an FFT result contains all the information about pure sine waves (e.g. that are equivalent to a sin() function that starts with phase of zero at the start of the FFT aperture, and that are exactly integer periodic in aperture). If you use only the real part of an FFT result, you can only see cosine waves (not sine waves, periodic in aperture), thus your silent result.

For shorter FFTs, the real component of the result might contain windowing artifacts if the frequency of your sine wave is between FFT result bins for the given FFT length (e.g. not integer periodic in aperture). So, in synthesis, you are hearing an artifact, quantized in frequency.

$\endgroup$
1
$\begingroup$

Mathematically, an FFT is a specific form of Fourier transform. First you only sample it at a fixed grid of points, leading to a periodic frequency representation (you cannot distinguish sine waves whose frequency differs by whole multiples of the sampling frequencies). This is something you already need to deal with at the sampling stage by prepending appropriate low-pass filtering.

Then you take the sample window of your data and repeat it an infinite number of times. As a result of that operation, the resulting Fourier transform will only contain components with a periodicity of whole multiples of your sample window length. As another result of that operation, sine signals with a period not an exact multiple of the sampling window will have discontinuities at the points they are "pasted together".

One uses "windowing" in order to get a good compromise between the resulting frequency bleed over frequency bins and a reasonable symbolic accuracy of signal representation.

Note that as long as you do nothing with your transformed data but transform it back unchanged, it will be reconstructed perfectly: the FFT is an information-preserving transform.

It's just not a Fourier transform in the manner that is so nice for calculating frequency responses of passive circuitry because it works on time-discretized forced-periodic data with resulting discrete frequency bins.

$\endgroup$

Your Answer

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