0

I want to define a sampling frequency, e.g. 100 kSamples/second, and a length for the audio sample, e.g. 4096 sampling points.

Then I want to calculate the number of spectral lines that I will get as well as the exact frequency that corresponds to each of those spectral lines.

I want to implement this in Python.

Can anyone throw out any ideas or links?

Alex Kulinkovich
  • 4,408
  • 15
  • 46
  • 50
JRD
  • 849
  • 7
  • 14
  • Before starting with looking at an audio signal, I would test my code with some simple sinusoids where you know how your output spectrum should look like. Have a look here https://stackoverflow.com/questions/25735153/plotting-a-fast-fourier-transform-in-python – Mouse On Mars Sep 10 '18 at 17:39

2 Answers2

0

Assuming that you are using a simple DFT: 1. The number of the spectral lines is equal to the number of the samples. Mind that there are spectral lines in both positive and negative frequencies. 2. The value and the implementation of the frequency vector calculation can be found here: https://docs.scipy.org/doc/numpy/reference/generated/numpy.fft.fftfreq.html

Gideon Kogan
  • 662
  • 4
  • 18
0

For some sampling frequency fs and N DFT bins, there are N frequency bins with the k-th one describing the contribution of the frequency

f_k = k * fs/N

The frequency bins w_k = 2*pi*k/ N of the DFT which are frequently discussed (e.g. in Wikipedia) are normalized in radians/sample, to get the real frequency, one has to take into account that w_(N-1) = ws.

cheersmate
  • 2,385
  • 4
  • 19
  • 32