How to use numpy with portaudio to extract bass, mid treble

后端 未结 2 536
梦谈多话
梦谈多话 2021-01-15 21:35

As in this example How to extract frequency information from an input audio stream (using PortAudio)? I\'m curious about portaudio and numpy...

I\'m not 100% sure

2条回答
  •  再見小時候
    2021-01-15 22:06

    Actually, you would not use a Fourier transform to do this.

    Splitting any audio signal in bass, mid and treble is usually done using filters. A filter is a signal processing device that attenuates certain frequency ranges. Filters can be build digitally or electrically. For example, they are used in the audio crossover systems in loudspeakers.

    To get the low-frequency bass part you would use a low-pass filter. Low-pass filters filter out high frequencies. They are also called 'high-cut' filters.
    To get the mid-frequency mid part you would use a band-pass filter. Band-pass filters filter out both low and high frequencies. They are also called 'bell-filters'.
    To get the high-frequency treble part you would use a high-pass filter. High-pass filters filter out any low frequencies. They are also called 'low-cut' filters.

    Actually, you could also only use the high-pass and low-pass filter. If you subtract both filtered signals from the original signal, the result would be a band-pass filtered signal. This saves you one filter.

    Each filter will have a threshold frequency. The threshold frequency is a special frequency, from which the filter should start filtering. Depending on the filter order, the signal will be attenuated by 6 dB/oct (1st order), 12 dB/oct (2nd order), 18 dB/oct (3rd order), etc. For your application, a 2nd order design is probably fine.
    Note that filters in general mess with your signal in some ways and the higher the order, the more audible this can get. By the way, this is pure physics and true for all signal processing including Fourier transforms.

    Using these three filters is (can be) equivalent to doing a Fourier transform with only three spectral points.

提交回复
热议问题