I'm working on an audio visualizer using Blender, and I'm wanting to separate input audio files into their respective frequencies to allow my models to react based on the amplitude at different frequencies. Is there a Python library out there that can (somewhat simply) separate an audio file into different frequencies? I'm going to be generating 12 different animations with audio files, and want to be able to decide which frequencies to separate out and whatnot.
What you need is a filter bank.
For audio, typically, fractional octave filter banks are used. This Python library can help you.
If you want to specify the bands yourself, here is another Python library than can help. You'll want to look into their Linkwitz-Riley crossover network implementation (
crossover). These are particularly interesting because their magnitude responses sum to unity gain (if you decide to modify the band-passed signals and re-construct).
You want to extract signal components within a specific frequency range. For this you can use a band-pass filter. If you use several filter, then you can call it a filter-bank.
There are several option to build a band-pass filter. You can check:
- Scipy.signal https://docs.scipy.org/doc/scipy/reference/signal.html
- Librosa https://librosa.org/doc/latest/index.html
- Pyfar https://pyfar.readthedocs.io/en/latest/readme.html
I would go with scipy.signal because of the great set of tools (either for filtering but also for filter design and analysis). It is also quite fast and with a great community of developers.
A filter takes a signal as input and provides a signal as output. After the signal is filteres you must also decide how you will use it for your purposes. I suggest to extract segment of a predefined duration (1sec for example) and calculate the average power of the filtered signal.