A simple, janky, yet charming terminal-based audio visualizer written in Python. It can visualize audio data from a microphone or any other audio input device.
See /image_gallery
to see the program in action.
- Visualize audio data in vertical or horizontal bar charts.
- Adjustable parameters such as smoothing factor, buffer size, sampling rate, and number of bars.
- Theme support for customizing the visual output.
- Works on Linux, macOS, and Windows.
- Works best in VSC terminal, kitty, and alacritty.
sudo apt-get install -y portaudio19-dev
Setup a loopback device.
brew install blackhole-2ch
- Open the "Audio MIDI Setup" app.
- Create an "Aggregate Device" with the default input device and "BlackHole 2ch".
- Set this Aggregate Device as the input device
On Windows, audio routing can be tricky. If you want to visualize audio from your speakers or headphones instead of just the microphone, you will need to use a virtual audio cable. Follow these steps:
- Download and install a virtual audio cable from VB-Audio
- Set your playback device to the virtual audio cable.
- In your recording devices, set the virtual audio cable as the default recording device.
- Route the audio through your headphones or speakers.
This will allow for the program to render the audio that is being outputted on the device as well as continue to have the user be able to hear the same audio.
brew install audio_visualizer
Will add to other package managers (like winget, AUR, etc) if asked.
-
Clone the repository:
git clone https://github.com/gituser12981u2/audio_visualizer
-
Set up a virtual environment:
python3 -m venv .venv
source .venv/bin/activate # On Windows, use '.venv\Scripts\activate'
-
Install the package:
pip install .
If your system has a compatible Nvidia or AMD GPU, you can enable GPU acceleration by installing an additional dependency:
pip install .[gpu]
<package manager install> audio_visualizer --with-gpu
Note: GPU acceleration is not recommended if your system supports AMX, as native operations are more efficient for this program.
Then follow these instructions to install the CUDA––for Nvidia––or ROCm––for AMD––toolkit.
To Start the visualizer, use the following command:
audio-visualizer
Or run this command for the same outcome:
audio-visualizer --mode vertical
Or to run in horizontal mode:
audio-visualizer --mode horizontal-ltr
Note: there are two horizontal modes. One that draws bars from left to right (ltr) and one that draws bars from right to left (rtl)
Modify config.lua
to change default settings and key bindings. This file controls various aspects of the Audio Visualizer's behavior, including the visual mode, hotkeys, and audio processing parameters.
- Linux/macOS: Place your
config.lua
in~/.config/audio_visualizer/
. This is the recommended location as it follows the standard configuration directory structure on Unix-like systems. - Windows: Place your
config.lua
in%APPDATA%\audio-visualizer\
. This location is recommended for Windows users as it aligns with the typical application data storage.
If a config.lua
file is not found in these locations, the program will attempt to load it from the directory where the audio-visualizer
command is executed.
Switch visualization modes dynamically with configured hotkeys. For example, the default keybindings are:
- 'ctrl+h': horizontal ltr mode
- 'ctrl+l': horizontal rtl mode
- 'ctrl+j': vertical mode
Themes allow you to customize the visual appearance of the audio visualizer:
- background_color: Set to a 'RGB' value like '255;0;0' for red, or 'default to use the terminal's default color.
- bar_color: Set to a 'RGB' value or 'default' to use the terminal's default color.
--mode
: Visualization mode('vertical or horizontal). Default isvertical
. That is if you put no--mode
option.--alpha
: Smoothing factor for FFT. Default is0.4
.--chunk
: Number of frames per buffer. Default is2048
.--rate
: Sampling rate Default is44100
.
Example:
audio-visualizer --mode horizontal-rtl --alpha 0.3 --chunk 1024 --rate 48000
This project is licensed under the MIT License. See the LICENSE file for details.
This project is inspired by cava.
Thank you to the follow people for their contributions to this project:
-@ohksith - Provided fix for the terminal to clean it self after visualization stopped