bharris6 / pytermvis

Python Terminal Audio Visualizer
MIT License
4 stars 0 forks source link
audio terminal visualizer

pytermvis

Python Terminal Audio Visualizer

Requirements

Required:

How to install

$ 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

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.

How to run

ALSA requires specification of the right sampler:

$ pytermvis-cli -s alsaaudio

SoundCard

SoundCard supports Linux/pulseaudio, Mac/coreaudio, and Windows/WASAPI.

$ pip install --user soundcard

How to run

SoundCard is the default sampler, but can be specified as well:

$ pytermvis-cli -s soundcard

General How to Run

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

Extra Renderers

A basic install only supports the matplotlib renderer.

Options

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"

What does it do?

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.

Issues

Requires Python 3.4+.

ALSA support isn't really configurable.