I have a project in Python with a friend where we want to manipulate music sound, and we'll need Fourier Transforms, so I made research online and wanted to know if I understand correctly the concepts.
Here is what I think I understand so far:

(the module numpy is noted np)

For a temporal signal x(t) made to an array x, sampled at a constant interval dt with N samples, sampled at a sampling rate sr:

  • the Fourier transform decompose a signal x(t) in an infinite sum: $x(t)= A_{1}e^{iw_1t} + A_{2}e^{iw_2t}+A_{3}e^{iw_3t}+...+ A_{n}e^{iw_nt} \\$ where $A_n = r_ne^{ip_n}$, and $w_n$ is a frequency
  • amplitude at the given frequency $w_n$: $r_n = np.abs(A_n) = \sqrt{real(A_n)^2 + complex(A_n)^2}$
  • phase at the given frequency $w_n$: $p_n = np.angle(A)$
  • np.fft.fftfreq(N, 1/sr): returns all the frequencies $w$ present in the wave as an array: $[w_1, w_2, w_3, ..., w_n]$
  • np.fft.fft(array x): returns a 2D array with complex values which correspond to $[A_1, A_2, ..., A_n]$
  • period of the signal: $T = dt \times N$
  • fundamental frequency (Hz): $df = 1/T$
  • fundamental frequency (rad/sec): $dw = 2π/T$
  • fundamental frequency (adimensional): $f = np.fft.fftfreq(N)\times N \times df$ ?
  • fundamental frequency (adimensional): $w = np.fft.fftfreq(N) \times N \times dw$ ?
  • duration = number of frames (length of my array) $\div$ sample rate ?

I had some questions too:

  • In order to plot/make a spectrogram, I need to have the duration of my wave, the frequencies ($w_1, w_2, ..., w_n$) in it, and the amplitudes for each frequencies ($A_1, A_2, ..., A_n$). For each value of t of my wave duration, I have the frequencies. I then calculate the amplitude of all the frequencies since its a function of time (e.g: $A_1e^{iw_1t}$) ?
  • If I want to generate a more complex sound that just one frequency, I need to generate many frequencies which amplitudes vary over time ? I want to be able to generate samples (i.e: those kind of sound : link)

Thank you very much for your attention!


Your Answer

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

Browse other questions tagged or ask your own question.