Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This is just a quick example of how to use the raw ASCII output from CAVA in an application
// A minimal set of NodeJS code for parsing incoming ASCII data from CAVA and turning it into useful data.
// This code would need to have cava's output piped to it:
// Ex: $ cava -p ~/.config/cava/raw | node cava_ascii_output_parser.js
let str = '';
process.stdin.on('readable', () => {
let chunk;
// Use a loop to make sure we read all available data.
while ((chunk = !== null) {
str += chunk;
// CAVA's convention for marking the ends of frames is the @ symbol
const frameEnd = str.indexOf('@');
if (frameEnd > 0) {
displayFrame(str.substring(0, frameEnd));
str = str.substring(frameEnd + 1);
function displayFrame(f) {
// Bars are separated by semi-colons
// Do something with the frames
// This line references code not present in the gist
process.stdin.on('end', () => {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.