This Project is a small cli program written in C that takes the raw ascii output from Cava
and converts it into lines of block elements.
- Cmake
To build this program you will need to clone the repository
git clone https://github.com/JonathanSteininger/CavaRawBarWrapper.git
Go into the directory
cd CavaRawBarWrapper
Add a build directory
mkdir build
make build files and build the program
cmake -S . -B build && cmake --build build
The final program is "build/cavawrapper"
You can do this all at once
git clone https://github.com/JonathanSteininger/CavaRawBarWrapper.git
cd CavaRawBarWrapper
mkdir build
cmake -S . -B build && cmake --build build
To use this cli program. You need to pipe in data in the format "0;0;0;0;0;\n" through stdin. The size of the numbers and the amount of values doesn't matter.
aslong as there arent more than 300 values It should work.
You can use an application like Cava in raw ascii output mode to get this data and pipe it into this program.
An example would be like this:
cava | ./cavawrapper
Its recommended to make a local cava config and pass that into cava.
cava -p local/path/to/config | ./cavawrapper
You can get a list of arguments their uses through the use of the -h and --help argument.
./cavawrapper -h
cavawrapper Help Screen
This program reads the raw output from cava in ascii mode.
The cava output will need to be piped into this program.
Optional Arguments:
--bar-added-height [num] - (default: 0) - adds a set amount of height to every bar.
Usefull if you want to permenantly see the bars even when theres little to no sound.
--minimum-output-height [amount of layers] - (default: 10) - forces the program to output a minimum amount of layers.
This will not change the bars height, but will make the program draw alot more empty space.
This is usefull if another program struggels with the length of the output changing alot.
--input-bar-delimiter [ascii code] - (default: 59) - Changes the expected charecter between inputed bar values.
--input-frame-delimiter [ascii code] - (default: 10) - Changes the expected charecter after all bar values are printed.
--output-layer-delimiter [ascii code] - (default: 59) - Changes the output charecter that goes in between each layer
--output-frame-delimiter [ascii code] - (default: 10) - Changes the output charecter that goes after evey layer has been printed
--position-output [position] - (default: bottom) - Chooses the direction of the output. options: bottom, left, top, right
I recommend you use this program just for the application that needs it by copying it into its directory and having it start the program.
To use this for Eww I recommend you copy the cavawrapper program into the eww config directory with eww.yuck.
Making a local Cava config file is recommended.
To use it in eww:
(deflisten soundBars
`cava -p ./localCavaConfig | ./cavawrapper`)
To Display the bars:
(defwidget []
(box :valign "end"
(box :valign "end" "${replace(soundBars, ";", "
")}")
)
)
This will replace the raw data's seperator charecter with a new line.
you can't insert a \n char in eww so you have to make the string use a real new line char instead (thats why it looks ugly and wraps like that).
I recomend to use a monospaced font like "Hack" so the bars connect on each line.
For some reason eww stutters when the outputed string changes size really fast.
You can use the argument --minimum-output-height to set a minimum amount of layers.
The larger this value is the smoother eww will display it. However, eww will use more power when nothing is playing.
This program will take an input until a end of frame charecter has been found (default = '\n').
When the end of the frame has been found it will process it into the final output.
The output will be layers of text split by a delimiter charecter (default = ';') and print it to std out.
Lets stay the input is '0;1;2;3;4;\n'
The output would be: ' ▁▂▃▄\n'
if the bars are high enough the output will be split into layers with a delimiter.
input: '0;1;12;8\n;'
output: ' ▄ ; ▁██\n'
When You take this output and replace the delimiter ';' with '\n' you get:
▄
▁██
Using a monospaced font like Hack would have the bars semlessly stack on top of each other to give the elusion of a solid bar.