svn commit: r453161 - in head/audio: . cava cava/files
Tobias Kortkamp
tobik at FreeBSD.org
Mon Oct 30 09:44:14 UTC 2017
Author: tobik
Date: Mon Oct 30 09:44:12 2017
New Revision: 453161
URL: https://svnweb.freebsd.org/changeset/ports/453161
Log:
New port: audio/cava
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
- Include a backport of an sndio input contributed by me
PR: 223301
Submitted by: omar.polo at protonmail.com (based on)
Added:
head/audio/cava/
head/audio/cava/Makefile (contents, props changed)
head/audio/cava/distinfo (contents, props changed)
head/audio/cava/files/
head/audio/cava/files/patch-config.c (contents, props changed)
head/audio/cava/files/patch-sndio (contents, props changed)
head/audio/cava/pkg-descr (contents, props changed)
head/audio/cava/pkg-plist (contents, props changed)
Modified:
head/audio/Makefile
Modified: head/audio/Makefile
==============================================================================
--- head/audio/Makefile Mon Oct 30 09:15:22 2017 (r453160)
+++ head/audio/Makefile Mon Oct 30 09:44:12 2017 (r453161)
@@ -63,6 +63,7 @@
SUBDIR += cantata
SUBDIR += caps-lv2
SUBDIR += caps-plugins
+ SUBDIR += cava
SUBDIR += ccaudio2
SUBDIR += cd-console
SUBDIR += cd-discid
Added: head/audio/cava/Makefile
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/audio/cava/Makefile Mon Oct 30 09:44:12 2017 (r453161)
@@ -0,0 +1,46 @@
+# $FreeBSD$
+
+PORTNAME= cava
+DISTVERSION= 0.6.0
+CATEGORIES= audio
+
+MAINTAINER= omar.polo at 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>
Added: head/audio/cava/distinfo
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/audio/cava/distinfo Mon Oct 30 09:44:12 2017 (r453161)
@@ -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
Added: head/audio/cava/files/patch-config.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/audio/cava/files/patch-config.c Mon Oct 30 09:44:12 2017 (r453161)
@@ -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);
Added: head/audio/cava/files/patch-sndio
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/audio/cava/files/patch-sndio Mon Oct 30 09:44:12 2017 (r453161)
@@ -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;
++}
Added: head/audio/cava/pkg-descr
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/audio/cava/pkg-descr Mon Oct 30 09:44:12 2017 (r453161)
@@ -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
Added: head/audio/cava/pkg-plist
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/audio/cava/pkg-plist Mon Oct 30 09:44:12 2017 (r453161)
@@ -0,0 +1,2 @@
+bin/cava
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/config
More information about the svn-ports-head
mailing list