karlstav / cava Goto Github PK
View Code? Open in Web Editor NEWCross-platform Audio Visualizer
License: MIT License
Cross-platform Audio Visualizer
License: MIT License
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.
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!
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.
Here is the output of ./cava -i fifo -p 1000hz-s16le-2c-5sec.raw
:
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:
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?
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!
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).
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?
I'd suggest to Show time, date or even both (maybe selectable over arguments) in the Top-Right Corner.
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?
Building fails on Gentoo Linux. ./autogen.sh
and ./configure
ran fine though.
Maybe you want to add the build requirements for fedora to the readme?
For fedora you need:
alsa-lib-devel
ncurses-devel
fftw3-devel
I also wrote a simple specs file for automated rpm building: https://gist.github.com/sedrubal/617d40deb7452a25d004#file-cava-spec
And thanks for this program ;)
Until now the only way to change the available colors is to change the default terminal colors, is it possible to support more colors out of the box in the future?
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!
I'd like to see the top of bars with ~80% height, e.g. in red (like many other visualizers do, like this
is that possible?
https://aur.archlinux.org/packages/cava/
If it gets 10 votes it'll be (probably) moved to community
repo.
Using Funtoo. I'm happy to list any relevant versions of different libs.
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?
We should tag stable versions (i.e. for the purposes of packaging).
I've made an AUR package for git version: https://aur.archlinux.org/packages/cava-git and it'd be good to make a stable package.
Using urxvt
with the smallest width allowed, the program crashes and gives off this error:
floating point exception (core dump)
.
http://gfycat.com/WelltodoInfatuatedGypsymoth -- note that the music is paused.
I use mpd's fifo: cava -i fifo -p /tmp/mpd.fifo -b 60
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.
Continuation of #34.
Current progress:
Tested under Windows 10.
*** 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
# 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.
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.
The title doesn't have to be complex, just "cava" would be fine!
Thanks!
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. :-)
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?
so, i installed everything, did everything right, but when i try to run it it says segmentation fault
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.
[forget those, forgot to update cava; coming soon]
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
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
I can't figure out how to do this and would like to make it 220-370 instead of 20-12000 Hz.
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
.
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
[smoothing]
integral=0.0
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.
It seems less responsive for me.
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.
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.
@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!
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:
rm -r ~/.config/cava
(that's where the config should up for me, because $XDG_CONFIG_HOME
isn't set on my machine).make
.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.
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.
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).
The config file will in INI format:
#CONFIG FILE
paramter1=value1
;parameter2=value2
Suggested parameters:
Please make suggestions for other parameters.
Other considerations:
@CelestialWalrus has volunteered to do the initial work. Feel free to modify or reject any of my suggestions.
─── cava -i fifo -p /tmp/mpd.fifo -b 10
input method fifo is not supported, supported methods are: 'alsa' and 'fifo'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.