Python Terminal Audio Visualizer
Required:
$ git clone https://github.com/bharris6/pytermvis.git
$ cd pytermvis
$ pip install .
Once installed, you need to set up the appropriate sampler for your machine.
ALSA support relies on the pyalsaaudio
package and a loopback module snd-aloop
being loaded. Then your ALSA configuration needs to support splitting sound output to the loopback interface as well as to your normal speakers.
$ pip install --user pyalsaaudio
Some resources for ALSA loopback configuration can be found below:
NOTE: There's also the alsaloop command, but I have not played with that.
ALSA requires specification of the right sampler:
$ pytermvis-cli -s alsaaudio
SoundCard
supports Linux/pulseaudio, Mac/coreaudio, and Windows/WASAPI.
$ pip install --user soundcard
SoundCard
is the default sampler, but can be specified as well:
$ pytermvis-cli -s soundcard
The install method will put a command pytermvis
on your path that you can execute. Once you've installed pytermvis
itself and installed an appropriate sampler, you can run it using that command:
$ pytermvis -m audio
You can also run pytermvis
using python's -m
flag instead:
$ python -m pytermvis.run -m audio
A basic install only supports the matplotlib renderer.
Shortcode | Long Code | Description |
---|---|---|
--rate | What rate to sample at. Integer. Default 44100. | |
--period | How many chunks/frames per sample. Integer. Default 1024. | |
-r | --renderer | Renderer to use. "text" or "matplotlib". Default "text" |
-s | --sampler | Which backend sampler to use. "alsaaudio" or "soundcard". Default "soundcard" |
-m | --mode | Which visualization to display. "audio" for the sound signal itself, or "fft"/"bfft"/"gfft" for various FFT transformations. Default "audio" |
pytermvis
uses SoundCard
's or pyalsaaudio
's ability to record from "loopback" devices. This means it is basically catching the audio output of your speaker and passing those raw frames through numpy
's FFT to get the frequency domain representation. Then, that FFT data is split into buckets based on the terminal width and each bucket's magnitude is printed as vertical lines using one of the renderers.
Requires Python 3.4+.
ALSA support isn't really configurable.