Git Product home page Git Product logo

pytermvis's Introduction

pytermvis

Python Terminal Audio Visualizer

Requirements

Required:

Optional:

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 -b alsa

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 -b 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 -r text

You can also run pytermvis using python's -m flag instead:

$ python -m pytermvis.run -r text

Extra Renderers

A basic install will only support a text-based renderer. To use the asciimatics or pygame renderers, you'll need to install their respective packages.

Asciimatics

$ pip install --user asciimatics

Once installed, asciimatics can be selected as the renderer by using the -r flag:

$ pytermvis -r asciimatics

Pygame

pip install --user pygame

Once installed, pygame can be selected as the renderer by using the -r flag:

$ pytermvis -r pygame

It will show the same prompt for selection of sound device as the other renderers. The difference is, a new window will be created in which the visualizer output is drawn.

Options

Shortcode Long Code Description
-c --char What character to draw with. One-character string. Default "*"
-s --sample-rate What rate to sample at. Integer. Default 44100.
-r --renderer Renderer to use. "text", "asciimatics", or "pygame". Default "text"
-b --backend Which backend sampler to use. "alsa" or "soundcard". Default "soundcard"
-t --type Which waveform to use. "audio" or "spectrum". Default "spectrum"
-v --visualization Which type of visualization to use. "graph" for solid bars/lines or "scope" for discrete points. Default "graph"

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/scipy'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 amplitude is printed as vertical lines using one of the renderers: asciimatics, pygame, or a printline output.

Issues

Requires Python 3.x, preferable 3.6+.

ALSA support isn't really configurable.

pytermvis's People

Contributors

bharris6 avatar

Stargazers

 avatar Karol Hetman avatar  avatar Dylan Zingler avatar

Watchers

Dylan Zingler avatar

pytermvis's Issues

ALSA Support

Right now only PulseAudio is supported on Linux due to the reliance on SoundCard for audio device attaching.

ALSA support should be added.

Options:

  • pyalsaaudio or other ALSA wrappers?
  • cli-visualizer style where it listens to a FIFO
    • Requires ALSA (re)configuration, not that hard to do though.

Alternate Audio and Spectral Views

It'd be nice to have a couple alternate ways of displaying the audio data. One reason is pygame rendering of the audio waveform is much more aesthetically pleasing than the frequency domain. Another is just to give some options for rendering.

First, allow selecting/rendering the audio waveform itself (non-FFT). Should be pretty simple... just a flag to pass in to the sampler as to whether it performs an FFT on the sample data.

-t or --type, options are "audio" or "spectrum". Default "spectrum".

Second, a "scope" view... this is probably a renderer change to plot points instead of lines.

-v or --visualization, options are "scope" or "graph". Default "graph".

Add Configurable Parameters Support

Right now, stuff like the print character and the sample rate is hardcoded. Need to split that into a configuration file which can be modified by the user.

Both configuration file and command-line arguments should be added.

Refactor Common Code

Common code, such as the normalize() function, should be moved to a separate file.

It would also be useful to have a more modular approach where the configuration defines whether it runs using pygame, asciimatics, etc.

FFT Analysis

I'm not happy with how the visualizer looks. It'd be nice to have:

  • Some smoothing across the bars
  • Some fallback averaging over time (so the bars aren't as jumpy)
  • Figure out why the frequencies are not as clearly distinguishable as other visualizers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.