diff options
author | Tobias Kortkamp <tobik@FreeBSD.org> | 2017-10-30 09:44:12 +0000 |
---|---|---|
committer | Tobias Kortkamp <tobik@FreeBSD.org> | 2017-10-30 09:44:12 +0000 |
commit | 6e458c9091e9364a80b9b7905745f9bbae265273 (patch) | |
tree | 4b8258de60c7e54761976d4a67485ecd5ae79fc6 /audio/cava | |
parent | fee60457a959850c192e9742ebdfc02759fa7c91 (diff) | |
download | ports-6e458c9091e9364a80b9b7905745f9bbae265273.tar.gz ports-6e458c9091e9364a80b9b7905745f9bbae265273.zip |
Notes
Diffstat (limited to 'audio/cava')
-rw-r--r-- | audio/cava/Makefile | 46 | ||||
-rw-r--r-- | audio/cava/distinfo | 3 | ||||
-rw-r--r-- | audio/cava/files/patch-config.c | 11 | ||||
-rw-r--r-- | audio/cava/files/patch-sndio | 176 | ||||
-rw-r--r-- | audio/cava/pkg-descr | 7 | ||||
-rw-r--r-- | audio/cava/pkg-plist | 2 |
6 files changed, 245 insertions, 0 deletions
diff --git a/audio/cava/Makefile b/audio/cava/Makefile new file mode 100644 index 000000000000..dee7a87a7b3e --- /dev/null +++ b/audio/cava/Makefile @@ -0,0 +1,46 @@ +# $FreeBSD$ + +PORTNAME= cava +DISTVERSION= 0.6.0 +CATEGORIES= audio + +MAINTAINER= omar.polo@protonmail.com +COMMENT= Console-based Audio Visualizer for ALSA, MPD, PulseAudio, and sndio + +LICENSE= MIT +LICENSE_FILE= ${WRKSRC}/LICENSE + +LIB_DEPENDS= libfftw3.so:math/fftw3 \ + libiniparser.so:devel/iniparser + +USES= autoreconf libtool localbase ncurses +USE_GITHUB= yes +GH_ACCOUNT= karlstav + +GNU_CONFIGURE= yes +CONFIGURE_ENV= ac_cv_lib_asound_snd_pcm_open=no + +INSTALL_TARGET= install-strip + +OPTIONS_DEFINE= PULSEAUDIO SNDIO +OPTIONS_DEFAULT=PULSEAUDIO + +PULSEAUDIO_CONFIGURE_ENV_OFF= ac_cv_lib_pulse_simple_pa_simple_new=no +PULSEAUDIO_LIB_DEPENDS= libpulse-simple.so:audio/pulseaudio \ + libpulse.so:audio/pulseaudio \ + +SNDIO_CONFIGURE_ENV_OFF= ac_cv_lib_sndio_sio_open=no +SNDIO_LIB_DEPENDS= libsndio.so:audio/sndio + +post-patch: + @${REINPLACE_CMD} '/^cava_font/d' ${WRKSRC}/Makefile.am + @${REINPLACE_CMD} '/<alloca.h>/d' ${WRKSRC}/cava.c + +pre-configure: + @${ECHO_CMD} ${DISTVERSION} > ${WRKSRC}/version + +post-install: + @${MKDIR} ${STAGEDIR}${EXAMPLESDIR} + ${INSTALL_DATA} ${WRKSRC}/example_files/config ${STAGEDIR}${EXAMPLESDIR} + +.include <bsd.port.mk> diff --git a/audio/cava/distinfo b/audio/cava/distinfo new file mode 100644 index 000000000000..1a33c786224e --- /dev/null +++ b/audio/cava/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1509139935 +SHA256 (karlstav-cava-0.6.0_GH0.tar.gz) = 42d51c6c283cd2b0f5125954ea8c61a12385703d1953ef9c40103402c7a744dc +SIZE (karlstav-cava-0.6.0_GH0.tar.gz) = 40990 diff --git a/audio/cava/files/patch-config.c b/audio/cava/files/patch-config.c new file mode 100644 index 000000000000..8059acc60d45 --- /dev/null +++ b/audio/cava/files/patch-config.c @@ -0,0 +1,11 @@ +--- config.c.orig 2017-08-26 08:52:40 UTC ++++ config.c +@@ -378,7 +378,7 @@ if (p->smcount > 0) { + iniparser_getseckeys(ini, "eq", keys); + #endif + #ifdef LEGACYINIPARSER +- char **keys = iniparser_getseckeys(ini, "eq"); ++ char **keys = iniparser_getseckeys(ini, "eq", keys); + #endif + for (int sk = 0; sk < p->smcount; sk++) { + p->smooth[sk] = iniparser_getdouble(ini, keys[sk], 1); diff --git a/audio/cava/files/patch-sndio b/audio/cava/files/patch-sndio new file mode 100644 index 000000000000..47fff0abd39e --- /dev/null +++ b/audio/cava/files/patch-sndio @@ -0,0 +1,176 @@ +https://github.com/karlstav/cava/commit/76fa7c132da25f5499a0f1b5dc4b416a34dad737 + +diff --git a/cava.c b/cava.c +index 76197cd..64dff25 100644 +--- cava.c ++++ cava.c +@@ -53,6 +53,10 @@ + #include "input/pulse.c" + #endif + ++#ifdef SNDIO ++#include "input/sndio.c" ++#endif ++ + #include <iniparser.h> + + #include "config.h" +@@ -287,6 +291,9 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co + #ifdef PULSE + strcat(supportedInput,", 'pulse'"); + #endif ++ #ifdef SNDIO ++ strcat(supportedInput,", 'sndio'"); ++ #endif + + //fft: planning to rock + fftw_complex outl[M / 2 + 1][2]; +@@ -388,6 +395,13 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co + } + #endif + ++ #ifdef SNDIO ++ if (p.im == 4) { ++ thr_id = pthread_create(&p_thread, NULL, input_sndio, (void*)&audio); ++ audio.rate = 44100; ++ } ++ #endif ++ + if (p.highcf > audio.rate / 2) { + cleanup(); + fprintf(stderr, +diff --git a/config.c b/config.c +index 1da11cd..9f8465e 100644 +--- config.c ++++ config.c +@@ -87,6 +87,13 @@ if (strcmp(inputMethod, "pulse") == 0) { + #endif + + } ++if (strcmp(inputMethod, "sndio") == 0) { ++ p->im = 4; ++ #ifndef SNDIO ++ fprintf(stderr, "cava was built without sndio support\n"); ++ exit(EXIT_FAILURE); ++ #endif ++} + if (p->im == 0) { + fprintf(stderr, + "input method '%s' is not supported, supported methods are: %s\n", +@@ -325,6 +332,10 @@ inputMethod = (char *)iniparser_getstring(ini, "input:method", "fifo"); + inputMethod = (char *)iniparser_getstring(ini, "input:method", "pulse"); + #endif + ++//setting sndio to defaualt if supported ++#ifdef SNDIO ++ inputMethod = (char *)iniparser_getstring(ini, "input:method", "sndio"); ++#endif + + #ifdef NCURSES + outputMethod = (char *)iniparser_getstring(ini, "output:method", "ncurses"); +@@ -402,6 +413,12 @@ if (strcmp(inputMethod, "pulse") == 0) { + p->im = 3; + p->audio_source = (char *)iniparser_getstring(ini, "input:source", "auto"); + } ++#ifdef SNDIO ++if (strcmp(inputMethod, "sndio") == 0) { ++ p->im = 4; ++ p->audio_source = (char *)iniparser_getstring(ini, "input:source", SIO_DEVANY); ++} ++#endif + + validate_config(supportedInput, params); + //iniparser_freedict(ini); +diff --git a/configure.ac b/configure.ac +index 6e3c291..92fa281 100644 +--- configure.ac ++++ configure.ac +@@ -64,6 +64,19 @@ AC_CHECK_LIB(pulse-simple, pa_simple_new, have_pulse=yes, have_pulse=no) + AC_MSG_NOTICE([WARNING: No pusleaudio dev files found building without pulseaudio support]) + fi + ++dnl ###################### ++dnl checking for sndio dev ++dnl ###################### ++AC_CHECK_LIB(sndio, sio_open, have_sndio=yes, have_sndio=no) ++ if [[ $have_sndio = "yes" ]] ; then ++ LIBS="$LIBS -lsndio" ++ CPPFLAGS="$CPPFLAGS -DSNDIO" ++ fi ++ ++ if [[ $have_sndio = "no" ]] ; then ++ AC_MSG_NOTICE([WARNING: No sndio dev files found building without sndio support]) ++ fi ++ + dnl ###################### + dnl checking for math lib + dnl ###################### +diff --git a/input/sndio.c b/input/sndio.c +new file mode 100644 +index 0000000..6142225 +--- /dev/null ++++ input/sndio.c +@@ -0,0 +1,63 @@ ++#include <assert.h> ++#include <errno.h> ++#include <sndio.h> ++#include <string.h> ++ ++void* input_sndio(void* data) ++{ ++ struct audio_data *audio = (struct audio_data *)data; ++ struct sio_par par; ++ struct sio_hdl *hdl; ++ int16_t buf[256]; ++ unsigned int i, n, channels; ++ ++ assert(audio->channels > 0); ++ channels = audio->channels; ++ ++ sio_initpar(&par); ++ par.sig = 1; ++ par.bits = 16; ++ par.le = 1; ++ par.rate = 44100; ++ par.rchan = channels; ++ par.appbufsz = sizeof(buf) / channels; ++ ++ if ((hdl = sio_open(audio->source, SIO_REC, 0)) == NULL) { ++ fprintf(stderr, __FILE__": Could not open sndio source: %s\n", audio->source); ++ exit(EXIT_FAILURE); ++ } ++ ++ if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par) || par.sig != 1 || par.le != 1 || par.rate != 44100 || par.rchan != channels) { ++ fprintf(stderr, __FILE__": Could not set required audio parameters\n"); ++ exit(EXIT_FAILURE); ++ } ++ ++ if (!sio_start(hdl)) { ++ fprintf(stderr, __FILE__": sio_start() failed\n"); ++ exit(EXIT_FAILURE); ++ } ++ ++ n = 0; ++ while (audio->terminate != 1) { ++ if (sio_read(hdl, buf, sizeof(buf)) == 0) { ++ fprintf(stderr, __FILE__": sio_read() failed: %s\n", strerror(errno)); ++ exit(EXIT_FAILURE); ++ } ++ ++ for (i = 0; i < sizeof(buf)/sizeof(buf[0]); i += 2) { ++ if (par.rchan == 1) { ++ // sndiod has already taken care of averaging the samples ++ audio->audio_out_l[n] = buf[i]; ++ } else if (par.rchan == 2) { ++ audio->audio_out_l[n] = buf[i]; ++ audio->audio_out_r[n] = buf[i + 1]; ++ } ++ n = (n + 1) % 2048; ++ } ++ } ++ ++ sio_stop(hdl); ++ sio_close(hdl); ++ ++ return 0; ++} diff --git a/audio/cava/pkg-descr b/audio/cava/pkg-descr new file mode 100644 index 000000000000..09f188cb05be --- /dev/null +++ b/audio/cava/pkg-descr @@ -0,0 +1,7 @@ +C.A.V.A. is a bar spectrum audio visualizer for the terminal using +ALSA, PulseAudio, sndio or fifo buffer for input. + +This program is not intended for scientific use. It's written to look +responsive and aesthetic when used to visualize music. + +WWW: https://karlstav.github.io/cava diff --git a/audio/cava/pkg-plist b/audio/cava/pkg-plist new file mode 100644 index 000000000000..e206a4ca5b2c --- /dev/null +++ b/audio/cava/pkg-plist @@ -0,0 +1,2 @@ +bin/cava +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/config |