Search code examples
pythonaudiosignalssignal-processingsampling

How to create a signal with certain sampling frequency and time?


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?


Solution

  • 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.