karlstav / cava

Cross-platform Audio Visualizer
MIT License
4.22k stars 232 forks source link

config not properly installed. #420

Closed chincheta0815 closed 2 years ago

chincheta0815 commented 2 years ago

The config file for cava does not seem to be properly installed after running autogen.sh for whatever reason... Is there a way of installing the config via "make install"? and/or: cava writes a standard config after the first start if there is none. Right now there is just an empty file being written to $HOME/.config/cava after the first start.

karlstav commented 2 years ago

what do you mean by

not seem to be properly installed

?

autogen.sh will not overwrite the file if there is already one there. can that be the issue?

chincheta0815 commented 2 years ago

no. so far it just does not install/copy one. at least on mac os... that stupid for the brew formula...

my idea: usually you won't need to run "autogen.sh". most tools start at "configure". all file installation is done afterwards with "make install". so maybe that is a better option to put it there since it is more "standard" and might avoid issues...

karlstav commented 2 years ago

It is possible to generate the configure script and check it in. But there was a reason why I did not do this, however I have forgotten what that reason was.

it would be interesting to find out first why the copy does not work. it should be pretty straight forward. what is the output of running ./autogen.sh?

antiprism commented 2 years ago

It is not usual to check the configure script into the git repository, as it is a generated file, and you would also need to check in any other generated files like Makefile.in. On the other hand, the configure script will be included in a release tarball made by running make dist or make distcheck.

chincheta0815, have you installed the relavant packages on your system to run autogen.sh. A quick web search suggests

brew install autoconf automake libtool

Adrian.

chincheta0815 commented 2 years ago

It is not usual to check the configure script into the git repository, as it is a generated file, and you would also need to check in any other generated files like Makefile.in. On the other hand, the configure script will be included in a release tarball made by running make dist or make distcheck.

chincheta0815, have you installed the relavant packages on your system to run autogen.sh. A quick web search suggests

brew install autoconf automake libtool

Adrian.

Sure. Everything installted. But it might be that AT BUILD time the config is copied. So during install there won't be a config in the user who is installing... So the issue is a little bit more tricky.

But anyway: Right now the brew formula is a little bit on hold as the maintainter so homebrew like to a a test for cava. And I have no clue for another one than cava -v or so...

antiprism commented 2 years ago

Ok, I understand your messages now. The problem you are reporting is that the autogen.sh is installing the cava configuration file config, and that this file should be installed with make install instead. I agree this would be better and that users wouldn't expect files to be installed when they ran autogen.sh.

Adrian.

Karl, separate issue, but when I was reviewing the build I noticed that make dist and make distcheck didn't work for me. This means that a buildable tarball cannot be made, and that the source cannot be built outside the source tree (which is helpful to package maintainers). Note that cava is not compatible with the system iniparser on my system. and so I have to use the local cava one.

I fixed the make issues with the following changes. Some of them you may want todo something different, and so I haven't made a patch.

Add all the headers to SOURCES Makefile.am

cava_SOURCES = cava.c config.c input/common.c input/fifo.c input/shmem.c \
               output/terminal_noncurses.c output/raw.c config.h \
               input/alsa.h input/common.h input/fifo.h input/portaudio.h \
               input/pulse.h input/shmem.h input/sndio.h \
               output/raw.h output/sdl_cava.h output/terminal_bcircle.h \
               output/terminal_ncurses.h output/terminal_noncurses.h \
               debug.h util.h

and iniparser/Makefile.am

libiniparser_la_SOURCES = src/iniparser.c src/dictionary.c \
                          src/iniparser.h src/dictionary.h

Remove this line from Makefile.am

cava_SOURCES += iniparser/libiniparser.la

in config.c #include won't work if building in a separate directory using the local iniparser library

You could add a -D macro to CPPFLAGS in configure.ac if building the local iniparser, and then use this to #include "iniparser/src/iniparser,h" instead. configure.ac

AC_SUBST(SYSTEM_LIBINIPARSER, 0)
CPPFLAGS="$CPPFLAGS -DUSE_LOCAL_INIPARSER"
AC_CONFIG_FILES(iniparser/Makefile)

config.c

#ifdef USE_LOCAL_INIPARSER
  #include "iniparser/src/iniparser.h"
#else 
  #include <iniparser.h>
#endif

Finally cava.psf neetds to be included in the tarball Makefile.am

EXTRA_DIST = cava.psf
chincheta0815 commented 2 years ago

@Adrian Do you probably also know how one could test cava for not crashing after it was build. This is something the hombrew maintainers like to have. I have actually no clue... Here is the resp. pull request: https://github.com/Homebrew/homebrew-core/pull/89820

antiprism commented 2 years ago

Hi chincheta0815

Grab a short audio file, e.g. https://www2.cs.uic.edu/~i101/SoundFiles/CantinaBand3.wav

Make a cava configuration file, conf.txt

[general]
bars = 2
sleep_timer = 1

[input]
method = alsa
source = plughw:Loopback,1

[output]
method = raw
data_format = ascii

Install the alsa loopback module

sudo modprobe snd_aloop

Now, run cava in the background, play the audio file to cava's input, then kill cava when the file is finished playing.

cava -p conf.txt > tmp.txt &
aplay -D plughw:Loopback,0 CantinaBand3.wav
killall cava

It the file tmp.txt includes something other than pairs of zeros it is because cava has processed the audio

...
0;0;
0;0;
0;0;
0;0;
0;0;
0;0;
0;0;
0;0;
0;0;
9;9;
13;13;
16;16;
17;17;
23;23;
27;27;
29;29;
30;30;
30;30;
29;29;
25;25;
...

Adrian.

karlstav commented 2 years ago

alternativly just use fifo as source and use /dev/random or something:

[general]
bars = 2
sleep_timer = 1

[input]
method = fifo
source = /dev/random

[output]
method = raw
data_format = ascii

should produce non-zero values

[general]
bars = 2
sleep_timer = 1

[input]
method = fifo
source = /dev/zero

[output]
method = raw
data_format = ascii

should produce all zeroes.

cava does respond to sigterm. so you should be able to kill it just fine.

chincheta0815 commented 2 years ago

Okay. that helped. The brew formula got accepted, is merged and ready to use. Enjoy.