Coder Social home page Coder Social logo

karlstav / cava Goto Github PK

View Code? Open in Web Editor NEW
3.8K 44.0 217.0 1.38 MB

Cross-platform Audio Visualizer

License: MIT License

C 92.05% Shell 0.27% Makefile 0.63% M4 5.37% GLSL 1.58% CMake 0.09%
alsa audio-visualizer freebsd glsl-shaders linux macos ncurses portaudio pulseaudio sdl2

cava's Introduction

CAVA Build Status

Cross-platform Audio Visualizer

by Karl Stavestrand

Get it on Google Play

spectrum

Demo video

What it is

Cava is a bar spectrum audio visualizer for terminal (ncurses) or desktop (SDL).

works on:

  • Linux
  • FreeBSD
  • macOS
  • Windows

This program is not intended for scientific use. It's written to look responsive and aesthetic when used to visualize music.

Installing

From Source

Installing Build Requirements

Required components:

  • FFTW
  • libtool
  • automake
  • autoconf-archive (needed for setting up OpenGL)
  • pkgconf
  • build-essentials
  • iniparser

Recomended components:

The development lib of one of these audio frameworks, depending on your distro:

  • ALSA
  • Pulseaudio
  • Pipewire
  • Portaudio
  • Sndio
  • JACK

Optional components:

Only FFTW, iniparser and the build tools are actually required for CAVA to compile, but this will only give you the ability to read from fifo files. To capture audio directlty from your system pipewire, pulseaudio, alsa, sndio, jack or portaudio dev files are required (depending on what audio system you are using).

Ncurses can be used as an alternative output method if you have issues with the default one. But it is not required.

All the requirements can be installed easily in all major distros:

FreeBSD

pkg install autoconf autoconf-archive automake fftw3 iniparser jackit libglvnd libtool pkgconf psftools sdl2 sndio

Additionally, run these commands on FreeBSD before building:

export CFLAGS="-I/usr/local/include"
export LDFLAGS="-L/usr/local/lib"

Debian/Ubuntu:

sudo apt install build-essential libfftw3-dev libasound2-dev libncursesw5-dev libpulse-dev libtool automake autoconf-archive libiniparser-dev libsdl2-2.0-0 libsdl2-dev libpipewire-0.3-dev libjack-jackd2-dev pkgconf

ArchLinux:

pacman -S base-devel fftw ncurses alsa-lib iniparser pulseaudio autoconf-archive pkgconf

openSUSE:

zypper install alsa-devel ncurses-devel fftw3-devel libpulse-devel libtool autoconf-archive pkgconf

Fedora:

dnf install alsa-lib-devel ncurses-devel fftw3-devel pulseaudio-libs-devel libtool autoconf-archive iniparser-devel pkgconf

macOS:

First install homebrew if you have't already:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then install prerequisites:

brew install fftw ncurses libtool automake autoconf-archive pkgconf portaudio iniparser

The installation location for Homebrew packages is different between Intel Macs and Apple Silicon Macs. As such, the commands will be a little bit different. You can find out which type you have here

For both machines, run these commands to fix macOS not finding libtool and ncursesw:

export LIBTOOL=`which glibtool`
export LIBTOOLIZE=`which glibtoolize`
ln -s `which glibtoolize` /usr/local/bin/libtoolize

On an Intel Mac, run the following command as well:

ln -s /usr/lib/libncurses.dylib /usr/local/lib/libncursesw.dylib

On an Apple Silicon Mac, run this command instead:

ln -s /opt/homebrew/lib/lib/libncursesw.6.dylib /usr/local/lib/libncursesw.dylib

Note that the file name may be a little bit different depending on the versions, but the directory should be the same.

Additionally, run these commands on Apple Silicon Macs so that ./configure can find the Homebrew packages:

export LDFLAGS="-L/opt/homebrew/lib"
export CPPFLAGS="-I/opt/homebrew/include"

Intel Mac instructions tested on macOS Big Sur.

Apple Silicon instructions tested on macOS Ventura.

Windows:

see separate readme in cava_win folder.

Building

First of all clone this repo and cd in to it, then run:

./autogen.sh
./configure
make

If you have a recommended component installed, but do not wish to use it (perhaps if building a binary on one machine to be used on another), then the corresponding feature can be disabled during configuration (see configure --help for details).

For windows there is a VS solution file in the cava_win folder.

Installing

Install cava to default /usr/local:

make install

Or you can change PREFIX, for example:

./configure --prefix=PREFIX

Uninstalling

make uninstall

Package managers

All distro specific instalation sources might be out of date. Please check version before reporting any issues here.

FreeBSD

pkg install cava

openSUSE

Tumbleweed users have cava in their repo. They can just use:

zypper in cava

Leap users need to add the multimedia:apps repository first:

zypper ar -f obs://multimedia:apps/openSUSE_Leap_42.2 multimedia

If you use another version just replace openSUSE_Leap_42.2 with openSUSE_13.2, adjust it to your version.

Fedora

Cava is available in Fedora 26 and later. You can install Cava by running:

dnf install cava

Arch

Cava is in AUR.

pacaur -S cava

Ubuntu/Debian

Ubuntu 20.10 or more recent / Debian (unstable)
sudo apt install cava
Older Ubuntu

Harshal Sheth has added CAVA to his PPA, it can be installed with:

add-apt-repository ppa:hsheth2/ppa
apt update
apt install cava

macOS

cava is in homebrew.

brew install cava

Capturing audio

Pulseaudio

Just make sure you have installed pulseaudio dev files and that cava has been built with pulseaudio support (it should be automatically if the dev files are found).

If you're lucky all you have to do is to run cava.

If nothing happens you might have to use a different source than the default. The default might also be your microphone. Look at the config file for help.

Pipewire

Set

method = pipewire

The default source is auto and will most likely be your currently selected output. If you run wireplumber you can use wpctl to get the object.path or object.serial of the desired device to visualize.

e.g.

source = alsa:pcm:3:front:3:playback

ALSA

Set

method = alsa

in the config file.

ALSA can be difficult because there is no native way to grab audio from an output. If you want to capture audio straight fom the output (not just mic or line-in), you must create an ALSA loopback interface, then output the audio simultaneously to both the loopback and your normal interface.

To create a loopback interface simply run:

sudo modprobe snd_aloop

Hopefully your aplay -l should now contain a loopback interface.

To make it persistent across boot add the line snd-aloop to "/etc/modules". To keep it from being loaded as the first soundcard add the line options snd-aloop index=1 to "/etc/modprobe.d/alsa-base.conf", this will load it at '1'. You can replace '1' with whatever makes most sense in your audio setup.

Playing the audio through your Loopback interface makes it possible for cava to capture it, but there will be no sound in your speakers. In order to play audio on the loopback interface and your actual interface you must make use of the ALSA multi channel.

Look at the included example file example_files/etc/asound.conf on how to use the multi channel. I was able to make this work with a HDA Intel PCH sound card, but I had no luck with the an USB DAC.

Read more about the ALSA method here.

If you are having problems with the alsa method on Rasberry PI, try enabling mmap by adding the following line to /boot/config.txt and reboot:

dtoverlay=i2s-mmap

dmix

@reluekiss, was able to make cava work with dmix. Check out the example config in example_files/etc/asound_dmix.conf and issue 534.

mpd

Add these lines in mpd:

audio_output {
    type                    "fifo"
    name                    "my_fifo"
    path                    "/tmp/mpd.fifo"
    format                  "44100:16:2"
}

Uncomment and change input method to fifo in the config file.

The path of the fifo can be specified with the source parameter.

I had some trouble with sync (the visualizer was ahead of the sound). Reducing the ALSA buffer in mpd fixed it:

audio_output {
        type            "alsa"
        name            "My ALSA"
        buffer_time     "50000"   # (50ms); default is 500000 microseconds (0.5s)
}

Sndio

Set

method = sndio

Sndio is the audio framework used on OpenBSD, but it's also available on FreeBSD, NetBSD and Linux. So far this is only tested on FreeBSD, but it's probably very similar on other operating systems. The following example demonstrates how to setup CAVA for sndio on FreeBSD (please consult the OSS section for a deeper explanation of the various pcmX sound devices and the corresponding /dev/dspX audio devices in this example).

$ cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC1220 (Rear Analog)> (play/rec) default
pcm1: <Realtek ALC1220 (Front Analog Mic)> (rec)
pcm2: <USB audio> (play/rec)
No devices installed from userspace.

Sndio operates on device descriptors. In general for every /dev/dspX audio device there is a corresponding rsnd/X sndio raw device descriptor. In this example there are rsnd/0, rsnd/1 and rsnd/2 (they are not listed in /dev, sndio uses these descriptors to access the corresponding audio devices internally). Sndio also handles the implicit default device descriptor, which acts like a symlink to the raw device descriptor corresponding to the default audio device /dev/dsp. In this example it acts like a symlink to rsnd/0 because the default audio device /dev/dsp symlinks to /dev/dsp0. Sndio also evaluates the environment variables AUDIODEVICE and AUDIORECDEVICE. If one of these is set (AUDIORECDEVICE overrides AUDIODEVICE if both are set) and a sndio-aware program tries to open the default device descriptor or an unspecified device descriptor, then the program will use the device descriptor specified in the environment variable.

Now in order to visualize the mic input in CAVA, the source value in the configuration file must be set to the corresponding audio descriptor:

source = default    # default; symlink to rsnd/0 in this example; AUDIORECDEVICE and AUDIODEVICE evaluation
source =            # unspecified device descriptor; same as default above
source = rsnd/0     # for the pcm0 mic on the rear
source = rsnd/1     # for the pcm1 mic on the front
source = rsnd/2     # for the pcm2 mic on the USB headset

With source = default one can switch the visualization on the commandline without changing the configuration file again:

$ AUDIODEVICE=rsnd/0 cava
$ AUDIODEVICE=rsnd/1 cava
$ AUDIODEVICE=rsnd/2 cava

Sndio can't record the played back audio with just the raw device descriptors, i.e. the sounds from a music player or a browser which play on the external stereo speakers through rsnd/0 are not visualized in CAVA. For this to work the sndio server has to be started and a monitoring sub-device has to be created. The following example shows how to start the server and create a monitoring sub-device snd/0 from rsnd/0 and then start CAVA with AUDIODEVICE pointing to the new monitoring sub-device:

$ sndiod -f rsnd/0 -m play,mon
$ AUDIODEVICE=snd/0 cava

Switch between the speakers and the USB headset:

$ sndiod -f rsnd/2 -m play,mon -s usb -f rsnd/0 -m play,mon -s speakers
$ AUDIODEVICE=snd/usb cava
$ AUDIODEVICE=snd/speakers cava

Consult the manpage sndiod(8) for further information regarding configuration and startup of a sndio server.

OSS

Set

method = oss

The audio system used on FreeBSD is the Open Sound System (OSS). The following example demonstrates how to setup CAVA for OSS on FreeBSD:

$ cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC1220 (Rear Analog)> (play/rec) default
pcm1: <Realtek ALC1220 (Front Analog Mic)> (rec)
pcm2: <USB audio> (play/rec)
No devices installed from userspace.

The system has three pcm sound devices, pcm0, pcm1 and pcm2. pcm0 corresponds to the analog output jack on the rear, in which external stereo speakers are plugged in, and the analog input jack, in which one could plug in a microphone. Because it encapsulates both, output and input, it is marked as play/rec. It is also set as the default sound device. pcm1 corresponds to another analog input jack for a mic on the front side and is marked rec. A USB headset with an integrated mic is plugged in an USB port and the system has created the pcm2 sound device with play/rec capabilities for it.

In general for every pcmX device there is a corresponding /dev/dspX audio device. In this example there are /dev/dsp0, /dev/dsp1 and /dev/dsp2 (the system creates them when needed, they are not listed via ls /dev if they are currently not in use). The system also creates an implicit /dev/dsp, which acts like a symlink to the default audio device, in this example to /dev/dsp0.

Now in order to visualize the mic input in CAVA, the source value in the configuration file must be set to the corresponding audio device:

source = /dev/dsp     # default; symlink to /dev/dsp0 in this example
source = /dev/dsp0    # for the pcm0 mic on the rear
source = /dev/dsp1    # for the pcm1 mic on the front
source = /dev/dsp2    # for the pcm2 mic on the USB headset

OSS can't record the outgoing audio on its own, i.e. the sounds from a music player or a browser which play on the external stereo speakers through /dev/dsp0 are not visualized in CAVA. A solution is to use Virtual OSS. It can create virtual audio devices from existing audio devices, in particular it can create a loopback audio device from /dev/dsp0 and from which the played back audio can be fed into CAVA:

$ doas pkg install virtual_oss
$ doas virtual_oss -r44100 -b16 -c2 -s4ms -O /dev/dsp0 -R /dev/null -T /dev/sndstat -l dsp.cava

$ cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC1220 (Rear Analog)> (play/rec) default
pcm1: <Realtek ALC1220 (Front Analog Mic)> (rec)
pcm2: <USB audio> (play/rec)
Installed devices from userspace:
dsp.cava: <Virtual OSS> (play/rec)

It created a virtual loopback device /dev/dsp.cava from /dev/dsp0. Now the audio is visualized in CAVA with source = /dev/dsp.cava in the configuration file. The playback program must have a configuration to use the /dev/dsp.cava device. For programs where this is not possible, e.g. which always use /dev/dsp, replace -l dsp.cava with -l dsp. Virtual OSS can be configured and started as a service on FreeBSD.

JACK

Set

method = jack

The JACK Audio Connection Kit (JACK) is a professional sound server API which is available on several operating systems, e.g. FreeBSD and Linux.

CAVA is a JACK client with the base client name cava and adheres to the standard server start and stop behaviour, i.e. CAVA starts a JACK server if none is already running and the environment variable JACK_START_SERVER is defined, in which case the server also stops when all clients have exited. The source in the CAVA configuration file specifies the name of the JACK server to which CAVA tries to connect to. The default value is default, which is also the default JACK server name. The value can be empty, in which case it implies default. Therefore the following three entries are equivalent:

; source = default
source = default
source =

One exception is the combination of an empty source entry and the environment variable JACK_DEFAULT_SERVER. If the environment variable is defined, e.g. export JACK_DEFAULT_SERVER=foo, then the following entries are equivalent:

source = foo
source =

Consult the manpage jackd(1) for further information regarding configuration and startup of a JACK server.

CAVA creates terminal audio-typed (so no MIDI support) input ports. These ports can connect to output ports of other JACK clients, e.g. connect to the output ports of a music player and CAVA will visualize the music. Currently CAVA supports up to two input ports, i.e. it supports mono and stereo. The number of input ports can be controlled via the channels option in the input section of the configuration file:

channels = 1    # one input port, mono
channels = 2    # two input ports, stereo (default)

The port's short name is simply M for mono, and L and R for stereo. The full name of the input port according to the base client name is cava:M for mono, and cava:L and cava:R for stereo.

The option autoconnect controls the connection strategy for CAVA's ports to other client's ports:

autoconnect = 0    # don't connect to other ports automatically
autoconnect = 1    # only connect to other ports during startup
autoconnect = 2    # reconnect to new ports regularly (default)

The automatic connection strategies scan the physical terminal input-ports, i.e. the real audio device which actually outputs the sound, and applies the same connections to CAVA's ports. In this way CAVA visualizes the played back audio from JACK clients by default.

In order to control and manage the connection between CAVA's ports and ports of other client programs, there are connection management programs for JACK. Some well known connection managers with a graphical user interface are QjackCtl and Cadence. The JACK package itself often comes with CLI tools. Depending on the operating system it could be necessary to install them separately, e.g. on FreeBSD:

$ doas pkg install jack-example-tools

Among the tools are the programs jack_lsp and jack_connect. These two tools are enough to list and connect ports on the commandline. The following example demonstrates how to setup connections with these tools:

$ jack_lsp
system:capture_1
system:capture_2
system:playback_1
system:playback_2
cava:L
moc:output0
moc:output1
cava:R

This listing shows all full port names that are currently available. These correspond to two external JACK clients, cava and moc, and one internal JACK client system. The types and current active connections between the ports can be listed with the -p and -c switches for jack_lsp. In order to connect the ports of CAVA and MOC, jack_connect is used:

$ jack_connect cava:L moc:output0
$ jack_connect cava:R moc:output1

Now CAVA visualizes the outgoing audio from MOC.

squeezelite

squeezelite is one of several software clients available for the Logitech Media Server. Squeezelite can export its audio data as shared memory, which is what this input module uses. Just adapt your config:

method = shmem
source = /squeezelite-AA:BB:CC:DD:EE:FF

where AA:BB:CC:DD:EE:FF is squeezelite's MAC address (check the LMS Web GUI (Settings>Information) if unsure). Note: squeezelite must be started with the -v flag to enable visualizer support.

macOS

Note: Cava doesn't render correctly within the default macOS terminal. In order to achieve an optimal display, install Kitty. Beware that you may run in to the issue presented in #109; however, it can be resolved with this.

Background Music

Install Background Music which provides a loopback interface automatically. Once installed and running just edit your config to use this interface with portaudio:

method = portaudio
source = "Background Music"

Sound Flower

Soundflower also works to create a loopback interface. Use Audio MIDI Setup to configure a virtual interface that outputs audio to both your speakers and the loopback interface, following this recipe. By creating a multi-output device you lose the ability to control the volume on your keyboard. Because of this, we recommend the Background Music app which still gives you keyboard controls.

Then edit your config to use this interface with portaudio:

method = portaudio
source = "Soundflower (2ch)"

Windows

Should capture the audio from the default output device automatically.

Running via ssh

To run via ssh to an external monitor, redirect output to /dev/console:

 ~# ./cava  <> /dev/console >&0 2>&1

exit with ctrl+z then run 'bg' to keep it running after you log out.

(You must be root to redirect to console. Simple sudo is not enough: Run sudo su first.)

Troubleshooting

No bars in terminal

Most likley issue #399. Locale settings need to be set correctly in order for cava to work.

Visualizer reacts to microphone instead of output

This is a known issue with pipewire. Try the workaround described here

Vertical lines in bars

This is either an issue with the font, or line spacing being enabled in the terminal emulator. Try to change font or disable line spacing.

Low resolution

Since the graphics are simply based on characters, try decreasing the font size.

Low frame rate

Some terminal emulators are just slow. Cava will look best in a GPU based terminal like kitty or alacritty. You can also try to increase the font size

Font is changed in ttys after exit

If you run cava in a TTY (like ctrl+alt+F2) the program will change the font to the included cava.psf (actually a slightly modified "unifont").

In console fonts it seems that only 256 Unicode characters are supported, probably because they are bitmap fonts. I could not find a font with Unicode characters 2581-2587 (the 1/8 - 7/8 blocks used on the top of each bar to increase resolution).

So in cava.psf, the characters 1-7 are actually replaced by Unicode characters 2581-2587. When cava exits, it changes the font back. If cava exits abnormally and you notice that 1-7 are replaced by partial blocks, just change the font with setfont.

Actually, setfont is supposed to return the default font, but this usually isn't set. I haven't found another way to get the current font. So cava sets the font to "Lat2-Fixed16" when interrupted. All major distros should have it. It will revert to your default font at reboot.

Gradient not working in Konsole

Konsole simply does not support this. #194

Usage

Usage : cava [options]
Visualize audio input in terminal. 

Options:
	    -p          path to config file
	    -v          print version

Exit with ctrl+c or q.

If cava quits unexpectedly or is force killed, echo must be turned on manually with stty -echo.

Controls

NOTE: only works in ncurses output mode.

Key Description
up / down increase/decrease sensitivity
left / right increase/decrease bar width
f / b change foreground/background color
r Reload configuration
c Reload colors only
q or CTRL-C Quit C.A.V.A.

Configuration

As of version 0.4.0 all options are done in the config file, no more command-line arguments!

By default a configuration file is created upon first launch in $XDG_CONFIG_HOME/cava/config or $HOME/.config/cava/config, but cava can also be made to use a different file with the -p option.

Sending cava a SIGUSR1 signal, will force cava to reload its configuration file. Thus, it behaves as if the user pressed r in the terminal. One might send a SIGUSR1 signal using pkill or killall. For example:

$ pkill -USR1 cava

Similarly, sending cava a SIGUSR2 signal will only reload the colors from the configuration file, which is the same as pressing c in the terminal. This is slightly faster than reloading the entire config as the audio processing does not need to reinitialize.

$ pkill -USR2 cava

Examples on how the equalizer works:

[eq]
1=0
2=1
3=0
4=1
5=0

3_138

[eq]
1=2
2=2
3=1
4=1
5=0.5

3_139

Using cava in other applications

cavacore library

The core processing engine in cava has been split into a separate library cavacore. See CAVACORE.md for details.

Raw Output

You can also use Cava's output for other programs by using raw output mode, which will write bar data to STDOUT that can be piped into other processes. More information on this option is documented in the example config file.

A useful starting point example script written in python that consumes raw data can be found here.

Contribution

Please read CONTRIBUTING.md before opening a pull request.

Thanks to:

for major contributions in the early development of this project.

Also thanks to dpayne for figuring out how to find the pulseaudio default sink name.

cava's People

Contributors

anko avatar antiprism avatar binarii avatar bsdcode avatar chelovechishko avatar czinsii avatar dgrisham avatar dnalor avatar druppfv avatar dziubanmaciej avatar elafargue avatar emilgedda avatar hartwork avatar hashhar avatar hsheth2 avatar iamsubhranil avatar jubalh avatar karlstav avatar livibetter avatar orthographic-pedant avatar quantum5 avatar safinsingh avatar serial-ata avatar sionleroux avatar sjef avatar spydergamer avatar thecsw avatar tivervac avatar xyene avatar yash-garg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cava's Issues

questions about the output

Although it says:

This program is not intended for scientific use.

But I begin to wonder the output. It all started with #9.

I don't have any tools that can generate test audio, so I generated on my own (see below), an 1kHz, s16le, 2ch, raw PCM audio, 1000hz-s16le-2c-5sec.raw, using wave:

% echo $((44100*5)) 1 1000 | wave -r 44100 > 1000hz-f32le-1c-5sec.raw
% # aplay -f FLOAT_LE -r 44100 -c 1 -q 1000hz-f32le-1c-5sec.raw
% ffmpeg -f f32le -acodec pcm_f32le -ac 1 -i 1000hz-f32le-1c-5sec.raw -f s16le -acodec pcm_s16le -filter_complex "[0:a][0:a]amerge=inputs=2[aout]" -map "[aout]" -ac 2 1000hz-s16le-2c-5sec.raw

I commented out the parts in db80571 that I think they would be affecting: L568-570 and L595-606. I may miss some, but from the output of ALSA input, I get rid of them enough.

FIFO

Here is the output of ./cava -i fifo -p 1000hz-s16le-2c-5sec.raw:

2015-04-30--11 27 00

ALSA

And output of ./cava -i alsa -d pulse with playback by aplay -f S16_LE -r 44100 -c 2 -q 1000hz-s16le-2c-5sec.raw in background:

2015-04-30--10 30 51

Questions

Both peaks did indicate the 1kHz, when I changed the frequency, they shifted, so I believe that does show, but there should not have anything but a peak in FIFO.

  • Is FIFO processing correctly?

    Both outputs of inputs should look more or less the same, right? Did I feed in right format of data?

    Below 1k, the leftmost three peaks, there is something interfering, they look related, but I can't tell what it is.

    (Forgot almost everything I learned in signal processing. Sorry, professors!)

  • What are the frequency bands, exactly in the output we see?

    The locations of the peaks don't look right at all

    If the output is equally dividing 50-12kHz, 1kHz should be about one 12th of window width from the left. But both are close to the center.

    From what I can see, in -i alsa, the rightmost frequency/bar in output is somewhere around 9kHz.

    Is it log scale? 1k almost in middle, 10k almost at right, that sounds about right, doesn't it?

segmentation fault

so, i installed everything, did everything right, but when i try to run it it says segmentation fault

Treble sensitivity

Pre-e2a1265:

2_114

Post-e2a1265:

2_113

The bass is now recessed.

It happens with at least 10 tracks on my playlist. (probably more, only checked with ten)

[enhancement] Autosense low values as well

Just another thought I had. I frequently listen to music that varies in volume (I can't ReplayGain online streaming services), and I have autosens turned on so that the high peaks get toned down in cava. However, this means for quieter songs, cava is just a bubbling brook at the bottom of the terminal window.

It would be cool to set a lower threshold (or just default to something reasonable, like 80%) for autosens to adjust the sensitivity UP to for the peaks to fall into, to keep it entertaining. I'd imagine the timeout for lows could/should be longer than for highs, but again I'm probably asking for something much more complicated than I realize. :-)

Raspberry Pi

I am not capable of using your tool. Everytime I run it nothing happens. I can use "cava -v" and if I press CTRL-C it will stops but it shows no bars at all. By the way I'm running it on a Raspberry Pi.
unbenannt

Question Regarding Installation

Not necessarily an issue with the program... but I'm having trouble installing it on Ubuntu 14.04.3 LTS. I really like everything I've seen about the program. With regards to installation, my issues lie when I get to the sections: "Getting Started" and "Installing Manually". I believe I understand the sections after that... I just have no idea how to install it (And somehow allow the program to use FFTW?). Like I said, I'm very interested in using CAVA, I just need some guidance. Thanks!

Fails to run using pulseaudio

Having just built cava and rebooted (I needed to anyway for a kernel upgrade), so the pulseaudio server would restart, I now try to run it and receive the following error:

ALSA lib pcm_hw.c:1693:(_snd_pcm_hw_open) Invalid value for card
error opening stream: Operation not permitted

I am not in the audio as systemd handles session permissions sanely. When I try to run cava as root (mostly just for giggles), it segfaults with a coredump (from which I pulled the following backtrace):

#0  0x00007f502cfa21d4 in fclose@@GLIBC_2.2.5 () from /usr/lib/libc.so.6
#1  0x0000000000403cad in ?? ()
#2  0x000000000040449c in ?? ()
#3  0x00007f502cf5a790 in __libc_start_main () from /usr/lib/libc.so.6
#4  0x00000000004022c9 in ?? ()

The symbols were obviously stripped during the creation of the package for installation (under ArchLinux).

Feature Request: Set the terminal title

Cava doesn't currently set the window title so titlebars, etc show the terminal emulator's default title.

Here's a screen, notice how the terminal running cava still says "urxvt" while the other terminal running ncmpcpp has it's own title.

1

The title doesn't have to be complex, just "cava" would be fine!

Thanks!

Target 'copyconf' fails if config-path does not exist.

When trying to compile cava without having a path to the config-file, cp fails with the following message:

cp: cannot create regular file ‘/home/phijor/.config/cava/config’: No such file or directory

Steps to reproduce:

  1. rm -r ~/.config/cava (that's where the config should up for me, because $XDG_CONFIG_HOME isn't set on my machine).
  2. make.
  3. See it fail.

I will try to fix the issue, shouldn't be to difficult. I think it's the best if $CONFIGDIR actually contains the directory the config will reside in, not the absolute path to the file itself. That way one can check if it actually exists before trying to put something in it.

Error on Raspbian at run-time.

pi@raspberrypi:~/Desktop/cava $ cava
cava: error while loading shared libraries: libiniparser.so.4: cannot open shared object file: No such file or directory

It's not running under Raspberry Pi 2B. I have installed Raspbian GNU/Linux 8.0 (jessie).
There was no errors when I was compiling, I compiled it two times for being sure.

[Enhancement] Reload config from external signal

I'm loving cava so far, especially now that 0.4.0 has added direct PulseAudio support!

One thing I thought might be cool is if cava can reload the configuration when sent a signal, for example SIGUSR1, like httpd and various other programs which use USR1 as a command to reload the config.

The prime example of this is if I change the pulseaudio output/source, I want to automatically set the appropriate variable in cava's config and tell cava to re-read it, via a script. This would also apply for any other config changes.

Perhaps better, cava could watch the config file for changes and automatically reload it, but I think that may be a bit more involved than necessary.

I'm not sure if this is as simple as adding an if statement to sig_handler, or not, as I've rather little C experience.

The current state of cava on Windows

Continuation of #34.

Current progress:

  • Compiles under Cygwin
  • Doesn't compile under MSYS/MinGW (pthread missing)
  • ALSA will probably never work
  • FIFO will have to be replaced with named pipes on Windows
  • PulseAudio input works, but I couldn't get PulseAudio to get my Stereo Mix

Tested under Windows 10.

Unable to Run

gettting an error
error opening stream: Operation not permitted
cava: pcm_params.c:2288: snd_pcm_hw_refine: Assertion `pcm && params' failed.
Aborted (core dumped)
upon trying to start the program.

Freeze on launch without parameters.

EDIT: Massive PEBCAK here, it's been a long day. Turns out reading the top comment and realizing that ; is used as a comment character as well as # would help...

It seems the config file parsing is causing a crash, at least for me. Whenever I launch without parameters (ie, it's reading the config), or whenever I refresh the config inside of cava, it freezes.

For the former (launching w/out parameters), it just sits with the bars all at their lowest value, for the latter (refreshing config while cava is open and working), it blanks the screen and stops working.

I just re-tried, and it no longer freezes after refreshing in cava, it just fails to load the config.

I'm on build cava 0.3.4-10-ge02e383-dirty on Linux 4.2.0-gentoo-r1 x86_64.

module based source code

started working on module based source code using file structure suggested by @CelestialWalrus in #34 . See separate branch "modules".

Only been able to push ncurses drawing out in separate files for now. Made alsa and fifo files, but haven't gotten around to move the code yet.

It looks like it's plausible, but I have never done anything similar before. So any hints/tips much appreciated, thanks!

Use ncurses instead of printing a lot?

At the moment, cava renders each frame by printing term_width * term_height characters to fill the terminal.

This could be sped up using ncurses to only erase and re-print what changed.


Example:

Going from bars like

#   #
##  #
### #
#####

to

#    
##  #
#####
#####

would just mean doing this (d for delete, i for insert)

    d

   i 

with two cursor jumps, instead of re-printing the whole lot.

Idea: Check for /sys/module/snd_aloop/ if input is ALSA

The error "not permitted"

ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.29/work/alsa-lib-1.0.29/src/pcm/pcm_hw.c:1693:(_snd_pcm_hw_open) Invalid value for card
error opening stream: Operation not permitted

is a bit misleading, since adding sudo will not fix the problem. It would be cool if cava could check for the existence of /sys/module/ (sysfs mounted) and then for /sys/module/snd_aloop/ (module loaded). That should allow producing a more helpful error message. What do you think?

Time and Date

I'd suggest to Show time, date or even both (maybe selectable over arguments) in the Top-Right Corner.

Segfault

*** Error in `cava': free(): invalid next size (fast): 0x0000000001deee30 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x71e76)[0x7fa14f63ae76]
/usr/lib/libc.so.6(+0x776c6)[0x7fa14f6406c6]
/usr/lib/libc.so.6(+0x77eae)[0x7fa14f640eae]
/usr/lib/libiniparser.so.0(iniparser_load+0x208)[0x7fa15079aea8]
cava[0x40478d]
cava[0x40201d]
/usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7fa14f5e9680]
cava[0x4030e9]
======= Memory map: ========
00400000-00407000 r-xp 00000000 08:04 1983935                            /usr/bin/cava
00606000-00607000 r--p 00006000 08:04 1983935                            /usr/bin/cava
00607000-00608000 rw-p 00007000 08:04 1983935                            /usr/bin/cava
00608000-0060d000 rw-p 00000000 00:00 0
01dee000-01e0f000 rw-p 00000000 00:00 0                                  [heap]
7fa148000000-7fa148021000 rw-p 00000000 00:00 0
7fa148021000-7fa14c000000 ---p 00000000 00:00 0
7fa14efa1000-7fa14efb7000 r-xp 00000000 08:04 1972893                    /usr/lib/libgcc_s.so.1
7fa14efb7000-7fa14f1b6000 ---p 00016000 08:04 1972893                    /usr/lib/libgcc_s.so.1
7fa14f1b6000-7fa14f1b7000 rw-p 00015000 08:04 1972893                    /usr/lib/libgcc_s.so.1
7fa14f1b9000-7fa14f1c0000 r-xp 00000000 08:04 1972815                    /usr/lib/librt-2.22.so
7fa14f1c0000-7fa14f3bf000 ---p 00007000 08:04 1972815                    /usr/lib/librt-2.22.so
7fa14f3bf000-7fa14f3c0000 r--p 00006000 08:04 1972815                    /usr/lib/librt-2.22.so
7fa14f3c0000-7fa14f3c1000 rw-p 00007000 08:04 1972815                    /usr/lib/librt-2.22.so
7fa14f3c1000-7fa14f3c3000 r-xp 00000000 08:04 1972868                    /usr/lib/libdl-2.22.so
7fa14f3c3000-7fa14f5c3000 ---p 00002000 08:04 1972868                    /usr/lib/libdl-2.22.so
7fa14f5c3000-7fa14f5c4000 r--p 00002000 08:04 1972868                    /usr/lib/libdl-2.22.so
7fa14f5c4000-7fa14f5c5000 rw-p 00003000 08:04 1972868                    /usr/lib/libdl-2.22.so
7fa14f5c9000-7fa14f764000 r-xp 00000000 08:04 1972840                    /usr/lib/libc-2.22.so
7fa14f764000-7fa14f964000 ---p 0019b000 08:04 1972840                    /usr/lib/libc-2.22.so
7fa14f964000-7fa14f968000 r--p 0019b000 08:04 1972840                    /usr/lib/libc-2.22.so
7fa14f968000-7fa14f96a000 rw-p 0019f000 08:04 1972840                    /usr/lib/libc-2.22.so
7fa14f96a000-7fa14f96e000 rw-p 00000000 00:00 0
7fa14f971000-7fa14f9de000 r-xp 00000000 08:04 1972879                    /usr/lib/libncursesw.so.6.0
7fa14f9de000-7fa14fbdd000 ---p 0006d000 08:04 1972879                    /usr/lib/libncursesw.so.6.0
7fa14fbdd000-7fa14fbe1000 r--p 0006c000 08:04 1972879                    /usr/lib/libncursesw.so.6.0
7fa14fbe1000-7fa14fbe3000 rw-p 00070000 08:04 1972879                    /usr/lib/libncursesw.so.6.0
7fa14fbe9000-7fa14fc01000 r-xp 00000000 08:04 1972828                    /usr/lib/libpthread-2.22.so
7fa14fc01000-7fa14fe00000 ---p 00018000 08:04 1972828                    /usr/lib/libpthread-2.22.so
7fa14fe00000-7fa14fe01000 r--p 00017000 08:04 1972828                    /usr/lib/libpthread-2.22.so
7fa14fe01000-7fa14fe02000 rw-p 00018000 08:04 1972828                    /usr/lib/libpthread-2.22.so
7fa14fe02000-7fa14fe06000 rw-p 00000000 00:00 0
7fa14fe09000-7fa14ff85000 r-xp 00000000 08:04 1979946                    /usr/lib/libfftw3.so.3.4.4
7fa14ff85000-7fa150185000 ---p 0017c000 08:04 1979946                    /usr/lib/libfftw3.so.3.4.4
7fa150185000-7fa150192000 r--p 0017c000 08:04 1979946                    /usr/lib/libfftw3.so.3.4.4
7fa150192000-7fa150193000 rw-p 00189000 08:04 1979946                    /usr/lib/libfftw3.so.3.4.4
7fa150199000-7fa150297000 r-xp 00000000 08:04 1972859                    /usr/lib/libm-2.22.so
7fa150297000-7fa150496000 ---p 000fe000 08:04 1972859                    /usr/lib/libm-2.22.so
7fa150496000-7fa150497000 r--p 000fd000 08:04 1972859                    /usr/lib/libm-2.22.so
7fa150497000-7fa150498000 rw-p 000fe000 08:04 1972859                    /usr/lib/libm-2.22.so
7fa150499000-7fa15058c000 r-xp 00000000 08:04 1979637                    /usr/lib/libasound.so.2.0.0
7fa15058c000-7fa15078b000 ---p 000f3000 08:04 1979637                    /usr/lib/libasound.so.2.0.0
7fa15078b000-7fa150792000 r--p 000f2000 08:04 1979637                    /usr/lib/libasound.so.2.0.0
7fa150792000-7fa150794000 rw-p 000f9000 08:04 1979637                    /usr/lib/libasound.so.2.0.0
7fa150799000-7fa15079d000 r-xp 00000000 08:04 1983934                    /usr/lib/libiniparser.so.0
7fa15079d000-7fa15099c000 ---p 00004000 08:04 1983934                    /usr/lib/libiniparser.so.0
7fa15099c000-7fa15099d000 r--p 00003000 08:04 1983934                    /usr/lib/libiniparser.so.0
7fa15099d000-7fa15099e000 rw-p 00004000 08:04 1983934                    /usr/lib/libiniparser.so.0
7fa1509a1000-7fa1509c3000 r-xp 00000000 08:04 1972837                    /usr/lib/ld-2.22.so
7fa150bbd000-7fa150bc2000 rw-p 00000000 00:00 0
7fa150bc2000-7fa150bc3000 r--p 00021000 08:04 1972837                    /usr/lib/ld-2.22.so
7fa150bc3000-7fa150bc4000 rw-p 00022000 08:04 1972837                    /usr/lib/ld-2.22.so
7fa150bc4000-7fa150bc6000 rw-p 00000000 00:00 0
7fa150bc6000-7fa150bc9000 rw-p 00000000 00:00 0
7ffe1e2e8000-7ffe1e30a000 rw-p 00000000 00:00 0                          [stack]
7ffe1e3a9000-7ffe1e3ab000 r--p 00000000 00:00 0                          [vvar]
7ffe1e3ab000-7ffe1e3ad000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
uname -a
Linux betsy 4.1.12_1 #1 SMP PREEMPT Tue Oct 27 06:38:21 UTC 2015 x86_64 GNU/Linux

gcc --version
gcc (GCC) 4.9.3

License and thoughts

I noticed a few things and I'd like to contribute, however, there is no license and I don't like to touch code without written open source license.

@karlstav would you license C.A.V.A? If yes, @anko and @CelestialWalrus do you agree on the license?


Here is a list I might do:

  • no consistent coding style, and issues like \t and space mixed in indentations and trailing whitespace, etc.

    This one has to be done first, or more inconsistence would be made.

  • makefile, use canned recipe and turn on -Wall and -Wextra, etc.

  • warnings like the following and things popping out after turning on warnings:

    cava.c:586:40: warning: universal character names are only valid in C++ and C99 [enabled by default]
                                     printf("\u2588");
    

    It's just warning, although cava works fine, but I think this should be dealt with properly.

    I think this need @karlstav to decide the direction, either -std=c99 or print out UTF8-encoded? I am not sure since I have never dealt with the Unicode, not really a C coder. (And #4 related or helped?)

    If taking C99 route, usleep might need to be replaced with nanosleep or there would be another warning.

Build fails on Arch due to ncurses6

ncurses6 was added to the testing repos on arch and cava fails to build because it can't find ncurses5.

For ncurses6 users, I've found two temporary solutions:

  • Symlink the ncurses6 binary

    sudo ln -s /bin/ncursesw6-config /bin/ncursesw5-config
    
  • Or Change "ncursesw5-config" on line 18 of the makefile to "ncursesw6-config"

Rebuild after either symlinking or editing the makefile and it should build and run fine.

Please support building against system's iniparser (rather than the bundled one)

Hi!

Some Linux distros do have packages for iniparser, e.g. Gentoo does. It would be cool to be able to build cava against the iniparser installed system-wide rather than the bundled one. For a list of reasons why that would be helpful, let me point to this page:
https://wiki.gentoo.org/wiki/Why_not_bundle_dependencies

In case a related patch does not seem worth your own time at the moment, please let me know if you would accept a patch in that direction, in general.

Best, Sebastian

Please identify license

I tried identifying the license in LICENSE. It's a permissive license, but seems to match none of ISC, BSD, zlib, .. exactly. Did you make a custom license or did I just miss the one? If it's non-custom, please mention the name somewhere. If it's custom, please consider moving to something non-custom.

Thanks and best, Sebastian

Windows build / switch to PortAudio

Well, I was thinking about porting cava to Windows & OS X, and I think a switch to PortAudio would be great, because it solves some of the issues.

Also: I think you can use PortAudio on Android, so that'd be nice.

PortAudio is a free, cross-platform, open-source, audio I/O library. It lets you write simple audio programs in 'C' or C++ that will compile and run on many platforms including Windows, Macintosh OS X, and Unix (OSS/ALSA).

Config file

The config file will in INI format:

#CONFIG FILE
paramter1=value1
;parameter2=value2

Suggested parameters:

  • input method
  • alsa device
  • fifo path
  • output method
  • color/background color
  • frame rate
  • Sensitivity
  • number of bars
  • cutoff frequencies
    • High frequency cutoff
    • Low frequency cutoff
  • smoothing
    • "integral" smoothing
    • "moster cat" smoothing
    • gravity
  • equalizer
    • base
    • mid tone
    • treble

Please make suggestions for other parameters.

Other considerations:

  • Should all parameters be overridable via command line arguments?
  • Should all parameters be adjustable real time via keyboard shortcuts?(nice to have)
  • Should there be a possibility to save adjusted parameters real time back in to the config file?(nice to have)

@CelestialWalrus has volunteered to do the initial work. Feel free to modify or reject any of my suggestions.

Numbers being displayed instead of bars

Here's a screenshot of what I am seeing. If I run cava in the tty, the bars are displayed correctly, so this makes me think that it is a font issue, but I have tried different fonts with nothing changing.

Cannot compile with debug=1 on raspbian (Debian/Jessie)

This is the error:

root@moode:~/cava# make debug=1
cd iniparser && make
make[1]: Entering directory '/root/cava/iniparser'
CC      src/iniparser.o
CC      src/dictionary.o
AR      libiniparser.a
a - src/iniparser.o
a - src/dictionary.o
RANLIB  libiniparser.a
LINK    libiniparser.so
make[1]: Leaving directory '/root/cava/iniparser'
gcc -std=c99 -Wall -Wextra -DPACKAGE=\"cava\" -DVERSION=\"0.3.5-8-g74e74e4\" -D_POSIX_SOURCE -D _POSIX_C_SOURCE=200809L -Iiniparser/src -DDEBUG   cava.c iniparser/libiniparser.a  iniparser/libiniparser.a -lasound -lm -lfftw3 -lpthread -I/usr/include/ncursesw -lncursesw -ltinfo -o cava
cava.c: In function ‘main’:
cava.c:804:28: error: ‘peak’ undeclared (first use in this function)
        lcf[o], hcf[o], peak[o], f[o]);
                ^
cava.c:804:28: note: each undeclared identifier is reported only once for each function it appears in
cava.c:380:6: warning: variable ‘flastd’ set but not used [-Wunused-but-set-variable]
  int flastd[200];
      ^
<builtin>: recipe for target 'cava' failed
make: *** [cava] Error 1

Parallel make issue, e.g. with make -j5

# make -j5
[..]
gcc: error: ./iniparser/libiniparser.a: No such file or directory
[..]

The issue is missing dependencies. Target cava actually depends on presence of iniparser/libiniparser.a but the dependency is not coded into the Makefile.

Pulseaudio, Yay or Nay?

Looking at other visualizer like projectM, I think pulseaudio is able to grab audio directly from sink. This would eliminate the need for the complicated 'alsa loopback'+'pulseaudio combined sink' setup.

Now I know a lot of people don't like pulseaudio. I use it, mostly because it came with my disrto and it works. The alsa part will of course be kept as an option.

I think this will also require a configure script that checks for the presence of alsa or pulseaudio and creates the makefile accordingly.

So is it worth it making cava able to use pulseaudio directly? Do people use pulseaudio?

Automated unit tests?

Now that we've got all sorts of pull requests going on, it might be good to at least think about unit-testing. We've had regressions and they're always hard to catch manually, but could have been prevented with automated tests that check for known past issues and correctness.

I don't know exactly how the tests would look, but @livibetter's manual test of piping generated sound into cava's inputs (#15) might make a good starting point.

In its present state, cava is tough to write tests for, as everything is in a single file that does many things. Separating the model ("how high should bars be") from its presentation ("how do we print this") would be a good first step.

Further thoughts, ideas?

config script

@dylanaraps @CelestialWalrus or who ever might be reading this, I started working on the config script in a separate branch. It's not really my area of expertise, yet... and I'm kinda stuck. I guess I will figure it out eventually, but any help would be much appreciated. Thanks!

Raw output?

I'm looking into the feasibility of using CAVA output to drive a visualizer for Volumio (https://volumio.org). I was envisioning displaying the spectrum analyzer output on the client side, in their browser.

Any chance CAVA can output the FFT results to fifo? We can then push it through a websocket, and let the client draw the spectrum.

Thanks!

Top bars not cleared in "ncurses-cava"

Issue was first raised in #36 by @CelestialWalrus, see illustration here.

Might be the same as what @rolf1304 describers as " flickering cursors at the bars' tops" in #36 .

I'm not seeing the same issue in Terminator on my computer, suggesting that it might be related to something else then the terminal software. @CelestialWalrus can you provide info about font and terminal settings? @rolf1304 can you look at the gif and confirm if it is the same issue you are seeing?

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.